pub struct Status(/* private fields */);
Expand description
Read PCM status directly from memory, bypassing alsa-lib.
This means that it’s
- less overhead for reading status (no syscall, no allocations, no virtual dispatch, just a read from memory)
- Send + Sync, and
- will only work for “hw” / “plughw” devices (not e g PulseAudio plugins), and not all of those are supported, although all common ones are (as of 2017, and a kernel from the same decade). Kernel supported archs are: x86, PowerPC, Alpha. Use “SyncPtrStatus” for other archs.
The values are updated every now and then by the kernel. Many functions will force an update to happen,
e g PCM::avail()
and PCM::delay()
.
Note: Even if you close the original PCM device, ALSA will not actually close the device until all Status structs are dropped too.
Implementations§
source§impl Status
impl Status
pub fn new(p: &PCM) -> Result<Self>
pub fn from_fd(fd: RawFd) -> Result<Self>
sourcepub fn hw_ptr(&self) -> Frames
pub fn hw_ptr(&self) -> Frames
Number of frames hardware has read or written
This number is updated every now and then by the kernel. Calling most functions on the PCM will update it, so will usually a period interrupt. No guarantees given.
This value wraps at “boundary” (a large value you can read from SwParams).
sourcepub fn htstamp(&self) -> timespec
pub fn htstamp(&self) -> timespec
Timestamp - fast version of alsa-lib’s Status::get_htstamp
Note: This just reads the actual value in memory. Unfortunately, the timespec is too big to be read atomically on most archs. Therefore, this function can potentially give bogus result at times, at least in theory…?
sourcepub fn audio_htstamp(&self) -> timespec
pub fn audio_htstamp(&self) -> timespec
Audio timestamp - fast version of alsa-lib’s Status::get_audio_htstamp
Note: This just reads the actual value in memory. Unfortunately, the timespec is too big to be read atomically on most archs. Therefore, this function can potentially give bogus result at times, at least in theory…?