Skip to main content

CpalOutput

Struct CpalOutput 

Source
pub struct CpalOutput { /* private fields */ }
Available on crate feature cpal-output only.
Expand description

Audio output device impl using cpal.

Implementations§

Source§

impl CpalOutput

Source

pub fn open() -> Result<Self, Error>

Source

pub fn open_with_host(hostid: AudioHostId) -> Result<Self, Error>

Trait Implementations§

Source§

impl OutputDevice for CpalOutput

Source§

fn channel_count(&self) -> usize

Returns the output buffer channel count (e.g., 1 for mono, 2 for stereo).
Source§

fn sample_rate(&self) -> u32

Returns the output sample rate in Hz.
Source§

fn sample_position(&self) -> u64

Returns the current playhead position in samples (not frames). Tracks the total number of samples output since device creation.
Source§

fn volume(&self) -> f32

Returns the current output volume (typically 0.0 to 1.0).
Source§

fn set_volume(&mut self, volume: f32)

Sets the output volume.
Source§

fn is_suspended(&self) -> bool

Returns true if audio output is suspended by the system. Only relevant for web audio backends; always returns false for desktop backends.
Source§

fn is_running(&self) -> bool

Returns true if audio is currently playing (not paused).
Source§

fn pause(&mut self)

Pauses playback while keeping the output source active.
Source§

fn resume(&mut self)

Resumes playback from a paused state.
Source§

fn play(&mut self, source: Box<dyn Source>)

Starts playback of a new audio source.
Source§

fn stop(&mut self)

Stops playback and replaces the source with silence.
Source§

fn close(&mut self)

Releases the audio device and cleans up resources.

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<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<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,