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§
- Audio
Format - PCM stream format, checked once at the intake boundary.
- Sample
Consumer - Render/DSP-thread half.
- Sample
Producer - Audio-thread half. Real-time safe:
push_samplesnever allocates, locks, or blocks.
Enums§
- Format
Error - Why an
AudioFormatwas 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_framesframes of headroom (rounded up to a power of two).