AUDIO
Source snapshot · 11 November 2026

API reference / ravet_audio_file::IndexedConvertedReadAhead

Struct IndexedConvertedReadAhead 

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>

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)

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>>

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).

Trait Implementations§

§

impl<R: IndexedPlaybackReader + Send + 'static, F: FnMut() -> Result<R, AudioFileError> + Send + 'static> ReadAheadPump for IndexedConvertedReadAhead<R, F>

§

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

Perform one bounded read/publication attempt outside the audio callback.
§

fn worker_progressed(&self, _: &ReadAheadProgress) -> bool

Whether the immediately preceding pump made bounded worker progress. Pure, bounded observation only: no I/O, blocking or allocation. Native default uses new publication; explicitly converted sources can include input read/consumption/output generation. An unchanged full ring is false.
§

fn owns(&self, consumer: &AudioConsumer) -> bool

Check that this source owns the consumer’s matching producer.
§

fn pending_frames(&self) -> usize

Remaining worker scratch frames not yet published to the ring.
§

fn reader_position(&self) -> u64

Queue-source generated/read position, including pending and queued frames. Converted implementations use target-rate output frames, not input frames.
§

fn sample_rate(&self) -> u32

Fixed queue-source sample rate; conversion is explicit in its implementation.
§

fn seek_stopped( &mut self, consumer: &mut AudioConsumer, frame: u64, ) -> Result<(), Error>

Position exactly in queue-source frames, clearing generation only after success.

Auto Trait Implementations§

§

impl<R, F> Freeze for IndexedConvertedReadAhead<R, F>
where F: Freeze, R: Freeze,

§

impl<R, F> RefUnwindSafe for IndexedConvertedReadAhead<R, F>

§

impl<R, F> Send for IndexedConvertedReadAhead<R, F>
where F: Send, R: Send,

§

impl<R, F> Sync for IndexedConvertedReadAhead<R, F>
where F: Sync, R: Sync,

§

impl<R, F> Unpin for IndexedConvertedReadAhead<R, F>
where F: Unpin, R: Unpin,

§

impl<R, F> UnsafeUnpin for IndexedConvertedReadAhead<R, F>
where F: UnsafeUnpin, R: UnsafeUnpin,

§

impl<R, F> UnwindSafe for IndexedConvertedReadAhead<R, F>
where F: UnwindSafe, R: 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.