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

SharedAudioBuffer

Struct SharedAudioBuffer 

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

Mutex-protected audio ring buffer with typed sample interface

Wraps an AudioRingBuffer with a spin mutex to support multiple producers writing interleaved i16 samples.

Implementations§

Source§

impl SharedAudioBuffer

Source

pub fn new(capacity_frames: u32, config: AudioConfig) -> Self

Create a new shared audio buffer

§Arguments
  • capacity_frames - Number of audio frames the buffer can hold
  • config - Audio configuration (determines frame size)
Source

pub fn write_samples(&self, samples: &[i16]) -> usize

Write i16 samples into the buffer

Converts the sample slice to bytes and writes into the ring buffer. Returns the number of samples actually written.

Source

pub fn read_samples(&self, output: &mut [i16]) -> usize

Read i16 samples from the buffer

Reads bytes from the ring buffer and reinterprets as i16 samples. Returns the number of samples actually read.

Source

pub fn available_read_frames(&self) -> u32

Number of frames available to read

Source

pub fn available_write_frames(&self) -> u32

Number of frames available to write

Source

pub fn is_empty(&self) -> bool

Check if the buffer is empty

Source

pub fn config(&self) -> &AudioConfig

Get the audio configuration for this buffer

Auto Trait Implementations§

§

impl !Freeze for SharedAudioBuffer

§

impl !RefUnwindSafe for SharedAudioBuffer

§

impl Send for SharedAudioBuffer

§

impl Sync for SharedAudioBuffer

§

impl Unpin for SharedAudioBuffer

§

impl UnwindSafe for SharedAudioBuffer

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.