⚠️ VeridianOS Kernel Documentation - This is low-level kernel code. All functions are unsafe unless explicitly marked otherwise. no_std

AudioClient

Struct AudioClient 

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

Manages all active audio streams

Implementations§

Source§

impl AudioClient

Source

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.

Source

pub fn destroy_stream(&mut self, id: AudioStreamId) -> Result<(), KernelError>

Destroy an audio stream, freeing its buffer and mixer channel

Source

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).

Source

pub fn play(&mut self, id: AudioStreamId) -> Result<(), KernelError>

Start playing a stream

Source

pub fn pause(&mut self, id: AudioStreamId) -> Result<(), KernelError>

Pause a playing stream

Source

pub fn stop(&mut self, id: AudioStreamId) -> Result<(), KernelError>

Stop a stream (resets to beginning)

Source

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)

Source

pub fn get_state(&self, id: AudioStreamId) -> Result<StreamState, KernelError>

Get the state of a stream

Source

pub fn close_stream(&mut self, id: AudioStreamId) -> Result<(), KernelError>

Close and remove an audio stream

Source

pub fn stream_count(&self) -> usize

Get the number of active streams

Source

pub fn default_sample_rate(&self) -> u32

Get the sample rate of the client’s default config

Source

pub fn default_channels(&self) -> u8

Get the default channel count

Auto Trait Implementations§

§

impl !Freeze for AudioClient

§

impl !RefUnwindSafe for AudioClient

§

impl Send for AudioClient

§

impl Sync for AudioClient

§

impl Unpin for AudioClient

§

impl !UnwindSafe for AudioClient

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.