Struct audio_device::alsa::Pcm [−][src]
alsa
only.An opened PCM device.
Implementations
impl Pcm
[src]
pub fn open(name: &CStr, stream: Stream) -> Result<Self>
[src]
Open the given pcm device identified by name.
Examples
use audio_device::alsa; use std::ffi::CStr; let name = CStr::from_bytes_with_nul(b"hw:0\0")?; let pcm = alsa::Pcm::open(name, alsa::Stream::Playback)?;
pub fn open_default(stream: Stream) -> Result<Self>
[src]
Open the default pcm device.
Examples
use audio_device::alsa; use std::ffi::CStr; let pcm = alsa::Pcm::open_default(alsa::Stream::Playback)?;
pub fn open_nonblocking(name: &CStr, stream: Stream) -> Result<Self>
[src]
Open the given pcm device identified by name in a nonblocking manner.
Examples
use audio_device::alsa; use std::ffi::CStr; let name = CStr::from_bytes_with_nul(b"hw:0\0")?; let pcm = alsa::Pcm::open_nonblocking(name, alsa::Stream::Playback)?;
pub fn open_default_nonblocking(stream: Stream) -> Result<Self>
[src]
Open the default pcm device in a nonblocking mode.
Examples
use audio_device::alsa; use std::ffi::CStr; let pcm = alsa::Pcm::open_default_nonblocking(alsa::Stream::Playback)?;
pub fn state(&self) -> State
[src]
Get the state of the PCM.
Examples
use audio_device::alsa; let pcm = alsa::Pcm::open_default(alsa::Stream::Playback)?; dbg!(pcm.state());
pub fn configure<T>(&mut self) -> Configurator<'_, T> where
T: Sample,
[src]
T: Sample,
Construct a simple stream Configurator.
It will be initialized with a set of default parameters which are
usually suitable for simple playback or recording for the given sample
type T
.
See Configurator.
Examples
use audio_device::alsa; let mut pcm = alsa::Pcm::open_default(alsa::Stream::Playback)?; let config = pcm.configure::<i16>().install()?;
pub fn start(&mut self) -> Result<()>
[src]
Start a PCM.
Examples
use audio_device::alsa; let mut pcm = alsa::Pcm::open_default(alsa::Stream::Playback)?; pcm.start()?;
pub fn pause(&mut self) -> Result<()>
[src]
Pause a PCM.
Examples
use audio_device::alsa; let mut pcm = alsa::Pcm::open_default(alsa::Stream::Playback)?; pcm.pause()?;
pub fn resume(&mut self) -> Result<()>
[src]
Resume a PCM.
Examples
use audio_device::alsa; let mut pcm = alsa::Pcm::open_default(alsa::Stream::Playback)?; pcm.resume()?;
pub fn hardware_parameters_any(&mut self) -> Result<HardwareParametersMut<'_>>
[src]
Open all available hardware parameters for the current handle.
Examples
use audio_device::alsa; let mut pcm = alsa::Pcm::open_default(alsa::Stream::Playback)?; let mut hw = pcm.hardware_parameters_any()?; hw.set_rate_last()?; hw.install()?;
pub fn hardware_parameters_mut(&mut self) -> Result<HardwareParametersMut<'_>>
[src]
Open current hardware parameters for the current handle for mutable access.
Examples
use audio_device::alsa; let mut pcm = alsa::Pcm::open_default(alsa::Stream::Playback)?; let mut hw = pcm.hardware_parameters_mut()?; let actual_rate = hw.set_rate(44100, alsa::Direction::Nearest)?; hw.install()?; dbg!(actual_rate);
pub fn hardware_parameters(&mut self) -> Result<HardwareParameters>
[src]
Open current hardware parameters for the current handle.
Examples
use audio_device::alsa; let mut pcm = alsa::Pcm::open_default(alsa::Stream::Playback)?; let sw = pcm.hardware_parameters()?; dbg!(sw.rate()?);
pub fn software_parameters(&mut self) -> Result<SoftwareParameters>
[src]
Open current software parameters for the current handle.
Examples
use audio_device::alsa; let mut pcm = alsa::Pcm::open_default(alsa::Stream::Playback)?; let sw = pcm.software_parameters()?; dbg!(sw.boundary()?);
pub fn software_parameters_mut(&mut self) -> Result<SoftwareParametersMut<'_>>
[src]
Open current software parameters for the current handle for mutable access.
Examples
use audio_device::alsa; let mut pcm = alsa::Pcm::open_default(alsa::Stream::Playback)?; let mut sw = pcm.software_parameters_mut()?; sw.set_timestamp_mode(alsa::Timestamp::Enable)?; sw.install()?;
pub fn poll_descriptors_count(&mut self) -> usize
[src]
Get count of poll descriptors for PCM handle.
Examples
use audio_device::alsa; let mut pcm = alsa::Pcm::open_default(alsa::Stream::Playback)?; let count = pcm.poll_descriptors_count(); dbg!(count);
pub fn poll_descriptors_vec(&mut self, fds: &mut Vec<pollfd>) -> Result<()>
[src]
Get poll descriptors.
This function fills the given poll descriptor structs for the specified PCM handle. The poll desctiptor array should have the size returned by poll_descriptors_count() function.
The result is intended for direct use with the poll()
syscall.
For reading the returned events of poll descriptor after poll()
system
call, use ::snd_pcm_poll_descriptors_revents() function. The field
values in pollfd structs may be bogus regarding the stream direction
from the application perspective (POLLIN
might not imply read
direction and POLLOUT
might not imply write), but the
poll_descriptors_revents() function
does the right “demangling”.
You can use output from this function as arguments for the select()
syscall, too. Do not forget to translate POLLIN
and POLLOUT
events
to corresponding FD_SET
arrays and demangle events using
poll_descriptors_revents().
Examples
use audio_device::alsa; let mut pcm = alsa::Pcm::open_default(alsa::Stream::Playback)?; let mut fds = Vec::with_capacity(pcm.poll_descriptors_count()); pcm.poll_descriptors_vec(&mut fds)?;
pub fn poll_descriptors_revents(
&mut self,
fds: &mut [pollfd]
) -> Result<PollFlags>
[src]
&mut self,
fds: &mut [pollfd]
) -> Result<PollFlags>
Get returned events from poll descriptors.
This function does “demangling” of the revents mask returned from the
poll()
syscall to correct semantics (PollFlags::POLLIN = read,
PollFlags::POLLOUT = write).
Note: The null event also exists. Even if poll()
or select()
syscall
returned that some events are waiting, this function might return empty
set of events. In this case, application should do next event waiting
using poll()
or select()
.
Note: Even if multiple poll descriptors are used (i.e. fds.len() > 1
),
this function returns only a single event.
pub unsafe fn write_interleaved_unchecked(
&mut self,
buf: *const c_void,
len: c_ulong
) -> Result<c_long>
[src]
&mut self,
buf: *const c_void,
len: c_ulong
) -> Result<c_long>
Write unchecked interleaved frames to a PCM.
Note: that the len
must be the number of frames in the buf
which
does not account for the number of channels. So if len
is 100, and
the number of configured channels is 2, the buf
must contain at
least 200 bytes.
pub fn writer<T>(&mut self) -> Result<Writer<'_, T>> where
T: Sample,
[src]
T: Sample,
Construct a checked safe writer with the given number of channels and the specified sample type.
This will error if the type T
is not appropriate for this device, or
if the number of channels does not match the number of configured
channels.
Examples
use audio_device::alsa; let mut pcm = alsa::Pcm::open_default(alsa::Stream::Playback)?; let config = pcm.configure::<i16>().install()?; let mut writer = pcm.writer::<i16>()?; // use writer with the resulting config.
pub fn async_writer<T>(&mut self) -> Result<AsyncWriter<'_, T>> where
T: Sample,
[src]
T: Sample,
poll-driver
only.Construct a checked safe writer with the given number of channels and the specified sample type.
This will error if the type T
is not appropriate for this device, or
if the number of channels does not match the number of configured
channels.
Panics
Panics if the audio runtime is not available.
See Runtime for more.
Examples
use audio_device::alsa; let mut pcm = alsa::Pcm::open_default(alsa::Stream::Playback)?; let config = pcm.configure::<i16>().install()?; let mut writer = pcm.writer::<i16>()?; // use writer with the resulting config.
pub fn available_update(&mut self) -> Result<usize>
[src]
Return number of frames ready to be read (capture) / written (playback).
Examples
use audio_device::alsa; let mut pcm = alsa::Pcm::open_default(alsa::Stream::Playback)?; let avail = pcm.available_update()?; dbg!(avail);
Trait Implementations
Auto Trait Implementations
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,