AUDIO
Source snapshot · 11 November 2026

API reference / ravet_audio_file::RecordingWorker

Struct RecordingWorker 

pub struct RecordingWorker<P: RecordingPump> { /* private fields */ }
Expand description

Control-owned bounded automatic recording pump. new validates the matching prepared producer and retains the recorder; start creates a named worker. Capture callbacks keep their unique AudioProducer and only call prepared push. Full-ring overload remains explicit accepted-prefix/caller-drop policy; no hidden allocation, blocking backpressure, device/path/clock choice occurs. Pump allocations, encoding and I/O belong to the worker. Stop/join/finish/Drop belong to control after capture shutdown; cooperative stop does not cancel active I/O or guarantee a join deadline. Dropping the owner joins but never drains/finalizes. A panicked worker loses its unwound recorder and reports Failed/Poisoned, never successful finalization.

Implementations§

§

impl<P: RecordingPump> RecordingWorker<P>

pub fn new( recorder: P, producer: &AudioProducer, ) -> Result<Self, AudioFileError>

Validate queue identity before transferring the recorder. No thread or final output is created here; recorder preparation may already have written its caller-selected file header. Capture need not start yet.

pub fn from_recorder(recorder: P) -> Self

Prepare from the recorder’s exact owned ring, without borrowing a producer. This accepts device capture adapters that keep the producer inside their callback. Finalize only after the producer is permanently retired/dropped. The RecordingPump consumer contract must identify its actual drained ring.

pub fn start(&mut self) -> Result<(), AudioFileError>

Begin automatic bounded draining. An active worker rejects. Empty input uses a 2 ms park timeout. OS thread creation failure retains recorder ownership and reports Failed; callers may retry or reclaim with shutdown.

pub fn status(&self) -> RecordingStatus

Concurrent diagnostic snapshot; Running is not finalized-file evidence.

pub fn stop(&mut self) -> Result<(), AudioFileError>

Stop/join without draining or finalizing, retaining the recorder for a later start, explicit finish or shutdown. Pump faults remain Failed.

pub fn finish_stopped( &mut self, producer: &mut AudioProducer, ) -> Result<P::Destination, AudioFileError>

Reclaim the producer only after its capture user stops/joins. A foreign producer rejects before stopping this worker. Join, then invoke the source’s bounded remaining drain and consuming finish on control. Success yields a complete sink and Finalized; further start/finish reject. A worker pump error is returned once and leaves the owned poisoned recorder available to shutdown. A finalization error consumes its sink and cannot be retried or treated as a complete file. Late publication violates the stopped-producer lifecycle and can reject finish or lose frames.

pub fn finish_after_producer_retired( &mut self, ) -> Result<P::Destination, AudioFileError>

Finalize after the unique producer has been dropped, including hidden device callback producers. Live or leaked producers reject before stopping this worker. Retirement is permanent; the queue’s acquire proof synchronizes its last publication, then joining permits the source’s bounded final drain. Device/callback shutdown belongs to its owner; this method performs no device operation. Error/sink-consumption rules match finish_stopped.

pub fn shutdown(self) -> Result<RecordingExit<P>, AudioFileError>

Stop/join and reclaim the recorder plus its original pump error. This does no final drain/header patch/flush; queued input remains source-owned. The error is absent if already returned by either finish method. A worker panic returns Poisoned because its unwound recorder cannot be reclaimed.

Auto Trait Implementations§

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.