pub struct AlsaBackend { /* private fields */ }Expand description
ALSA host backend with provider-supplied deterministic PCM devices.
Implementations§
Source§impl AlsaBackend
impl AlsaBackend
Sourcepub fn new(devices: Vec<AlsaPcmDevice>) -> Self
pub fn new(devices: Vec<AlsaPcmDevice>) -> Self
Builds a hardware-required backend over the supplied PCM devices.
Capabilities are derived from the devices’ directions; the backend reports that real audio hardware is required.
Sourcepub fn fake() -> Self
pub fn fake() -> Self
Builds an offline backend with a deterministic set of fake PCM devices.
The backend reports that hardware is not required and carries the
Offline and Fake capabilities, so it can drive validation without an
ALSA development package or sound hardware. It exposes a default
playback, a default capture, a hw:0,0 playback, and a plughw:1,0
capture device.
§Examples
use sim_lib_stream_alsa::AlsaBackend;
let backend = AlsaBackend::fake();
assert_eq!(backend.list_devices().len(), 4);
assert!(backend.default_playback().is_some());
assert!(backend.default_capture().is_some());Sourcepub fn list_devices(&self) -> &[AlsaPcmDevice]
pub fn list_devices(&self) -> &[AlsaPcmDevice]
Returns the backend’s PCM devices in registration order.
Sourcepub fn default_playback(&self) -> Option<&AlsaPcmDevice>
pub fn default_playback(&self) -> Option<&AlsaPcmDevice>
Returns the first default device that can serve output, if any.
Sourcepub fn default_capture(&self) -> Option<&AlsaPcmDevice>
pub fn default_capture(&self) -> Option<&AlsaPcmDevice>
Returns the first default device that can serve input, if any.
Sourcepub fn open_default_playback(&self, capacity: usize) -> Result<HostOpenStream>
pub fn open_default_playback(&self, capacity: usize) -> Result<HostOpenStream>
Opens an output stream on the default playback device.
Errors when no default playback device is present, or when the open
request cannot be satisfied. capacity bounds the stream buffer.
Sourcepub fn open_default_capture(&self, capacity: usize) -> Result<HostOpenStream>
pub fn open_default_capture(&self, capacity: usize) -> Result<HostOpenStream>
Opens an input stream on the default capture device.
Errors when no default capture device is present, or when the open
request cannot be satisfied. capacity bounds the stream buffer.
Trait Implementations§
Source§impl Clone for AlsaBackend
impl Clone for AlsaBackend
Source§fn clone(&self) -> AlsaBackend
fn clone(&self) -> AlsaBackend
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more