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: AtomicU64Frames read while it was empty, and times frames were dropped as it held four times what it keeps.
adjustments: AtomicU64Implementations§
Source§impl FrameBuffer
impl FrameBuffer
pub fn new(channels: u16, margin: usize) -> Self
Sourcepub fn push(&self, samples: &[f32])
pub fn push(&self, samples: &[f32])
Adds interleaved frames, keeping no more than four times the margin and the device’s chunk.
Sourcepub fn pull(&self, out: &mut [f32])
pub fn pull(&self, out: &mut [f32])
Fills out with the oldest frames, silence where there are none.
Sourcepub fn hold_more(&self, frames: usize)
pub fn hold_more(&self, frames: usize)
Holds as many as frames more before dropping the oldest.
Sourcepub fn drop_oldest(&self, frames: usize)
pub fn drop_oldest(&self, frames: usize)
Drops the oldest frames, as many as are held at most.
Sourcepub fn device_push(&self, samples: &[f32])
pub fn device_push(&self, samples: &[f32])
The device’s side: adds one chunk, and notes the fill after it.
Sourcepub fn device_pull(&self, out: &mut [f32], plays_at: Option<i64>)
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.
Sourcepub fn device_sample(&self) -> Option<DeviceSample>
pub fn device_sample(&self) -> Option<DeviceSample>
The fill right after the device’s last chunk.
Auto Trait Implementations§
impl !Freeze for FrameBuffer
impl !RefUnwindSafe for FrameBuffer
impl Forget for FrameBuffer
impl Move for FrameBuffer
impl Send for FrameBuffer
impl Sync for FrameBuffer
impl Unpin for FrameBuffer
impl UnsafeUnpin for FrameBuffer
impl UnwindSafe for FrameBuffer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more