Struct Flac Writer
pub struct FlacWriter<W> { /* private fields */ }Expand description
Optional incremental PCM16/24 FLAC writer for an empty seekable destination. Accepts at most 65536 whole interleaved frames per write and retains only one 4096-frame pending block, one backend frame buffer and one serialized frame. Backend working allocations remain its contract; all methods are worker-only. Invalid input preserves prior state/output. Encoding/I/O/capacity failure after acceptance poisons the writer; output may contain an irreversible prefix. Finish emits the sole short final block, rewrites STREAMINFO count/MD5/frame sizes and flushes before returning ownership. Drop does not finalize; partial files are not complete recordings. No float quantization, path/thread/device policy, implicit file truncation or physical recording/deadline claim.
Implementations§
§impl<W: Write + Seek> FlacWriter<W>
impl<W: Write + Seek> FlacWriter<W>
pub fn new(
destination: W,
format: FlacFormat,
maximum_frames: u64,
maximum_bytes: u64,
) -> Result<Self, Error>
pub fn new( destination: W, format: FlacFormat, maximum_frames: u64, maximum_bytes: u64, ) -> Result<Self, Error>
Require a destination of length zero, 1..8 channels/1..96000 Hz, a maximum frame count 1..2^36-1 fitting usize, and byte budget at least 42 (header). Validation/preparation precede header output; native I/O errors may mutate destination position or leave a partial header. The sink is caller-owned.
pub fn format(&self) -> FlacFormat
pub fn accepted_frames(&self) -> u64
pub fn accepted_frames(&self) -> u64
Accepted frames, including retained pending input and any poisoned prefix.
pub fn pending_frames(&self) -> usize
pub fn written_bytes(&self) -> u64
pub fn written_bytes(&self) -> u64
Header plus complete serialized frames submitted successfully to the sink. A failed write may have submitted an additional partial frame.
pub fn is_poisoned(&self) -> bool
pub fn write_frames(&mut self, samples: &[i32]) -> Result<(), Error>
pub fn write_frames(&mut self, samples: &[i32]) -> Result<(), Error>
Validate the complete call before acceptance, then emit full fixed blocks. Empty writes are no-ops. Per-call/total input bounds and signed precision violations preserve a usable writer. Output-budget failure during encoding poisons; earlier successful output and accepted pending samples remain.