pub struct AudioOutput { /* private fields */ }Expand description
An opened output device that may accept exactly one application source.
Opening immediately starts a silent backend stream. Keep this guard, or the
AudioPlayback returned from it, outside World preparation and renderer
ownership. Dropping the guard closes output. No application/window/GPU is
required, but the optional audio feature and a working device are required.
Implementations§
Source§impl AudioOutput
impl AudioOutput
Sourcepub fn open(config: AudioOutputConfig) -> Result<Self, AudioOutputError>
pub fn open(config: AudioOutputConfig) -> Result<Self, AudioOutputError>
Opens the default device with explicit buffer policy and atomic diagnostics.
Failure returns an error, never an implicitly successful silent backend. Applications may choose and display their own silent-mode fallback. Backend setup can allocate; this API does not claim recovery from every backend allocation failure. No automatic device recovery is installed.
Sourcepub const fn info(&self) -> AudioOutputInfo
pub const fn info(&self) -> AudioOutputInfo
Returns the opened output format and requested/default buffer policy.
Sourcepub fn status(&self) -> AudioOutputStatus
pub fn status(&self) -> AudioOutputStatus
Returns independently shareable diagnostics without sharing device ownership.
Sourcepub fn play_mono(
self,
source: impl Iterator<Item = f32> + Send + 'static,
) -> AudioPlayback
pub fn play_mono( self, source: impl Iterator<Item = f32> + Send + 'static, ) -> AudioPlayback
Transfers one mono PCM iterator to the output and returns its lifetime guard.
Construct the source for AudioOutputInfo::sample_rate; output uses that
same rate without resampling. Rodio duplicates mono into stereo; output
channels beyond the first two receive silence.
Each sample is sanitized to finite -1.0 through 1.0 PCM before conversion.
The source executes on the audio thread: it must return promptly, avoid
blocking, allocation, file/device calls and panics, and bound its own work.
None ends the source permanently. Interactive stopped/paused sources must keep yielding zero if they need to resume. Controls and musical timing belong to the application; no pause, time-scale or World policy is implied. This consumes the output, so callers cannot enqueue unbounded sources. Backend attachment may allocate; it is setup, not a real-time operation.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for AudioOutput
impl !UnwindSafe for AudioOutput
impl Freeze for AudioOutput
impl Send for AudioOutput
impl Sync for AudioOutput
impl Unpin for AudioOutput
impl UnsafeUnpin for AudioOutput
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ConditionalSend for Twhere
T: Send,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.