Struct Indexed Converted Read Ahead
pub struct IndexedConvertedReadAhead<R, F> { /* private fields */ }Expand description
Explicit known-duration indexed PCM transport using IntegerSinc only. Each stopped candidate reads at most the taps-sized source window, plus an EOF probe when needed. The factory owns version stability and metadata parsing; skipped content is not authenticated. No compressed reader/deadline is implied. Temporary window scratch is at most 66KiB in addition to existing bounded state.
use ravet_audio_file::{audio_ring, IndexedConvertedReadAhead, ConvertedReadAheadOptions,
PlaybackConversion, WaveEncoding, WaveFormat, WaveReader, WaveWriter};
use std::io::Cursor;
let mut writer = WaveWriter::new(Cursor::new(Vec::new()),
WaveFormat { channels: 1, sample_rate: 44100, encoding: WaveEncoding::Float32 }, 17)?;
writer.write_frames(&[0.25; 17])?;
let bytes = writer.finish()?.into_inner();
let reader = WaveReader::new(Cursor::new(bytes.clone()), 17)?;
let (producer, mut consumer) = audio_ring(1, 32).unwrap();
let mut pump = IndexedConvertedReadAhead::new(reader,
move || WaveReader::new(Cursor::new(bytes.clone()), 17), producer, &consumer,
ConvertedReadAheadOptions { output_rate: 48000,
conversion: PlaybackConversion::IntegerSinc { taps: 16 },
maximum_source_frames: 17, maximum_output_frames: 64,
source_batch_frames: 17, conversion_batch_frames: 17 })?;
let receipt = pump.seek_indexed_stopped(&mut consumer, 1)?;
assert_eq!(receipt.window_original_frames, 2);
assert_eq!(pump.counts().original_frames_submitted_after_prime, 0);
assert_eq!(pump.output_origin(), 1);Implementations§
§impl<R: IndexedPlaybackReader, F: FnMut() -> Result<R, AudioFileError>> IndexedConvertedReadAhead<R, F>
impl<R: IndexedPlaybackReader, F: FnMut() -> Result<R, AudioFileError>> IndexedConvertedReadAhead<R, F>
pub fn new(
reader: R,
factory: F,
producer: AudioProducer,
consumer: &AudioConsumer,
options: ConvertedReadAheadOptions,
) -> Result<Self, ConvertedReadAheadFailure<R, F>>
pub fn new( reader: R, factory: F, producer: AudioProducer, consumer: &AudioConsumer, options: ConvertedReadAheadOptions, ) -> Result<Self, ConvertedReadAheadFailure<R, F>>
Frame-zero, known-duration IntegerSinc preparation, with matching empty stopped queue. No source reads, seeks or factory calls; failure owns inputs.
pub fn counts(&self) -> IndexedReadAheadCounts
pub fn generation(&self) -> u64
pub fn output_origin(&self) -> u64
pub fn output_generated_position(&self) -> u64
pub fn input_reader_position(&self) -> u64
pub fn pending_input_frames(&self) -> usize
pub fn pending_output_frames(&self) -> usize
pub fn pump(&mut self) -> Result<ConvertedReadAheadProgress, Error>
pub fn into_parts(self) -> (R, F, AudioProducer, IndexedReadAheadCounts)
pub fn into_parts(self) -> (R, F, AudioProducer, IndexedReadAheadCounts)
Recover stopped off-audio owners/counters; no seek/drain/read is hidden.
pub fn seek_indexed_stopped(
&mut self,
consumer: &mut AudioConsumer,
output_frame: u64,
) -> Result<IndexedSeekReceipt, IndexedSeekFailure<R>>
pub fn seek_indexed_stopped( &mut self, consumer: &mut AudioConsumer, output_frame: u64, ) -> Result<IndexedSeekReceipt, IndexedSeekFailure<R>>
Build a fresh indexed candidate off audio. Old queue/phase/suffix/cursor survive every failure; success commits one generation and clears the old matching stopped queue. No live endpoint mailbox or callback wait exists. Short positive reads are allowed: <=taps successful window read calls, plus at most one EOF probe. WAV/AIFF full reads use ceil(window/batch).