Skip to main content

AudioSystem

Struct AudioSystem 

Source
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>

Source

pub fn new() -> Result<Self>

Creates empty, paused 48 kHz stereo F32 streams without allocation. Invalid const capacities return InvalidArgument.

Source

pub fn set_master_volume(&self, volume: u8) -> Result<()>

Sets the master gain, from 0 to 100 percent.

Source

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.

Source

pub fn open_output(self: Pin<&Self>) -> Result<OutputHandle<'_, S, B, F, O, Q>>

Reserves a sink and resets its queue and drop counter.

Source

pub fn open_stream(&self) -> Result<StreamHandle<'_, S, B, F, O, Q>>

Reserves an empty, paused application stream at 100 percent volume.

Auto Trait Implementations§

§

impl<const STREAMS: usize = 4, const STREAM_BYTES: usize = 2048, const MIX_FRAMES: usize = 128, const OUTPUTS: usize = 2, const SINK_BYTES: usize = 3072> !Freeze for AudioSystem<STREAMS, STREAM_BYTES, MIX_FRAMES, OUTPUTS, SINK_BYTES>

§

impl<const STREAMS: usize = 4, const STREAM_BYTES: usize = 2048, const MIX_FRAMES: usize = 128, const OUTPUTS: usize = 2, const SINK_BYTES: usize = 3072> !RefUnwindSafe for AudioSystem<STREAMS, STREAM_BYTES, MIX_FRAMES, OUTPUTS, SINK_BYTES>

§

impl<const STREAMS: usize, const STREAM_BYTES: usize, const MIX_FRAMES: usize, const OUTPUTS: usize, const SINK_BYTES: usize> Send for AudioSystem<STREAMS, STREAM_BYTES, MIX_FRAMES, OUTPUTS, SINK_BYTES>

§

impl<const STREAMS: usize, const STREAM_BYTES: usize, const MIX_FRAMES: usize, const OUTPUTS: usize, const SINK_BYTES: usize> Sync for AudioSystem<STREAMS, STREAM_BYTES, MIX_FRAMES, OUTPUTS, SINK_BYTES>

§

impl<const STREAMS: usize = 4, const STREAM_BYTES: usize = 2048, const MIX_FRAMES: usize = 128, const OUTPUTS: usize = 2, const SINK_BYTES: usize = 3072> !Unpin for AudioSystem<STREAMS, STREAM_BYTES, MIX_FRAMES, OUTPUTS, SINK_BYTES>

§

impl<const STREAMS: usize = 4, const STREAM_BYTES: usize = 2048, const MIX_FRAMES: usize = 128, const OUTPUTS: usize = 2, const SINK_BYTES: usize = 3072> !UnsafeUnpin for AudioSystem<STREAMS, STREAM_BYTES, MIX_FRAMES, OUTPUTS, SINK_BYTES>

§

impl<const STREAMS: usize = 4, const STREAM_BYTES: usize = 2048, const MIX_FRAMES: usize = 128, const OUTPUTS: usize = 2, const SINK_BYTES: usize = 3072> !UnwindSafe for AudioSystem<STREAMS, STREAM_BYTES, MIX_FRAMES, OUTPUTS, SINK_BYTES>

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.