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
impl RingSink
Sourcepub fn new(
producer: Producer<AudioFrame>,
channels: u16,
sample_rate: u32,
num_frames: usize,
) -> Self
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.
Sourcepub fn flush(&mut self) -> Result<(), PushError<AudioFrame>>
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).
Sourcepub fn producer(&self) -> &Producer<AudioFrame>
pub fn producer(&self) -> &Producer<AudioFrame>
Returns a shared reference to the underlying producer (for diagnostics).
Sourcepub fn stash(&self) -> &AudioFrame
pub fn stash(&self) -> &AudioFrame
Returns a shared reference to the stashed frame.