Skip to main content

AlsaPlaybackBridge

Struct AlsaPlaybackBridge 

Source
pub struct AlsaPlaybackBridge<P> { /* private fields */ }
Expand description

Drives an audio graph processor from an ALSA playback callback.

Implementations§

Source§

impl<P: Processor> AlsaPlaybackBridge<P>

Source

pub fn new(processor: P, spec: PcmSpec, max_block_frames: u32) -> Result<Self>

Builds a playback bridge, preparing processor for the given spec.

max_block_frames is the largest callback block the bridge will accept and must be greater than zero. The processor is prepared with the spec’s sample rate, channel count, and this block bound.

Source

pub fn render_buffer(&mut self, frames: usize) -> Result<PcmBuffer>

Renders frames of audio into a PcmBuffer in the spec’s format.

F32 output is returned directly; I16 output is converted from the rendered F32 samples.

Source

pub fn render_interleaved_f32(&mut self, frames: usize) -> Result<Vec<f32>>

Renders frames of audio and returns interleaved F32 samples.

Errors when frames exceeds the configured max_block_frames. The processor runs over a single ProcessBlock with a playing transport; the bridge’s sample position advances by frames.

Source

pub fn sample_pos(&self) -> u64

Returns the running sample position across rendered blocks.

Source

pub fn reset(&mut self)

Resets the processor, sample position, and scratch arena.

Trait Implementations§

Source§

impl<P: Debug> Debug for AlsaPlaybackBridge<P>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<P> Freeze for AlsaPlaybackBridge<P>
where P: Freeze,

§

impl<P> RefUnwindSafe for AlsaPlaybackBridge<P>
where P: RefUnwindSafe,

§

impl<P> Send for AlsaPlaybackBridge<P>
where P: Send,

§

impl<P> Sync for AlsaPlaybackBridge<P>
where P: Sync,

§

impl<P> Unpin for AlsaPlaybackBridge<P>
where P: Unpin,

§

impl<P> UnsafeUnpin for AlsaPlaybackBridge<P>
where P: UnsafeUnpin,

§

impl<P> UnwindSafe for AlsaPlaybackBridge<P>
where P: 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 = 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.