Skip to main content

FrameBuffer

Struct FrameBuffer 

Source
pub struct FrameBuffer {
    pub underruns: AtomicU64,
    pub adjustments: AtomicU64,
    /* private fields */
}
Expand description

Interleaved sample frames passed between an audio device’s callback and a stream’s thread.

Fields§

§underruns: AtomicU64

Frames read while it was empty, and times frames were dropped as it held four times what it keeps.

§adjustments: AtomicU64

Implementations§

Source§

impl FrameBuffer

Source

pub fn new(channels: u16, margin: usize) -> Self

Source

pub fn push(&self, samples: &[f32])

Adds interleaved frames, keeping no more than four times the margin and the device’s chunk.

Source

pub fn pull(&self, out: &mut [f32])

Fills out with the oldest frames, silence where there are none.

Source

pub fn pushed(&self) -> u64

Frames ever pushed on the stream’s side.

Source

pub fn hold_more(&self, frames: usize)

Holds as many as frames more before dropping the oldest.

Source

pub fn drop_oldest(&self, frames: usize)

Drops the oldest frames, as many as are held at most.

Source

pub fn device_push(&self, samples: &[f32])

The device’s side: adds one chunk, and notes the fill after it.

Source

pub fn device_pull(&self, out: &mut [f32], plays_at: Option<i64>)

The device’s side: takes one chunk, and notes the fill after it and, where the device says, when the oldest frame left plays.

Source

pub fn device_sample(&self) -> Option<DeviceSample>

The fill right after the device’s last chunk.

Source

pub fn level(&self) -> usize

The frames held.

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<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

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.

Source§

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

Source§

fn to_sample_(self) -> U

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.