Struct alsa::direct::pcm::MmapIO

source ·
pub struct MmapIO<S, D> { /* private fields */ }
Expand description

Struct containing direct I/O functions shared between playback and capture.

Implementations§

source§

impl<S, D: MmapDir> MmapIO<S, D>

source

pub fn status(&self) -> &Status

Read current status

source

pub fn appl_ptr(&self) -> Frames

Read current number of frames committed by application

This number wraps at ‘boundary’.

source

pub fn hw_ptr(&self) -> Frames

Read current number of frames read / written by hardware

This number wraps at ‘boundary’.

source

pub fn boundary(&self) -> Frames

The number at which hw_ptr and appl_ptr wraps.

source

pub fn buffer_size(&self) -> Frames

Total number of frames in hardware buffer

source

pub fn channels(&self) -> u32

Number of channels in stream

source

pub fn commit(&self, v: Frames)

Notifies the kernel that frames have now been read / written by the application

This will allow the kernel to write new data into this part of the buffer.

source

pub fn avail(&self) -> Frames

Number of frames available to read / write.

In case of an underrun, this value might be bigger than the buffer size.

source

pub fn data_ptr(&self) -> (RawSamples<S>, Option<RawSamples<S>>)

Returns raw pointers to data to read / write.

Use this if you want to read/write data yourself (instead of using iterators). If you do, using write_volatile or read_volatile is recommended, since it’s DMA memory and can change at any time.

Since this is a ring buffer, there might be more data to read/write in the beginning of the buffer as well. If so this is returned as the second return value.

source§

impl<S> MmapIO<S, Playback>

source

pub fn write<I: Iterator<Item = S>>(&mut self, i: &mut I) -> Frames

Write samples to the kernel ringbuffer.

source§

impl<S> MmapIO<S, Capture>

source

pub fn iter(&mut self) -> CaptureIter<'_, S>

Read samples from the kernel ringbuffer.

When the iterator is dropped or depleted, the read samples will be committed, i e, the kernel can then write data to the location again. So do this ASAP.

Trait Implementations§

source§

impl<S: Debug, D: Debug> Debug for MmapIO<S, D>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<S, D> RefUnwindSafe for MmapIO<S, D>

§

impl<S, D> !Send for MmapIO<S, D>

§

impl<S, D> !Sync for MmapIO<S, D>

§

impl<S, D> Unpin for MmapIO<S, D>

§

impl<S, D> UnwindSafe for MmapIO<S, D>

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.