Struct alsa::direct::pcm::Status

source ·
pub struct Status(/* private fields */);
Expand description

Read PCM status directly from memory, bypassing alsa-lib.

This means that it’s

  1. less overhead for reading status (no syscall, no allocations, no virtual dispatch, just a read from memory)
  2. Send + Sync, and
  3. 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

source

pub fn new(p: &PCM) -> Result<Self>

source

pub fn from_fd(fd: RawFd) -> Result<Self>

source

pub fn state(&self) -> State

Current PCM state.

source

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).

source

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…?

source

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…?

Trait Implementations§

source§

impl Debug for Status

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.