pub struct AudioSystem<const STREAMS: usize = 4, const STREAM_BYTES: usize = 2048, const MIX_FRAMES: usize = 128, const OUTPUTS: usize = 2, const SINK_BYTES: usize = 3072> { /* private fields */ }Expand description
A fixed pool of independent 48 kHz stereo interleaved F32 streams and outputs.
Defaults reserve 8 KiB for application PCM and 6 KiB for output PCM. The
fifth generic is bytes per sink (3072 = three 128-frame stereo F32 blocks).
Queue sizes must be frame-aligned; each output must hold a whole mix block.
Pin the system before registering outputs or mixing, using core::pin::pin!
for local storage or alloc::boxed::Box::pin for an owned platform service.
All storage is inline. Writes, controls, registration and mixing return
[IoErrorKind::WouldBlock] immediately on contention; no operation waits or spins.
Output consumption never takes the core lock.
use audio::AudioSystem;
let mut system: AudioSystem = AudioSystem::new().unwrap();
// A registered queue may not move, even when its handle is forgotten.
let pinned = core::pin::Pin::new(&mut system);Implementations§
Source§impl<const S: usize, const B: usize, const F: usize, const O: usize, const Q: usize> AudioSystem<S, B, F, O, Q>
impl<const S: usize, const B: usize, const F: usize, const O: usize, const Q: usize> AudioSystem<S, B, F, O, Q>
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Creates empty, paused 48 kHz stereo F32 streams without allocation.
Invalid const capacities return InvalidArgument.
Sourcepub fn set_master_volume(&self, volume: u8) -> Result<()>
pub fn set_master_volume(&self, volume: u8) -> Result<()>
Sets the master gain, from 0 to 100 percent.
Sourcepub fn mix_next_block(self: Pin<&Self>) -> Result<()>
pub fn mix_next_block(self: Pin<&Self>) -> Result<()>
Mixes one quantum and copies it to every output with room for a full block. A full output drops this block without affecting any other output.
Sourcepub fn open_output(self: Pin<&Self>) -> Result<OutputHandle<'_, S, B, F, O, Q>>
pub fn open_output(self: Pin<&Self>) -> Result<OutputHandle<'_, S, B, F, O, Q>>
Reserves a sink and resets its queue and drop counter.
Sourcepub fn open_stream(&self) -> Result<StreamHandle<'_, S, B, F, O, Q>>
pub fn open_stream(&self) -> Result<StreamHandle<'_, S, B, F, O, Q>>
Reserves an empty, paused application stream at 100 percent volume.