Skip to main content

RingSource

Struct RingSource 

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

A source node that drains audio from a worker thread via a lock-free ring.

RingSource holds the Consumer end of an rtrb ring. On every cycle it pops at most one AudioFrame (wait-free) and writes it into its single output port. If the ring is empty it repeats the last frame received, so the downstream signal holds rather than clicking to silence.

§Real-time safety

process performs only a wait-free pop and bounded slice copies — no allocation, lock, panic, or syscall. The last cache is pre-sized in RingSource::new so mirroring an incoming frame never grows it; if an incoming frame is shorter/longer than last the copy is bounded to the smaller length (no realloc).

Implementations§

Source§

impl RingSource

Source

pub fn new( consumer: Consumer<AudioFrame>, channels: u16, sample_rate: u32, num_frames: usize, ) -> Self

Creates a new source draining consumer.

last is pre-allocated to silence of the given size so that cycles before the first frame arrives emit silence rather than uninitialised data.

Source

pub fn consumer(&self) -> &Consumer<AudioFrame>

Returns a shared reference to the underlying consumer (for diagnostics).

Source

pub fn last(&self) -> &AudioFrame

Returns a shared reference to the last received frame.

Trait Implementations§

Source§

impl AudioNode for RingSource

Source§

fn inputs(&self) -> &[PortDescriptor]

Returns the static metadata for every input port on this node. Read more
Source§

fn outputs(&self) -> &[PortDescriptor]

Returns the static metadata for every output port on this node. Read more
Source§

fn process( &mut self, _ctx: &mut ProcessContext, _in_frames: &[AudioFrame], out_frames: &mut [AudioFrame], )

Processes one audio cycle, reading inputs and writing outputs in place. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.