pub struct AudioClient { /* private fields */ }Expand description
Manages all active audio streams
Implementations§
Source§impl AudioClient
impl AudioClient
Sourcepub fn create_stream(
&mut self,
name: &str,
config: AudioConfig,
) -> Result<AudioStreamId, KernelError>
pub fn create_stream( &mut self, name: &str, config: AudioConfig, ) -> Result<AudioStreamId, KernelError>
Create a new audio stream
Allocates a ring buffer and registers a mixer channel for the stream.
The stream starts in the Stopped state.
Sourcepub fn destroy_stream(&mut self, id: AudioStreamId) -> Result<(), KernelError>
pub fn destroy_stream(&mut self, id: AudioStreamId) -> Result<(), KernelError>
Destroy an audio stream, freeing its buffer and mixer channel
Sourcepub fn write_samples(
&mut self,
id: AudioStreamId,
samples: &[i16],
) -> Result<usize, KernelError>
pub fn write_samples( &mut self, id: AudioStreamId, samples: &[i16], ) -> Result<usize, KernelError>
Write i16 samples to a stream’s buffer
Returns the number of samples actually written (may be less if the buffer is full).
Sourcepub fn play(&mut self, id: AudioStreamId) -> Result<(), KernelError>
pub fn play(&mut self, id: AudioStreamId) -> Result<(), KernelError>
Start playing a stream
Sourcepub fn pause(&mut self, id: AudioStreamId) -> Result<(), KernelError>
pub fn pause(&mut self, id: AudioStreamId) -> Result<(), KernelError>
Pause a playing stream
Sourcepub fn stop(&mut self, id: AudioStreamId) -> Result<(), KernelError>
pub fn stop(&mut self, id: AudioStreamId) -> Result<(), KernelError>
Stop a stream (resets to beginning)
Sourcepub fn set_volume(
&self,
id: AudioStreamId,
volume: u16,
) -> Result<(), KernelError>
pub fn set_volume( &self, id: AudioStreamId, volume: u16, ) -> Result<(), KernelError>
Set the volume for a stream (0..65535 maps to 0.0..1.0)
Sourcepub fn get_state(&self, id: AudioStreamId) -> Result<StreamState, KernelError>
pub fn get_state(&self, id: AudioStreamId) -> Result<StreamState, KernelError>
Get the state of a stream
Sourcepub fn close_stream(&mut self, id: AudioStreamId) -> Result<(), KernelError>
pub fn close_stream(&mut self, id: AudioStreamId) -> Result<(), KernelError>
Close and remove an audio stream
Sourcepub fn stream_count(&self) -> usize
pub fn stream_count(&self) -> usize
Get the number of active streams
Sourcepub fn default_sample_rate(&self) -> u32
pub fn default_sample_rate(&self) -> u32
Get the sample rate of the client’s default config
Sourcepub fn default_channels(&self) -> u8
pub fn default_channels(&self) -> u8
Get the default channel count