pub struct CpalSink { /* private fields */ }Expand description
Plays through the default output device of a cpal host: ALSA on Linux (which a PipeWire or PulseAudio server serves through its ALSA plugin), AAudio on Android, and the native host elsewhere.
The stream is built as f32, or as i16 when the device offers nothing else; the render 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.
A request the device cannot do exactly is SinkError::UnsupportedConfig with the device’s default attached, never a silent change of rate.
Implementations§
Trait Implementations§
Source§impl AudioSink for CpalSink
impl AudioSink for CpalSink
Source§fn default_config(&self) -> Result<SinkConfig, SinkError>
fn default_config(&self) -> Result<SinkConfig, SinkError>
The format the device prefers, to ask for when a request is
SinkError::UnsupportedConfig.Source§fn start(
&mut self,
config: SinkConfig,
render: RenderFn,
) -> Result<SinkHandle, SinkError>
fn start( &mut self, config: SinkConfig, render: RenderFn, ) -> Result<SinkHandle, SinkError>
Starts the stream.
render is called on the audio thread with a buffer to fill. The stream stops when the handle is dropped.
A sink that cannot run the exact config returns SinkError::UnsupportedConfig instead of running at another rate, so the render
function never has to guess its format.Auto Trait Implementations§
impl Forget for CpalSink
impl Freeze for CpalSink
impl Move for CpalSink
impl RefUnwindSafe for CpalSink
impl Send for CpalSink
impl Sync for CpalSink
impl Unpin for CpalSink
impl UnsafeUnpin for CpalSinkwhere
*const ArcInner<AlsaContext> is !null: UnsafeUnpin,
PhantomData<ArcInner<AlsaContext>>: UnsafeUnpin,
*const ArcInner<Atomic<bool>> is !null: UnsafeUnpin,
PhantomData<ArcInner<Atomic<bool>>>: UnsafeUnpin,
impl UnwindSafe for CpalSink
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