AUDIO
Source snapshot · 11 November 2026

API reference / ravet_audio_file::FlacRecorder

Struct FlacRecorder 

pub struct FlacRecorder<W> { /* private fields */ }
Expand description

Worker-owned incremental FLAC capture sink fed by a prepared f32 audio ring. Audio callbacks only publish; pump quantizes/encodes/writes on its caller. Any failure after dequeue poisons because accepted ring frames cannot roll back. Producer full-ring drops remain producer policy. Drop does not finalize. No hidden worker, path/device/clock choice or physical recording claim.

Implementations§

§

impl<W: Write + Seek> FlacRecorder<W>

pub fn new( destination: W, format: FlacFormat, maximum_pump_frames: usize, maximum_total_frames: u64, maximum_bytes: u64, policy: FlacCapturePolicy, consumer: AudioConsumer, ) -> Result<Self, Error>

Validate ring channels and 1..65536 pump frames before creating the writer header. Writer format, total frame/byte budgets and empty sink rules apply.

pub fn frames(&self) -> u64

Frames accepted by the encoder, including its retained pending block. A rejected dequeued batch is excluded; successful capture is not yet final.

pub fn is_poisoned(&self) -> bool

pub fn pump(&mut self) -> Result<usize, Error>

Drain at most one prepared scratch batch; an empty ring performs no I/O. Malformed/nonfinite/overload input, writer capacity or I/O failure poisons after dequeue. Failed batches may have an irreversible accepted prefix.

pub fn finish(self) -> Result<W, Error>

Stop/join the producer first. Drain at most one ring capacity then finalize the nonempty FLAC writer. Concurrent late publication can reject or lose late data; stopped producer is the caller’s lifecycle obligation. Consumes the sink, with no retry after final output/header/seek/flush failures.

Trait Implementations§

§

impl<W: Write + Seek + Send + 'static> RecordingPump for FlacRecorder<W>

§

type Destination = W

Caller-selected sink returned only after successful consuming finish.
§

fn consumer(&self) -> &AudioConsumer

Stable exact owned consumer drained by pump/finish. It must identify the same ring for the recorder’s lifetime, including permanent retirement proof.
§

fn owns(&self, producer: &AudioProducer) -> bool

Check exact prepared producer/consumer identity outside callbacks.
§

fn pump(&mut self) -> Result<usize, Error>

Drain one bounded worker batch, returning successfully accepted frames.
§

fn frames(&self) -> u64

Source count semantics remain explicit: WAV/AIFF count successful writes; FLAC counts accepted encoder frames, including retained pending blocks.
§

fn finish(self) -> Result<W, Error>

Drain bounded remaining input and finalize the sink with producer stopped.

Auto Trait Implementations§

§

impl<W> Freeze for FlacRecorder<W>
where W: Freeze,

§

impl<W> RefUnwindSafe for FlacRecorder<W>
where W: RefUnwindSafe,

§

impl<W> Send for FlacRecorder<W>
where W: Send,

§

impl<W> Sync for FlacRecorder<W>
where W: Sync,

§

impl<W> Unpin for FlacRecorder<W>
where W: Unpin,

§

impl<W> UnsafeUnpin for FlacRecorder<W>
where W: UnsafeUnpin,

§

impl<W> UnwindSafe for FlacRecorder<W>
where W: UnwindSafe,

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<F, T> IntoSample<T> for Fwhere T: FromSample<F>,

§

fn into_sample(self) -> T

§

impl<T> Same for T

§

type Output = T

Should always be Self
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.