[][src]Trait cpal::traits::DeviceTrait

pub trait DeviceTrait {
    type SupportedInputConfigs: Iterator<Item = SupportedStreamConfigRange>;
    type SupportedOutputConfigs: Iterator<Item = SupportedStreamConfigRange>;
    type Stream: StreamTrait;
    fn name(&self) -> Result<String, DeviceNameError>;
fn supported_input_configs(
        &self
    ) -> Result<Self::SupportedInputConfigs, SupportedStreamConfigsError>;
fn supported_output_configs(
        &self
    ) -> Result<Self::SupportedOutputConfigs, SupportedStreamConfigsError>;
fn default_input_config(
        &self
    ) -> Result<SupportedStreamConfig, DefaultStreamConfigError>;
fn default_output_config(
        &self
    ) -> Result<SupportedStreamConfig, DefaultStreamConfigError>;
fn build_input_stream_raw<D, E>(
        &self,
        config: &StreamConfig,
        sample_format: SampleFormat,
        data_callback: D,
        error_callback: E
    ) -> Result<Self::Stream, BuildStreamError>
    where
        D: FnMut(&Data, &InputCallbackInfo) + Send + 'static,
        E: FnMut(StreamError) + Send + 'static
;
fn build_output_stream_raw<D, E>(
        &self,
        config: &StreamConfig,
        sample_format: SampleFormat,
        data_callback: D,
        error_callback: E
    ) -> Result<Self::Stream, BuildStreamError>
    where
        D: FnMut(&mut Data, &OutputCallbackInfo) + Send + 'static,
        E: FnMut(StreamError) + Send + 'static
; fn build_input_stream<T, D, E>(
        &self,
        config: &StreamConfig,
        data_callback: D,
        error_callback: E
    ) -> Result<Self::Stream, BuildStreamError>
    where
        T: Sample,
        D: FnMut(&[T], &InputCallbackInfo) + Send + 'static,
        E: FnMut(StreamError) + Send + 'static
, { ... }
fn build_output_stream<T, D, E>(
        &self,
        config: &StreamConfig,
        data_callback: D,
        error_callback: E
    ) -> Result<Self::Stream, BuildStreamError>
    where
        T: Sample,
        D: FnMut(&mut [T], &OutputCallbackInfo) + Send + 'static,
        E: FnMut(StreamError) + Send + 'static
, { ... } }

A device that is capable of audio input and/or output.

Please note that Devices may become invalid if they get disconnected. Therefore all the methods that involve a device return a Result allowing the user to handle this case.

Associated Types

type SupportedInputConfigs: Iterator<Item = SupportedStreamConfigRange>

The iterator type yielding supported input stream formats.

type SupportedOutputConfigs: Iterator<Item = SupportedStreamConfigRange>

The iterator type yielding supported output stream formats.

type Stream: StreamTrait

The stream type created by build_input_stream_raw and build_output_stream_raw.

Loading content...

Required methods

fn name(&self) -> Result<String, DeviceNameError>

The human-readable name of the device.

fn supported_input_configs(
    &self
) -> Result<Self::SupportedInputConfigs, SupportedStreamConfigsError>

An iterator yielding formats that are supported by the backend.

Can return an error if the device is no longer valid (eg. it has been disconnected).

fn supported_output_configs(
    &self
) -> Result<Self::SupportedOutputConfigs, SupportedStreamConfigsError>

An iterator yielding output stream formats that are supported by the device.

Can return an error if the device is no longer valid (eg. it has been disconnected).

fn default_input_config(
    &self
) -> Result<SupportedStreamConfig, DefaultStreamConfigError>

The default input stream format for the device.

fn default_output_config(
    &self
) -> Result<SupportedStreamConfig, DefaultStreamConfigError>

The default output stream format for the device.

fn build_input_stream_raw<D, E>(
    &self,
    config: &StreamConfig,
    sample_format: SampleFormat,
    data_callback: D,
    error_callback: E
) -> Result<Self::Stream, BuildStreamError> where
    D: FnMut(&Data, &InputCallbackInfo) + Send + 'static,
    E: FnMut(StreamError) + Send + 'static, 

Create a dynamically typed input stream.

fn build_output_stream_raw<D, E>(
    &self,
    config: &StreamConfig,
    sample_format: SampleFormat,
    data_callback: D,
    error_callback: E
) -> Result<Self::Stream, BuildStreamError> where
    D: FnMut(&mut Data, &OutputCallbackInfo) + Send + 'static,
    E: FnMut(StreamError) + Send + 'static, 

Create a dynamically typed output stream.

Loading content...

Provided methods

fn build_input_stream<T, D, E>(
    &self,
    config: &StreamConfig,
    data_callback: D,
    error_callback: E
) -> Result<Self::Stream, BuildStreamError> where
    T: Sample,
    D: FnMut(&[T], &InputCallbackInfo) + Send + 'static,
    E: FnMut(StreamError) + Send + 'static, 

Create an input stream.

fn build_output_stream<T, D, E>(
    &self,
    config: &StreamConfig,
    data_callback: D,
    error_callback: E
) -> Result<Self::Stream, BuildStreamError> where
    T: Sample,
    D: FnMut(&mut [T], &OutputCallbackInfo) + Send + 'static,
    E: FnMut(StreamError) + Send + 'static, 

Create an output stream.

Loading content...

Implementors

impl DeviceTrait for cpal::platform::AlsaDevice[src]

type SupportedInputConfigs = SupportedInputConfigs

type SupportedOutputConfigs = SupportedOutputConfigs

type Stream = Stream

impl DeviceTrait for cpal::Device[src]

type SupportedInputConfigs = SupportedInputConfigs

type SupportedOutputConfigs = SupportedOutputConfigs

type Stream = Stream

Loading content...