AUDIO
Source snapshot · 11 November 2026

API reference / ravet_audio_file::VorbisRecordingWorker

Struct VorbisRecordingWorker 

pub struct VorbisRecordingWorker<W: Write + Send + 'static> { /* private fields */ }
Expand description

Prepared-ring automatic owner for the genuinely !Send Vorbis codec. Only transferable preparation/results cross threads; initialize/pump/EOS/abort/ codec Drop stay on one named worker. Capture retains its unique prepared producer; callback push adds no heap, lock, I/O or implicit backpressure. Pause waits for the active worker batch/I/O, then acknowledges no more queue consumption until resume/finalize. Control operations, join and Drop can block indefinitely on caller sink I/O; they have no cancellation/deadline guarantee. Drop requests gated abort and joins, never EOS/flush. Sink destructors retain their own contract. Worker panic loses unwound sink/source and reports Failed. No physical device, perceptual, clock/resampling or callback deadline claim.

use ravet_audio_file::{audio_ring, VorbisFormat, VorbisRecordingWorker,
    VorbisRecordingCompletion};
let (mut producer,consumer)=audio_ring(1,4).unwrap();
let mut worker=VorbisRecordingWorker::new(Vec::new(),VorbisFormat {
    channels:1,sample_rate:48000,quality:0.5,stream_serial:1,
},consumer,2,4,65536)?;
worker.start()?;
producer.push(&[0.25,-0.25]).unwrap();
drop(producer); // after callback stop; proves no future publication
let exit=worker.finish_after_producer_retired()?;
match exit.completion() {
    VorbisRecordingCompletion::Finalized=>assert!(!exit.destination.is_empty()),
    VorbisRecordingCompletion::Failed(error)=>panic!("recording failed: {error:?}"),
    VorbisRecordingCompletion::Aborted=>panic!("recording was aborted"),
}

Implementations§

§

impl<W: Write + Send + 'static> VorbisRecordingWorker<W>

pub fn new( sink: W, format: VorbisFormat, consumer: AudioConsumer, batch_frames: usize, maximum_frames: u64, maximum_bytes: u64, ) -> Result<Self, Error>

Validate configuration/queue and prepare 1..4096-frame source scratch, without codec/thread/header creation.

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

Acknowledge OS spawn only; startup faults are carried by status/eventual completion. Spawn failure keeps preparation for retry/abort.

pub fn status(&self) -> VorbisRecordingStatus

pub fn accepted_frames(&self) -> u64

Encoder-submitted frames, including a failing accepted batch.

pub fn dequeued_frames(&self) -> u64

Ring-dequeued frames, including a rejected source batch.

pub fn written_bytes(&self) -> u64

Actual sink-accepted bytes, including partial failed writes.

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

Wait for active I/O and acknowledgement; no later dequeue until resume/finalize. No I/O cancellation/deadline.

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

Resume same local codec and wait for running acknowledgement.

pub fn finish_stopped( &mut self, producer: &mut AudioProducer, ) -> Result<VorbisRecordingExit<W>, Error>

Validate matching stopped producer before bounded tail drain/EOS/flush. Foreign proof preserves state; inspect completion, outer Ok proves recovery only.

pub fn finish_after_producer_retired( &mut self, ) -> Result<VorbisRecordingExit<W>, Error>

Permanent producer Drop proves no later publication, including hidden capture adapters. Live/leaked proof preserves state.

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

Reclaim incomplete sink/source/original fault without tail drain/EOS/flush. Prepared abort touches no sink; panic loses unwound owners.

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.