Trait AudioDevice

Source
pub trait AudioDevice {
    type Error: Error;

    // Required methods
    fn name(&self) -> Cow<'_, str>;
    fn device_type(&self) -> DeviceType;
    fn channel_map(&self) -> impl IntoIterator<Item = Channel<'_>>;
    fn is_config_supported(&self, config: &StreamConfig) -> bool;
    fn enumerate_configurations(
        &self,
    ) -> Option<impl IntoIterator<Item = StreamConfig>>;
}
Expand description

Trait for types describing audio devices. Audio devices have zero or more inputs and outputs, and depending on the driver, can be duplex devices which can provide both of them at the same time natively.

Required Associated Types§

Source

type Error: Error

Type of errors that can happen when using this device.

Required Methods§

Source

fn name(&self) -> Cow<'_, str>

Device display name

Source

fn device_type(&self) -> DeviceType

Device type. Either input, output, or duplex.

Source

fn channel_map(&self) -> impl IntoIterator<Item = Channel<'_>>

Iterator of the available channels in this device. Channel indices are used when specifying which channels to open when creating an audio stream.

Source

fn is_config_supported(&self, config: &StreamConfig) -> bool

Not all configuration values make sense for a particular device, and this method tests a configuration to see if it can be used in an audio stream.

Source

fn enumerate_configurations( &self, ) -> Option<impl IntoIterator<Item = StreamConfig>>

Enumerate all possible configurations this device supports. If that is not provided by the device, and not easily generated manually, this will return None.

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.

Implementors§