Skip to main content

AudioMixBus

Trait AudioMixBus 

pub trait AudioMixBus: Send + Sync {
    // Required methods
    fn stream_info(&self) -> StreamInfo;
    fn write_block(&self, samples: &[f32]);
    fn pull(&self, out: &mut [f32]);
}
Expand description

The contract between audio-producing lanes and the audio backend.

All methods are &self so the bus can sit inside an Arc shared by multiple lanes (writers) and the backend’s callback (single reader).

Required Methods§

fn stream_info(&self) -> StreamInfo

Channel count and sample rate negotiated with the device.

Lanes use this to size their writes (frames × channels) and to avoid sample-rate conversion mismatches.

fn write_block(&self, samples: &[f32])

Push interleaved PCM samples produced by an audio lane.

samples.len() must be a multiple of stream_info().channels. Implementations may drop the oldest data on overflow — audio is real-time and stale samples are worse than silence.

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

Drain the next out.len() samples into the hardware output buffer. Called from the audio backend’s callback thread.

Underrun (queue shorter than out.len()) is filled with silence (0.0) — never blocks, never allocates.

Implementors§