Skip to main content

AudioSampleReader

Struct AudioSampleReader 

Source
pub struct AudioSampleReader<D> { /* private fields */ }
Expand description

Exact presentation-range access over a track’s sequential audio packets.

Implementations§

Source§

impl<D: AudioDecoder> AudioSampleReader<D>

Source

pub fn new( decoder: D, packets: Vec<EncodedAudioSample>, sample_rate: u32, channels: u16, timing: AudioTrackTiming, preroll_packets: usize, limits: Limits, ) -> Result<Self>

preroll_packets is how many packets before the first one a request needs are decoded first after a reset, so the decoder’s state has converged by the time it reaches the samples that are returned.

Source

pub const fn sample_rate(&self) -> u32

Source

pub const fn channels(&self) -> u16

Source

pub const fn presentation_length(&self) -> u64

Source

pub fn timing(&self) -> &AudioTrackTiming

Source

pub fn get_range( &mut self, range: SampleRange, cancellation: &CancellationToken, ) -> Result<AudioBuffer>

Returns exactly the requested contiguous half-open presentation range.

Source

pub fn get( &mut self, timeline: Timeline, frame: FrameIndex, cancellation: &CancellationToken, ) -> Result<AudioBuffer>

Source

pub fn reset(&mut self) -> Result<()>

Cancels are caller-owned; reset drops queued decode state before a seek.

Auto Trait Implementations§

§

impl<D> Freeze for AudioSampleReader<D>
where D: Freeze,

§

impl<D> RefUnwindSafe for AudioSampleReader<D>
where D: RefUnwindSafe,

§

impl<D> Send for AudioSampleReader<D>
where D: Send,

§

impl<D> Sync for AudioSampleReader<D>
where D: Sync,

§

impl<D> Unpin for AudioSampleReader<D>
where D: Unpin,

§

impl<D> UnsafeUnpin for AudioSampleReader<D>
where D: UnsafeUnpin,

§

impl<D> UnwindSafe for AudioSampleReader<D>
where D: UnwindSafe,

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.

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.

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.