Struct Wave Read Ahead
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>
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
pub fn reader_position(&self) -> u64
Reader position includes pending/queued frames, not the audible position.
pub fn pump(&mut self) -> Result<ReadAheadProgress, AudioFileError>
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>
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>
impl<R: Read + Seek + Send + 'static> ReadAheadPump for WaveReadAhead<R>
§fn pump(&mut self) -> Result<ReadAheadProgress, AudioFileError>
fn pump(&mut self) -> Result<ReadAheadProgress, AudioFileError>
Perform one bounded read/publication attempt outside the audio callback.
§fn owns(&self, consumer: &AudioConsumer) -> bool
fn owns(&self, consumer: &AudioConsumer) -> bool
Check that this source owns the consumer’s matching producer.
§fn pending_frames(&self) -> usize
fn pending_frames(&self) -> usize
Remaining worker scratch frames not yet published to the ring.
§fn reader_position(&self) -> u64
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
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>
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
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.