Struct Wave Recorder
pub struct WaveRecorder<W> { /* private fields */ }Expand description
Worker-owned recording sink for an input ring, with explicit finalization. Device callbacks only publish to the producer; pump performs file I/O here. No thread, physical device, file path or recording permission is chosen.
Implementations§
§impl<W: Write + Seek> WaveRecorder<W>
impl<W: Write + Seek> WaveRecorder<W>
pub fn new(
destination: W,
format: WaveFormat,
maximum_frames: usize,
consumer: AudioConsumer,
) -> Result<Self, AudioFileError>
pub fn new( destination: W, format: WaveFormat, maximum_frames: usize, consumer: AudioConsumer, ) -> Result<Self, AudioFileError>
Validate matching channels before writing a header to an empty destination.
pub fn frames(&self) -> u64
pub fn pump(&mut self) -> Result<usize, AudioFileError>
pub fn pump(&mut self) -> Result<usize, AudioFileError>
Drain at most prepared scratch frames. Empty returns zero without file I/O. Any recording error poisons this sink because dequeued frames cannot be rolled back; later calls reject. Input ring drops remain producer diagnostics.
pub fn finish(self) -> Result<W, AudioFileError>
pub fn finish(self) -> Result<W, AudioFileError>
Stop/join the producer first. Drain at most one ring capacity, patch WAV lengths and flush. Continuing publication can reject finalization or lose late frames: stopped-producer ownership is a caller lifecycle obligation. Drop performs no implicit drain/finalization/file I/O.