Struct FileDecoder

Source
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

Source

pub fn open(path: &Path) -> Result<Self, Error>

Open a local file and read its format without decoding the whole track.

Source

pub fn open_native(path: &Path) -> Result<Self, Error>

Background analysis never launches an external decoder with uncontrolled producer work.

Source

pub fn sample_rate(&self) -> u32

Sample rate of the decoded PCM, in Hz.

Source

pub fn channels(&self) -> u16

Number of interleaved channels in each frame.

Source

pub fn channel_layout(&self) -> ChannelLayout

Speaker positions, when the decoder exposes them.

Source

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.

Source

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.

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<S> FromSample<S> for S

§

fn from_sample_(s: S) -> S

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

§

fn into_sample(self) -> T

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,