Configurator

Struct Configurator 

Source
pub struct Configurator<'a, T> { /* private fields */ }
Available on crate feature alsa only.
Expand description

A simple Pcm stream configuration.

§Examples

use audio_device::alsa;

let mut pcm = alsa::Pcm::open_default(alsa::Stream::Playback)?;

let config = pcm.configure::<f32>()
    .rate(48000)
    .channels(5)
    .install()?;

dbg!(config);

Implementations§

Source§

impl<'a, T> Configurator<'a, T>
where T: Sample,

Source

pub fn access(self, access: Access) -> Self

Configure the stream access to use.

§Examples
use audio_device::alsa;

let mut pcm = alsa::Pcm::open_default(alsa::Stream::Playback)?;

let config = pcm.configure::<f32>()
    .access(alsa::Access::MmapInterleaved)
    .install()?;

dbg!(config);
Source

pub fn format(self, format: Format) -> Result<Self>

Configure the stream format to use.

This will check that the format is appropriate to use by the current sample. Inappropriate formats will be signalled with Error::FormatMismatch.

§Examples
use audio_device::alsa;

let mut pcm = alsa::Pcm::open_default(alsa::Stream::Playback)?;

let config = pcm.configure::<f32>()
    .format(alsa::Format::FloatLE)?
    .install()?;

dbg!(config);
Source

pub fn latency(self, latency: Duration) -> Self

Configure the stream latency to use.

Will never accept a latency higher than 2**32. Anything larger will be floored to it.

§Examples
use audio_device::alsa;

let mut pcm = alsa::Pcm::open_default(alsa::Stream::Playback)?;

let config = pcm.configure::<f32>()
    .latency(std::time::Duration::from_micros(500))
    .install()?;

dbg!(config);
Source

pub fn channels(self, channels: c_uint) -> Self

Configure the number of channels to use.

§Examples
use audio_device::alsa;

let mut pcm = alsa::Pcm::open_default(alsa::Stream::Playback)?;

let config = pcm.configure::<f32>()
    .channels(5)
    .install()?;

dbg!(config);
Source

pub fn rate(self, rate: c_uint) -> Self

Configure the sample rate to use.

§Examples
use audio_device::alsa;

let mut pcm = alsa::Pcm::open_default(alsa::Stream::Playback)?;

let config = pcm.configure::<f32>()
    .rate(48000)
    .install()?;

dbg!(config);
Source

pub fn install(self) -> Result<Config>

Install the current configuration and return the one which is used by the underlying PCM.

§Examples
use audio_device::alsa;

let mut pcm = alsa::Pcm::open_default(alsa::Stream::Playback)?;

let config = pcm.configure::<f32>()
    .channels(2)
    .rate(48000)
    .install()?;

dbg!(config);

Auto Trait Implementations§

§

impl<'a, T> Freeze for Configurator<'a, T>

§

impl<'a, T> RefUnwindSafe for Configurator<'a, T>
where T: RefUnwindSafe,

§

impl<'a, T> Send for Configurator<'a, T>
where T: Send,

§

impl<'a, T> !Sync for Configurator<'a, T>

§

impl<'a, T> Unpin for Configurator<'a, T>
where T: Unpin,

§

impl<'a, T> !UnwindSafe for Configurator<'a, T>

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>,

Source§

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>,

Source§

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.