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
impl RingSource
Sourcepub fn new(
consumer: Consumer<AudioFrame>,
channels: u16,
sample_rate: u32,
num_frames: usize,
) -> Self
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.
Sourcepub fn consumer(&self) -> &Consumer<AudioFrame>
pub fn consumer(&self) -> &Consumer<AudioFrame>
Returns a shared reference to the underlying consumer (for diagnostics).
Sourcepub fn last(&self) -> &AudioFrame
pub fn last(&self) -> &AudioFrame
Returns a shared reference to the last received frame.