Skip to main content

CpalMicBackend

Struct CpalMicBackend 

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

cpal によるマイク入力キャプチャバックエンド。

既定入力デバイス(device_id = None)か、デバイス名で選んだ入力デバイス (device_id = Some(id))から生 interleaved f32 フレームを取り RawSink へ 流す。詳細はモジュールドキュメント参照。

Send。持つのは停止フラグ・JoinHandle・キャッシュ済みフォーマット・ device_id だけで、!Sendcpal::Stream は所有スレッド内に閉じ込める。

Implementations§

Source§

impl CpalMicBackend

Source

pub fn new(device_id: Option<String>) -> Self

マイクバックエンドを構築する。

device_id:

  • None → 既定入力デバイス(host.default_input_device())。
  • Some(id)host.input_devices() を走査し device.name()? == id の最初の デバイス(id は list_devices が返すデバイス名)。

選んだデバイスのネイティブフォーマットを問い合わせてキャッシュする。デバイスが 無い/一致しない/問い合わせ失敗なら FALLBACK_FORMAT(48000, 1))を キャッシュする。new 自体は panic もエラーもせず必ず成功し、device_id が一致 しなければ startError::DeviceNotFound になる。

Trait Implementations§

Source§

impl CaptureBackend for CpalMicBackend

Source§

fn native_format(&self) -> (u32, u16)

バックエンドのネイティブフォーマット (sample_rate, channels)
Source§

fn start(&mut self, sink: RawSink) -> Result<()>

指定シンクへ生フレームを流し始める。
Source§

fn stop(&mut self)

キャプチャを停止する。
Source§

impl Default for CpalMicBackend

Source§

fn default() -> Self

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

impl Drop for CpalMicBackend

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. 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<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 = 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.