Skip to main content

AudioOutputBackend

Struct AudioOutputBackend 

Source
pub struct AudioOutputBackend { /* private fields */ }
Expand description

Production stereo f32 PCM audio mixer draining AudioBus with native macOS CoreAudio AUHAL output and deterministic pull mode.

Implementations§

Source§

impl AudioOutputBackend

Production AudioBus ingestion, stereo PCM ring-buffer mixing, and native CoreAudio AUHAL startup for AudioOutputBackend.

Source

pub fn new_pull_mixer(config: AudioOutputConfig) -> Self

Creates a deterministic cross-platform pull-mode stereo PCM mixer backend.

§Arguments
  • AudioOutputConfig - Requested audio sample rate, ring size, polyphony, and master gain.
§Returns
  • Self - Running pull-mode stereo PCM mixer.
Source

pub fn start_native(config: AudioOutputConfig) -> Result<Self, AudioOutputError>

Initializes and starts a real native OS hardware audio driver (CoreAudio AUHAL on macOS).

§Arguments
  • AudioOutputConfig - Requested stereo audio stream configuration.
§Returns
  • Result<Self, AudioOutputError> - Running native hardware audio backend or explicit error.
Source

pub fn ingest_bus(&mut self, bus: &mut AudioBus) -> usize

Drains all pending AudioCommand items from bus into active mixer voices while syncing mute state.

§Arguments
  • &mut AudioBus - Source game audio bus drained in place.
§Returns
  • usize - Number of audio commands ingested from bus.
Source

pub fn enqueue_command(&mut self, command: AudioCommand)

Enqueues a single spatialized AudioCommand directly into the mixer voice pool.

§Arguments
  • AudioCommand - Audio command specifying cue, volume, pan, and pitch.
Source

pub fn mix_into_ring(&mut self, frames: usize) -> usize

Synthesizes frames stereo PCM frames into the internal ring buffer for asynchronous playback or inspection.

§Arguments
  • usize - Number of stereo frames to mix into the ring buffer.
§Returns
  • usize - Number of stereo frames mixed.
Source

pub fn pull_interleaved_f32(&mut self, output: &mut [f32]) -> usize

Pulls interleaved stereo f32 PCM samples ([L0, R0, L1, R1, ...]) bounded strictly in [-1.0, 1.0].

§Arguments
  • &mut [f32] - Interleaved stereo destination slice.
§Returns
  • usize - Number of stereo frames written to output.
Source

pub fn set_master_gain(&mut self, gain: f32)

Updates the mixer master linear output gain (clamped to [0.0, 2.0]).

§Arguments
  • f32 - Target master linear gain.
Source

pub fn set_muted(&mut self, muted: bool)

Toggles global audio mixer muting without stopping active voice progression.

§Arguments
  • bool - true to mute output to silence, false to unmute.
Source

pub fn pause(&mut self)

Pauses output rendering without discarding queued voices or buffered frames.

Source

pub fn resume(&mut self)

Resumes a paused pull-mode mixer backend.

Source

pub fn stop(&mut self)

Stops any native OS audio driver, clears buffered PCM frames, and transitions to Stopped.

Source

pub fn metrics(&self) -> AudioOutputMetrics

Captures a live telemetry snapshot of driver status, voice count, ring fill, underruns, and peak amplitude.

§Returns
  • AudioOutputMetrics - Current audio output telemetry snapshot.
Source§

impl AudioOutputBackend

Source

pub fn get_config(&self) -> AudioOutputConfig

Source

pub fn get_mut_config(&mut self) -> &mut AudioOutputConfig

Source

pub fn set_config(&mut self, val: AudioOutputConfig) -> &mut Self

Source

pub fn get_driver_kind(&self) -> AudioDriverKind

Source

pub fn get_mut_driver_kind(&mut self) -> &mut AudioDriverKind

Source

pub fn set_driver_kind(&mut self, val: AudioDriverKind) -> &mut Self

Source

pub fn get_state(&self) -> AudioOutputState

Source

pub fn get_mut_state(&mut self) -> &mut AudioOutputState

Source

pub fn set_state(&mut self, val: AudioOutputState) -> &mut Self

Trait Implementations§

Source§

impl Debug for AudioOutputBackend

Structured Debug formatting for AudioOutputBackend.

Source§

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

Formats AudioOutputBackend driver, state, and live mixer telemetry.

§Arguments
  • &mut Formatter<'_> - Output formatter.
§Returns
  • fmt::Result - Formatting status.
Source§

impl Default for AudioOutputBackend

Default pull-mode AudioOutputBackend ready for cross-platform deterministic mixing.

Source§

fn default() -> Self

Creates a default pull-mode AudioOutputBackend.

§Returns
  • Self - Running stereo 48 kHz pull mixer.
Source§

impl Drop for AudioOutputBackend

Safe teardown stopping any active hardware driver on AudioOutputBackend drop.

Source§

fn drop(&mut self)

Ensures native OS audio handles are cleanly stopped and disposed on drop.

Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl Forget for AudioOutputBackend

§

impl Freeze for AudioOutputBackend
where *const ArcInner<Mutex<AudioMixerCore>> is !null: Freeze, PhantomData<ArcInner<Mutex<AudioMixerCore>>>: Freeze,

§

impl Move for AudioOutputBackend

§

impl RefUnwindSafe for AudioOutputBackend
where Atomic<usize>: RefUnwindSafe, Mutex<AudioMixerCore>: RefUnwindSafe,

§

impl Send for AudioOutputBackend
where Arc<Mutex<AudioMixerCore>>: Send,

§

impl Sync for AudioOutputBackend
where Arc<Mutex<AudioMixerCore>>: Sync,

§

impl Unpin for AudioOutputBackend
where Arc<Mutex<AudioMixerCore>>: Unpin,

§

impl UnsafeUnpin for AudioOutputBackend
where *const ArcInner<Mutex<AudioMixerCore>> is !null: UnsafeUnpin, PhantomData<ArcInner<Mutex<AudioMixerCore>>>: UnsafeUnpin,

§

impl UnwindSafe for AudioOutputBackend
where Arc<Mutex<AudioMixerCore>>: 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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.