Skip to main content

CpalSource

Struct CpalSource 

Source
pub struct CpalSource { /* private fields */ }
Expand description

Captures from the default input device of a cpal host (ALSA on Linux, which PipeWire and PulseAudio serve; AAudio on Android).

The stream is built as f32, or as i16 when the device offers nothing else; the capture function always sees f32. The i16 path keeps a scratch buffer that grows to the largest block seen, so it allocates on the first callbacks only.

Implementations§

Source§

impl CpalSource

Source

pub fn new() -> Self

The platform’s default host.

Source

pub fn with_host(host: Host) -> Self

A given host.

Trait Implementations§

Source§

impl AudioSource for CpalSource

Source§

fn default_config(&self) -> Result<SinkConfig, SinkError>

The device’s preferred configuration.
Source§

fn start( &mut self, config: SinkConfig, capture: CaptureFn, ) -> Result<SinkHandle, SinkError>

Start capturing with exactly config, calling capture with each block. Capture stops when the handle is dropped.
Source§

impl Default for CpalSource

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Forget for CpalSource

§

impl Freeze for CpalSource
where *const ArcInner<AlsaContext> is !null: Freeze, PhantomData<ArcInner<AlsaContext>>: Freeze,

§

impl Move for CpalSource

§

impl RefUnwindSafe for CpalSource

§

impl Send for CpalSource
where Arc<AlsaContext>: Send,

§

impl Sync for CpalSource
where Arc<AlsaContext>: Sync,

§

impl Unpin for CpalSource
where Arc<AlsaContext>: Unpin,

§

impl UnsafeUnpin for CpalSource
where *const ArcInner<AlsaContext> is !null: UnsafeUnpin, PhantomData<ArcInner<AlsaContext>>: UnsafeUnpin,

§

impl UnwindSafe for CpalSource
where Arc<AlsaContext>: UnwindSafe,

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<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

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> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.