Struct Compressed Reader
pub struct CompressedReader { /* private fields */ }Expand description
Lazy decoded single-default-track FLAC/MP3/Vorbis reader. Requires compressed.
Encoded input is copied once (1..64 MiB); decoded frames are capped by caller
1..16,777,216 and total interleaved samples <=16,777,216. Decoded packet capacity
<=65536 frames, channels 1..64/rate 1..768000. Backend allocations remain its own
contract. No file/network I/O, resampling, speaker remapping or callback use.
Gapless trims apply; EOF checks declared duration/decoder integrity. Changing
configurations/chained resets reject. The default constructor uses replay seeks.
new_indexed_flac instead verifies the whole native FLAC stream once and retains
a bounded compressed-packet index; both modes swap seek candidates only on success.
Implementations§
§impl CompressedReader
impl CompressedReader
pub fn new( encoded: &[u8], maximum_frames: usize, ) -> Result<Self, AudioFileError>
pub fn new_indexed_flac(
encoded: &[u8],
maximum_frames: usize,
) -> Result<Self, AudioFileError>
pub fn new_indexed_flac( encoded: &[u8], maximum_frames: usize, ) -> Result<Self, AudioFileError>
Build an exact native-FLAC compressed-packet index on the calling worker. Copies 1..64 MiB input temporarily, decodes/verifies every packet once and retains at most 65,536 compressed packets / 64 MiB payload plus index metadata. No complete PCM clip or original container copy is retained. Caller frame and 16,777,216-sample limits still apply. A nonzero declared FLAC frame count is required. MP3, Vorbis and Ogg-FLAC reject. Subsequent seeks binary-search packet timestamps and decode only the containing packet (at most 65,536 frames); EOF seeks decode none. All methods still allocate on a worker and supply no file/device or deadline guarantee.
pub fn indexed_packets(&self) -> Option<usize>
pub fn indexed_packets(&self) -> Option<usize>
Number of verified retained FLAC packets, or None in default replay mode.
pub fn sample_rate(&self) -> u32
pub fn channels(&self) -> u16
pub fn position_frames(&self) -> usize
pub fn declared_frames(&self) -> Option<u64>
pub fn end_of_file(&self) -> bool
pub fn end_of_file(&self) -> bool
True only after EOF duration/integrity checks complete. Queued/read-ahead audio may still need playback; cursor equality alone is not this signal.
pub fn read_frames(
&mut self,
output: &mut [f32],
) -> Result<usize, AudioFileError>
pub fn read_frames( &mut self, output: &mut [f32], ) -> Result<usize, AudioFileError>
Read up to 65536 whole interleaved frames. Success leaves the unused output tail unchanged; zero-sized output makes no progress. Invalid buffer lengths reject before mutation. Decode faults clear the whole supplied output and poison reads (cursor may have advanced); successful seek can recover.
pub fn seek_frame(&mut self, frame: usize) -> Result<(), AudioFileError>
pub fn seek_frame(&mut self, frame: usize) -> Result<(), AudioFileError>
Exact decoded-frame seek including EOF; failure preserves old decoder, cursor and poison state. Default mode replays O(target) worker frames; indexed FLAC mode searches the immutable index and decodes one packet. Both modes allocate candidate backend/pending storage outside audio.
Trait Implementations§
§impl PlaybackReader for CompressedReader
Available on crate feature compressed only.
impl PlaybackReader for CompressedReader
compressed only.