Skip to main content

Module audio

Module audio 

Source
Expand description

Source-agnostic sample intake: format validation plus a lock-free SPSC ring buffer.

Format (sample rate, channel count) is validated once when the intake is created — the boundary — and the hot path trusts it from then on. The ring itself lives in the dependency-free rlx_ring crate (so Miri can check its unsafe without compiling the wgpu graph, Plan 0005); its SampleProducer/SampleConsumer handles are re-exported here so this module stays the single audio-intake surface for the standalone and FFI.

Samples are interleaved f32 frames. The producer side lives on an audio thread and stays real-time safe (no allocation, locks, logging, or I/O in push_samples, NFR section 5); if the ring is full the producer drops the excess (never blocks), and the consumer drains every render frame (NFR section 3).

Structs§

AudioFormat
PCM stream format, checked once at the intake boundary.
SampleConsumer
Render/DSP-thread half.
SampleProducer
Audio-thread half. Real-time safe: push_samples never allocates, locks, or blocks.

Enums§

FormatError
Why an AudioFormat was rejected at the boundary.

Constants§

MAX_CHANNELS
Most interleaved channels the intake accepts.
MAX_SAMPLE_RATE
Highest sample rate the intake accepts (Hz).
MIN_SAMPLE_RATE
Lowest sample rate the intake accepts (Hz).

Functions§

intake
Create a validated intake: an SPSC pair sized for at least capacity_frames frames of headroom (rounded up to a power of two).