[][src]Trait cpal::traits::HostTrait

pub trait HostTrait {
    type Devices: Iterator<Item = Self::Device>;
    type Device: DeviceTrait;
    type EventLoop: EventLoopTrait<Device = Self::Device>;
    fn is_available() -> bool;
fn devices(&self) -> Result<Self::Devices, DevicesError>;
fn default_input_device(&self) -> Option<Self::Device>;
fn default_output_device(&self) -> Option<Self::Device>;
fn event_loop(&self) -> Self::EventLoop; fn input_devices(&self) -> Result<InputDevices<Self::Devices>, DevicesError> { ... }
fn output_devices(
        &self
    ) -> Result<OutputDevices<Self::Devices>, DevicesError> { ... } }

A Host provides access to the available audio devices on the system.

Each platform may have a number of available hosts depending on the system, each with their own pros and cons.

For example, WASAPI is the standard audio host API that ships with the Windows operating system. However, due to historical limitations with respect to performance and flexibility, Steinberg created the ASIO API providing better audio device support for pro audio and low-latency applications. As a result, it is common for some devices and device capabilities to only be available via ASIO, while others are only available via WASAPI.

Another great example is the Linux platform. While the ALSA host API is the lowest-level API available to almost all distributions of Linux, its flexibility is limited as it requires that each process have exclusive access to the devices with which they establish streams. PulseAudio is another popular host API that aims to solve this issue by providing user-space mixing, however it has its own limitations w.r.t. low-latency and high-performance audio applications. JACK is yet another host API that is more suitable to pro-audio applications, however it is less readily available by default in many Linux distributions and is known to be tricky to setup.

Associated Types

type Devices: Iterator<Item = Self::Device>

The type used for enumerating available devices by the host.

type Device: DeviceTrait

The Device type yielded by the host.

type EventLoop: EventLoopTrait<Device = Self::Device>

The event loop type used by the Host

Loading content...

Required methods

fn is_available() -> bool

Whether or not the host is available on the system.

fn devices(&self) -> Result<Self::Devices, DevicesError>

An iterator yielding all Devices currently available to the host on the system.

Can be empty if the system does not support audio in general.

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

The default input audio device on the system.

Returns None if no input device is available.

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

The default output audio device on the system.

Returns None if no output device is available.

fn event_loop(&self) -> Self::EventLoop

Initialise the event loop, ready for managing audio streams.

Loading content...

Provided methods

fn input_devices(&self) -> Result<InputDevices<Self::Devices>, DevicesError>

An iterator yielding all Devices currently available to the system that support one or more input stream formats.

Can be empty if the system does not support audio input.

fn output_devices(&self) -> Result<OutputDevices<Self::Devices>, DevicesError>

An iterator yielding all Devices currently available to the system that support one or more output stream formats.

Can be empty if the system does not support audio output.

Loading content...

Implementors

impl HostTrait for cpal::platform::AlsaHost[src]

impl HostTrait for cpal::Host[src]

Loading content...