pub trait AudioBackend: Sized {
type Config;
type StartStreamError: Error;
type StreamError: Error;
// Required methods
fn start_stream(
config: Self::Config,
) -> Result<(Self, StreamInfo), Self::StartStreamError>;
fn set_processor(&mut self, processor: FirewheelProcessor);
fn poll_status(&mut self) -> Result<(), Self::StreamError>;
// Provided methods
fn available_input_devices() -> Vec<DeviceInfo> { ... }
fn available_output_devices() -> Vec<DeviceInfo> { ... }
}Expand description
A trait describing an audio backend.
When an instance is dropped, then it must automatically stop its corresponding audio stream.
Required Associated Types§
Sourcetype StartStreamError: Error
type StartStreamError: Error
An error when starting a new audio stream.
Sourcetype StreamError: Error
type StreamError: Error
An error that has caused the audio stream to stop.
Required Methods§
Sourcefn start_stream(
config: Self::Config,
) -> Result<(Self, StreamInfo), Self::StartStreamError>
fn start_stream( config: Self::Config, ) -> Result<(Self, StreamInfo), Self::StartStreamError>
Start the audio stream with the given configuration, and return a handle for the audio stream.
Sourcefn set_processor(&mut self, processor: FirewheelProcessor)
fn set_processor(&mut self, processor: FirewheelProcessor)
Send the given processor to the audio thread for processing.
This is called once after a successful call to start_stream.
Sourcefn poll_status(&mut self) -> Result<(), Self::StreamError>
fn poll_status(&mut self) -> Result<(), Self::StreamError>
Poll the status of the running audio stream. Return an error if the audio stream has stopped for any reason.
Provided Methods§
Sourcefn available_input_devices() -> Vec<DeviceInfo>
fn available_input_devices() -> Vec<DeviceInfo>
Return a list of the available input devices.
Sourcefn available_output_devices() -> Vec<DeviceInfo>
fn available_output_devices() -> Vec<DeviceInfo>
Return a list of the available output devices.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.