Struct Vorbis Recording Worker
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>
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>
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>
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
pub fn accepted_frames(&self) -> u64
Encoder-submitted frames, including a failing accepted batch.
pub fn dequeued_frames(&self) -> u64
pub fn dequeued_frames(&self) -> u64
Ring-dequeued frames, including a rejected source batch.
pub fn written_bytes(&self) -> u64
pub fn written_bytes(&self) -> u64
Actual sink-accepted bytes, including partial failed writes.
pub fn pause(&mut self) -> Result<(), Error>
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>
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>
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>
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>
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.