pub trait ContainerDecoder: Send {
// Required methods
fn open(&mut self, path: &Path) -> Result<StreamInfo>;
fn next_frame(&mut self) -> Result<Option<AudioFrame>>;
}Expand description
Multi-format container decoder.
Runs on a worker thread (not the RT audio thread): file I/O and heap allocation are expected and permitted here. Decoded frames should be handed to a lock-free ring buffer so the RT thread never blocks on this trait.
§Design notes
ContainerDecoder::openreturns a populatedStreamInforather than a bare stream handle, so callers can validate format/channel/rate before the first decode.ContainerDecoder::next_framereturnsOption<AudioFrame>:Ok(None)signals normal end-of-stream;Err(CodecError::Eof)is reserved for callers that treat EOF as a hard error.- Samples are stored in planar layout (
[ch0…, ch1…]) perAudioFrame; symphonia’s interleaved output is de-interleaved by the concrete decoder before construction.
Required Methods§
Sourcefn open(&mut self, path: &Path) -> Result<StreamInfo>
fn open(&mut self, path: &Path) -> Result<StreamInfo>
Open the container at path, sniff/probe the format, and return the
stream metadata.
§Errors
CodecError::Ioif the file cannot be opened or read.CodecError::Formatif the container format is unrecognised.
Sourcefn next_frame(&mut self) -> Result<Option<AudioFrame>>
fn next_frame(&mut self) -> Result<Option<AudioFrame>>
Decode the next chunk as a planar AudioFrame.
Returns Ok(None) at end-of-stream (never panics on EOF). Samples are
stored in planar layout ([ch0…, ch1…]) per AudioFrame.
§Errors
CodecError::Decodeif the stream is corrupt or a packet is malformed.CodecError::Ioif an underlying read fails mid-stream.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".