mirror of
https://github.com/kilyabin/psysonic.git
synced 2026-07-22 14:35:41 +00:00
a4c400cc69
M4A files store the iTunSMPB value behind a 16-byte binary 'data' atom header. The previous parser took bytes directly after the ASCII key, landing in the binary header and producing a corrupted parts array (total_valid=348 instead of ~13M samples), which caused take_duration to exhaust the source in ~8ms — silent no-playback. Fix: search for the " 00000000 " sentinel within 128 bytes of the key to locate the actual value string, falling back to the old offset for ID3v2/MP3 files where no binary header exists. Also patches symphonia-format-isomp4 (local crate under patches/) to: - Tolerate SL descriptor predefined=0x01 (older iTunes M4A) - Convert descriptor.unwrap() panic to a proper decode error - Gracefully skip malformed trak atoms (e.g. MJPEG cover-art streams) instead of failing the entire probe Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
42 lines
1.1 KiB
Rust
42 lines
1.1 KiB
Rust
// Symphonia
|
|
// Copyright (c) 2019-2022 The Project Symphonia Developers.
|
|
//
|
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
|
|
use symphonia_core::errors::Result;
|
|
use symphonia_core::io::ReadBytes;
|
|
|
|
use crate::atoms::{Atom, AtomHeader};
|
|
|
|
/// Chunk offset atom (32-bit version).
|
|
#[allow(dead_code)]
|
|
#[derive(Debug)]
|
|
pub struct StcoAtom {
|
|
/// Atom header.
|
|
header: AtomHeader,
|
|
pub chunk_offsets: Vec<u32>,
|
|
}
|
|
|
|
impl Atom for StcoAtom {
|
|
fn header(&self) -> AtomHeader {
|
|
self.header
|
|
}
|
|
|
|
fn read<B: ReadBytes>(reader: &mut B, header: AtomHeader) -> Result<Self> {
|
|
let (_, _) = AtomHeader::read_extra(reader)?;
|
|
|
|
let entry_count = reader.read_be_u32()?;
|
|
|
|
// TODO: Apply a limit.
|
|
let mut chunk_offsets = Vec::with_capacity(entry_count as usize);
|
|
|
|
for _ in 0..entry_count {
|
|
chunk_offsets.push(reader.read_be_u32()?);
|
|
}
|
|
|
|
Ok(StcoAtom { header, chunk_offsets })
|
|
}
|
|
}
|