pub struct AlsaPcmDevice { /* private fields */ }Expand description
SIM-visible ALSA PCM device metadata.
Implementations§
Source§impl AlsaPcmDevice
impl AlsaPcmDevice
Sourcepub fn playback(
pcm_name: impl Into<String>,
display_name: impl Into<String>,
channels: usize,
sample_rate_hz: u32,
) -> Result<Self>
pub fn playback( pcm_name: impl Into<String>, display_name: impl Into<String>, channels: usize, sample_rate_hz: u32, ) -> Result<Self>
Builds an output (playback) PCM device with the F32 sample format.
§Examples
use sim_lib_stream_alsa::AlsaPcmDevice;
let device = AlsaPcmDevice::playback("hw:0,0", "Card 0", 2, 48_000).unwrap();
assert_eq!(device.channels(), 2);
assert_eq!(device.sample_rate_hz(), 48_000);
assert!(!device.is_default());Sourcepub fn capture(
pcm_name: impl Into<String>,
display_name: impl Into<String>,
channels: usize,
sample_rate_hz: u32,
) -> Result<Self>
pub fn capture( pcm_name: impl Into<String>, display_name: impl Into<String>, channels: usize, sample_rate_hz: u32, ) -> Result<Self>
Builds an input (capture) PCM device with the F32 sample format.
Sourcepub fn default_playback(channels: usize, sample_rate_hz: u32) -> Result<Self>
pub fn default_playback(channels: usize, sample_rate_hz: u32) -> Result<Self>
Builds the routed default PCM device for playback.
Sourcepub fn default_capture(channels: usize, sample_rate_hz: u32) -> Result<Self>
pub fn default_capture(channels: usize, sample_rate_hz: u32) -> Result<Self>
Builds the routed default PCM device for capture.
Sourcepub fn new(
pcm_name: AlsaPcmName,
display_name: impl Into<String>,
direction: HostDirection,
channels: usize,
sample_rate_hz: u32,
sample_format: PcmSampleFormat,
) -> Result<Self>
pub fn new( pcm_name: AlsaPcmName, display_name: impl Into<String>, direction: HostDirection, channels: usize, sample_rate_hz: u32, sample_format: PcmSampleFormat, ) -> Result<Self>
Builds a PCM device from explicit parts, defaulting the buffer to 256 frames.
Returns an Error::Eval when channels or sample_rate_hz is zero.
The device Symbol id is derived from the name and direction.
Sourcepub fn with_buffer_frames(self, buffer_frames: usize) -> Result<Self>
pub fn with_buffer_frames(self, buffer_frames: usize) -> Result<Self>
Returns a copy of this device with the buffer size set to
buffer_frames, which must be greater than zero.
Sourcepub fn pcm_name(&self) -> &AlsaPcmName
pub fn pcm_name(&self) -> &AlsaPcmName
Returns the parsed ALSA PCM name.
Sourcepub fn display_name(&self) -> &str
pub fn display_name(&self) -> &str
Returns the human-readable display name.
Sourcepub fn direction(&self) -> HostDirection
pub fn direction(&self) -> HostDirection
Returns the device direction (input, output, or duplex).
Sourcepub fn sample_rate_hz(&self) -> u32
pub fn sample_rate_hz(&self) -> u32
Returns the sample rate in hertz.
Sourcepub fn sample_format(&self) -> PcmSampleFormat
pub fn sample_format(&self) -> PcmSampleFormat
Returns the PCM sample format.
Sourcepub fn buffer_frames(&self) -> usize
pub fn buffer_frames(&self) -> usize
Returns the configured buffer size in frames.
Sourcepub fn spec(&self) -> Result<PcmSpec>
pub fn spec(&self) -> Result<PcmSpec>
Builds the PCM spec (channels, rate, format) for this device.
Sourcepub fn is_default(&self) -> bool
pub fn is_default(&self) -> bool
Returns true when this device wraps the ALSA default PCM.
Sourcepub fn is_compatible_with(&self, requested: HostDirection) -> bool
pub fn is_compatible_with(&self, requested: HostDirection) -> bool
Returns true when the device can serve the requested direction.
A duplex device satisfies any requested direction.
Sourcepub fn port_symbol(&self) -> Symbol
pub fn port_symbol(&self) -> Symbol
Returns the device’s port symbol, the device id with a /port suffix.
Trait Implementations§
Source§impl Clone for AlsaPcmDevice
impl Clone for AlsaPcmDevice
Source§fn clone(&self) -> AlsaPcmDevice
fn clone(&self) -> AlsaPcmDevice
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AlsaPcmDevice
impl Debug for AlsaPcmDevice
impl Eq for AlsaPcmDevice
Source§impl PartialEq for AlsaPcmDevice
impl PartialEq for AlsaPcmDevice
Source§fn eq(&self, other: &AlsaPcmDevice) -> bool
fn eq(&self, other: &AlsaPcmDevice) -> bool
self and other values to be equal, and is used by ==.