pub struct FileOutputBlock<S>where
S: Sample,{ /* private fields */ }Expand description
Writes audio from the DSP graph to a file.
This block uses a separate I/O thread to perform disk writes, avoiding blocking the audio thread. Samples are passed through a lock-free ring buffer.
Implementations§
Source§impl<S> FileOutputBlock<S>
impl<S> FileOutputBlock<S>
Sourcepub fn new(writer: Box<dyn Writer<S>>) -> FileOutputBlock<S>
pub fn new(writer: Box<dyn Writer<S>>) -> FileOutputBlock<S>
Create a FileOutputBlock with the Writer implementation for a particular type of audio file.
The writer is moved to a background I/O thread. Samples are passed through a lock-free ring buffer to avoid blocking the audio thread.
Sourcepub fn start_recording(&mut self)
pub fn start_recording(&mut self)
Tell the writer to begin storing audio sample data.
Sourcepub fn stop_recording(&mut self) -> Result<(), Box<dyn Error>>
pub fn stop_recording(&mut self) -> Result<(), Box<dyn Error>>
Tell the writer to stop storing audio sample data.
This signals the I/O thread to flush remaining samples and finalize the file. The method blocks until the I/O thread completes.
Sourcepub fn is_recording(&self) -> bool
pub fn is_recording(&self) -> bool
Check whether the writer is actively storing audio sample data.
Sourcepub fn error_occurred(&self) -> bool
pub fn error_occurred(&self) -> bool
Check whether any write errors have occurred.
This can be queried periodically to detect I/O failures without blocking the audio thread.