AUDIO
Source snapshot · 11 November 2026

API reference / ravet_audio_file::CompressedReadAhead

Struct CompressedReadAhead 

pub struct CompressedReadAhead { /* private fields */ }
Expand description

Owned compressed worker pump. Prepare 1..65536 scratch frames and matching channel ring. No thread/clock/device is created. Decode/seek and destruction may allocate and must stay outside audio; only consumer pop is callback-safe. Pending decoded scratch retains unqueued suffixes under backpressure.

Implementations§

§

impl CompressedReadAhead

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

pub fn sample_rate(&self) -> u32

pub fn channels(&self) -> u16

pub fn reader_position(&self) -> usize

Includes pending/queued frames, rather than audible/sample-clock position.

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

At most one bounded stream read. Full rings retain remaining scratch and prevent another read until it is queued. EOF means verified stream end; pending/queued audio can still require playback. Decode faults poison the pump; queued earlier audio remains and cannot be rolled back.

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

Reclaim both endpoints after stopping/joining users. Reject foreign queues or failed replay before changing pending/queued state. Success clears old generation audio and poison. Default readers replay O(target); indexed FLAC readers decode one indexed packet. Neither mode provides a live seek.

Trait Implementations§

§

impl ReadAheadPump for CompressedReadAhead

§

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§

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.