AUDIO
Source snapshot · 11 November 2026

API reference / ravet_audio_file::WaveReadAhead

Struct WaveReadAhead 

pub struct WaveReadAhead<R> { /* private fields */ }
Expand description

Worker-owned WAV read-ahead with retained unqueued samples under backpressure. Prepare 1..=65,536 scratch frames no greater than the reader’s own capacity. Calls perform seek/read I/O and must never run on an audio callback.

Implementations§

§

impl<R: Read + Seek> WaveReadAhead<R>

pub fn new( reader: WaveReader<R>, producer: AudioProducer, maximum_frames: usize, ) -> Result<Self, AudioFileError>

pub fn format(&self) -> WaveFormat

pub fn reader_position(&self) -> u64

Reader position includes pending/queued frames, not the audible position.

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

At most one bounded file read. A full ring retains the entire remaining scratch suffix and prevents another read until that suffix is published. Failed reads preserve reader position and may be retried explicitly.

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

Seek after stopping and reclaiming both endpoints. Reject a foreign ring or out-of-range frame before changing reader/pending/queued state. Success discards old queued and unqueued data; no old generation leaks into playback.

Trait Implementations§

§

impl<R: Read + Seek + Send + 'static> ReadAheadPump for WaveReadAhead<R>

§

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

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

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<(), AudioFileError>

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

fn worker_progressed(&self, progress: &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.

Auto Trait Implementations§

§

impl<R> Freeze for WaveReadAhead<R>
where R: Freeze,

§

impl<R> RefUnwindSafe for WaveReadAhead<R>
where R: RefUnwindSafe,

§

impl<R> Send for WaveReadAhead<R>
where R: Send,

§

impl<R> Sync for WaveReadAhead<R>
where R: Sync,

§

impl<R> Unpin for WaveReadAhead<R>
where R: Unpin,

§

impl<R> UnsafeUnpin for WaveReadAhead<R>
where R: UnsafeUnpin,

§

impl<R> UnwindSafe for WaveReadAhead<R>
where 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.