Skip to main content

AudioBackend

Trait AudioBackend 

Source
pub trait AudioBackend: Send + Sync {
    type Stream: AudioStream + 'static;
    type Device: Send + Sync;
    type Error: Error + Send + Sync + 'static;

    // Required methods
    fn enumerate_output_devices(&self) -> Result<Vec<Self::Device>, Self::Error>;
    fn enumerate_input_devices(&self) -> Result<Vec<Self::Device>, Self::Error>;
    fn default_output_device(&self) -> Option<Self::Device>;
    fn default_input_device(&self) -> Option<Self::Device>;
    fn create_output_stream(
        &self,
        device: &Self::Device,
        config: AudioConfig,
        data_callback: Box<dyn FnMut(&mut [f32]) + Send>,
        error_callback: Box<dyn FnMut(Self::Error) + Send>,
    ) -> Result<Self::Stream, Self::Error>;
    fn create_input_stream(
        &self,
        device: &Self::Device,
        config: AudioConfig,
        data_callback: Box<dyn FnMut(&[f32]) + Send>,
        error_callback: Box<dyn FnMut(Self::Error) + Send>,
    ) -> Result<Self::Stream, Self::Error>;
}
Expand description

Audio backend trait for creating audio streams

Required Associated Types§

Source

type Stream: AudioStream + 'static

The stream type this backend produces. Not required to be Send — see AudioStream.

Source

type Device: Send + Sync

The device type this backend uses

Source

type Error: Error + Send + Sync + 'static

The error type this backend returns

Required Methods§

Source

fn enumerate_output_devices(&self) -> Result<Vec<Self::Device>, Self::Error>

Enumerate available output devices

Source

fn enumerate_input_devices(&self) -> Result<Vec<Self::Device>, Self::Error>

Enumerate available input devices

Source

fn default_output_device(&self) -> Option<Self::Device>

Get the default output device

Source

fn default_input_device(&self) -> Option<Self::Device>

Get the default input device

Source

fn create_output_stream( &self, device: &Self::Device, config: AudioConfig, data_callback: Box<dyn FnMut(&mut [f32]) + Send>, error_callback: Box<dyn FnMut(Self::Error) + Send>, ) -> Result<Self::Stream, Self::Error>

Create an output stream

Source

fn create_input_stream( &self, device: &Self::Device, config: AudioConfig, data_callback: Box<dyn FnMut(&[f32]) + Send>, error_callback: Box<dyn FnMut(Self::Error) + Send>, ) -> Result<Self::Stream, Self::Error>

Create an input stream

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§