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§
fn new(params: HardwareParameters) -> Result<Self, String>where
Self: Sized,
fn get_period_size(&self) -> usize
Sourcefn play(&self, wpf: impl WritePlayFunction) -> Result<usize, AudioPlayError>
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.
Provided Methods§
Sourcefn get_underrun_count(&self) -> usize
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.
Sourcefn wait_for_playback_space(&self)
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".