pub struct CpalOutput { /* private fields */ }Available on crate feature
cpal-output only.Expand description
Audio output device impl using cpal.
Implementations§
Source§impl CpalOutput
impl CpalOutput
Sourcepub fn open() -> Result<Self, Error>
pub fn open() -> Result<Self, Error>
Open an audio output device using the default configuration.
Sourcepub fn open_with_config(config: CpalOutputConfig) -> Result<Self, Error>
pub fn open_with_config(config: CpalOutputConfig) -> Result<Self, Error>
Open an audio output device using the given configuration.
Use CpalOutput::available_drivers, CpalOutput::available_devices and
CpalOutput::supported_sample_rates to enumerate available options dynamically.
Sourcepub fn available_drivers() -> Vec<CpalOutputDeviceDriver>
pub fn available_drivers() -> Vec<CpalOutputDeviceDriver>
Returns all audio drivers available on this platform.
Always includes CpalOutputDeviceDriver::Default, followed by any named drivers that are
currently available (e.g. ASIO, WASAPI on Windows; ALSA, JACK on Linux).
Sourcepub fn available_devices(
driver: CpalOutputDeviceDriver,
) -> Result<Vec<(DeviceId, String)>, Error>
pub fn available_devices( driver: CpalOutputDeviceDriver, ) -> Result<Vec<(DeviceId, String)>, Error>
Returns (id, name)s of all output devices available for the given driver.
Sourcepub fn supported_sample_rates(
driver: CpalOutputDeviceDriver,
device_id: Option<CpalDeviceId>,
) -> Result<Vec<u32>, Error>
pub fn supported_sample_rates( driver: CpalOutputDeviceDriver, device_id: Option<CpalDeviceId>, ) -> Result<Vec<u32>, Error>
Returns unique sample rates supported by an output device, sorted ascending.
Pass device_name = None to query the driver’s default device.
Trait Implementations§
Source§impl OutputDevice for CpalOutput
impl OutputDevice for CpalOutput
Source§fn channel_count(&self) -> usize
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
fn sample_rate(&self) -> u32
Returns the output sample rate in Hz.
Source§fn sample_position(&self) -> u64
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 set_volume(&mut self, volume: f32)
fn set_volume(&mut self, volume: f32)
Sets the output volume.
Source§fn is_suspended(&self) -> bool
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
fn is_running(&self) -> bool
Returns
true if audio is currently playing (not paused).Auto Trait Implementations§
impl Freeze for CpalOutput
impl !RefUnwindSafe for CpalOutput
impl Send for CpalOutput
impl Sync for CpalOutput
impl Unpin for CpalOutput
impl UnsafeUnpin for CpalOutput
impl !UnwindSafe for CpalOutput
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more