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

AudioRingBuffer

Struct AudioRingBuffer 

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

Lock-free single-producer single-consumer ring buffer for audio data

Uses atomic read/write positions to allow concurrent access from one producer and one consumer without locking.

Implementations§

Source§

impl AudioRingBuffer

Source

pub fn new(capacity_frames: u32, frame_size: u16) -> Self

Create a new ring buffer with the given capacity in frames

The actual byte capacity is capacity_frames * frame_size.

Source

pub fn write(&self, data: &[u8]) -> usize

Write data into the ring buffer

Returns the number of bytes actually written. May be less than data.len() if the buffer is nearly full.

Source

pub fn read(&self, output: &mut [u8]) -> usize

Read data from the ring buffer

Returns the number of bytes actually read. May be less than output.len() if the buffer does not contain enough data.

Source

pub fn available_read(&self) -> u32

Number of frames available to read

Source

pub fn available_write(&self) -> u32

Number of frames available to write

Source

pub fn clear(&mut self)

Clear the buffer (reset read/write positions)

Source

pub fn is_empty(&self) -> bool

Check if the buffer is empty

Source

pub fn is_full(&self) -> bool

Check if the buffer is full (only 1 byte of slack remaining)

Auto Trait Implementations§

§

impl !Freeze for AudioRingBuffer

§

impl RefUnwindSafe for AudioRingBuffer

§

impl Send for AudioRingBuffer

§

impl Sync for AudioRingBuffer

§

impl Unpin for AudioRingBuffer

§

impl UnwindSafe for AudioRingBuffer

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.