Skip to main content

ContainerDecoder

Trait ContainerDecoder 

Source
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::open returns a populated StreamInfo rather than a bare stream handle, so callers can validate format/channel/rate before the first decode.
  • ContainerDecoder::next_frame returns Option<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…]) per AudioFrame; symphonia’s interleaved output is de-interleaved by the concrete decoder before construction.

Required Methods§

Source

fn open(&mut self, path: &Path) -> Result<StreamInfo>

Open the container at path, sniff/probe the format, and return the stream metadata.

§Errors
Source

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

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§