pub struct FileDecoder { /* private fields */ }Expand description
Decodes one local audio file progressively into caller-owned PCM buffers.
Each successful read produces at most one decoded packet. Short reads are
normal; only Ok(0) means end of stream. The caller can feed the returned
portion of the buffer to aede-dsp after creating a matching PCM format.
Implementations§
Source§impl FileDecoder
impl FileDecoder
Sourcepub fn open(path: &Path) -> Result<Self, Error>
pub fn open(path: &Path) -> Result<Self, Error>
Open a local file and read its format without decoding the whole track.
Sourcepub fn open_native(path: &Path) -> Result<Self, Error>
pub fn open_native(path: &Path) -> Result<Self, Error>
Background analysis never launches an external decoder with uncontrolled producer work.
Sourcepub fn sample_rate(&self) -> u32
pub fn sample_rate(&self) -> u32
Sample rate of the decoded PCM, in Hz.
Sourcepub fn channel_layout(&self) -> ChannelLayout
pub fn channel_layout(&self) -> ChannelLayout
Speaker positions, when the decoder exposes them.
Sourcepub fn flac_md5_status(&self) -> Option<FlacMd5Status>
pub fn flac_md5_status(&self) -> Option<FlacMd5Status>
FLAC source MD5 status, or None for another codec.
Verification uses original integer samples before float conversion or DSP and becomes conclusive only at EOF. Stopping early leaves it pending. Progressive seeking also decodes the discarded prefix and therefore still permits whole-source verification when the remainder reaches EOF.
Sourcepub fn read_frames(&mut self, output: &mut [f32]) -> Result<usize, Error>
pub fn read_frames(&mut self, output: &mut [f32]) -> Result<usize, Error>
Fill a buffer with complete frames and return the number of frames.
The buffer must be nonempty and its length divisible by channels().
A rejected buffer is unchanged and does not advance decoding. A valid
buffer may receive fewer frames than it can hold, even before EOF.
Sourcepub fn skip_frames(
&mut self,
frames: u64,
cancelled: impl FnMut() -> bool,
) -> Result<SeekResult, Error>
pub fn skip_frames( &mut self, frames: u64, cancelled: impl FnMut() -> bool, ) -> Result<SeekResult, Error>
Discard up to frames complete source frames from the current position.
This uses the ordinary decoder, preserving encoder-delay and end-trim handling exactly. Memory stays bounded by one decoded packet, but work grows with the traversed audio. Cancellation is checked before decoding and after at most 4096 discarded frames; an individual decoder call may still block on I/O. On cancellation or a decode error, discard this decoder: its partially advanced position is not a successful seek.