Skip to main content

AudioHardwareInterface

Trait AudioHardwareInterface 

Source
pub trait AudioHardwareInterface {
    // Required methods
    fn new(params: HardwareParameters) -> Result<Self, String>
       where Self: Sized;
    fn get_period_size(&self) -> usize;
    fn play(&self, wpf: impl WritePlayFunction) -> Result<usize, AudioPlayError>;
    fn pause(&self);

    // Provided methods
    fn get_underrun_count(&self) -> usize { ... }
    fn wait_for_playback_space(&self) { ... }
}
Expand description

The AudioHardwareInterface trait provides a platform-independent playback boundary.

Required Methods§

Source

fn new(params: HardwareParameters) -> Result<Self, String>
where Self: Sized,

Source

fn get_period_size(&self) -> usize

Source

fn play(&self, wpf: impl WritePlayFunction) -> Result<usize, AudioPlayError>

Writes audio data to a hardware buffer and submits it for playback.

Returns the number of submitted frames.

Source

fn pause(&self)

Notifies the hardware that playback has been paused. This may be used to improve performance by reducing CPU usage.

Provided Methods§

Source

fn get_underrun_count(&self) -> usize

Returns the number of hardware callback cycles that encountered at least one buffer underrun.

Backends that cannot provide this metric should return 0.

Source

fn wait_for_playback_space(&self)

Waits until playback can accept more data without dropping or busy spinning.

Backends that cannot provide a direct wait mechanism should yield briefly.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§