Skip to main content

RingSink

Struct RingSink 

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

A sink node that stashes audio from the graph for a worker thread to drain.

RingSink holds the Producer end of an rtrb ring plus a stash frame. On every cycle it copies its single input into the stash (bounded, RT-safe). The stash is not pushed to the ring inside process, because rtrb::Producer::push takes ownership and would force a heap clone of the frame — that clone must happen off the real-time thread.

Call RingSink::flush from a worker thread to ship the stashed frame across the ring to its consumer.

§Real-time safety

process performs only a bounded copy into the pre-sized stash — no allocation, lock, panic, or syscall. The cloning push is deferred to the non-RT RingSink::flush.

Implementations§

Source§

impl RingSink

Source

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

Creates a new sink feeding producer.

stash is pre-allocated to silence of the given size so the RT copy never grows it.

Source

pub fn flush(&mut self) -> Result<(), PushError<AudioFrame>>

Pushes the stashed frame into the ring.

This clones the stash (allocating) and is therefore intended for the worker thread, not the real-time thread. The stash itself is left in place so the next cycle can overwrite it.

§Errors

Returns rtrb::PushError containing the unpushed frame when the ring has no free slot (treat as an xrun / dropped frame).

Source

pub fn producer(&self) -> &Producer<AudioFrame>

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

Source

pub fn stash(&self) -> &AudioFrame

Returns a shared reference to the stashed frame.

Trait Implementations§

Source§

impl AudioNode for RingSink

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.