pub struct PcmTrack { /* private fields */ }Expand description
A progressive PCM stream with one fixed source format.
Implementations§
Source§impl PcmTrack
impl PcmTrack
Sourcepub fn open(path: &Path) -> Result<Self, Error>
pub fn open(path: &Path) -> Result<Self, Error>
Open a local audio file without decoding it in full.
Sourcepub fn open_native(path: &Path) -> Result<Self, Error>
pub fn open_native(path: &Path) -> Result<Self, Error>
Native-only progressive decode for cooperative background extraction, without a child process.
Sourcepub fn open_stereo(path: &Path) -> Result<Self, Box<dyn Error>>
pub fn open_stereo(path: &Path) -> Result<Self, Box<dyn Error>>
Prepare stereo output for known multichannel material. Mono and stereo keep their original samples and channel positions.
Sourcepub fn format(&self) -> PcmStreamFormat
pub fn format(&self) -> PcmStreamFormat
The PCM format a sink must accept for this track.
Sourcepub fn source_format(&self) -> PcmStreamFormat
pub fn source_format(&self) -> PcmStreamFormat
Decoded source format before an optional stereo downmix.
Sourcepub fn flac_md5_status(&self) -> Option<FlacMd5Status>
pub fn flac_md5_status(&self) -> Option<FlacMd5Status>
FLAC source verification for this run, before downmix, resampling or DSP.
Only a fully decoded source reaching EOF can be verified; another codec
returns None. This status does not alter persisted integrity results.
Sourcepub fn set_output_rate(&mut self, rate: u32) -> Result<(), RateError>
pub fn set_output_rate(&mut self, rate: u32) -> Result<(), RateError>
Choose the sink’s sample rate before seeking or reading the first block. When rates match, samples retain the exact decoded path.
Sourcepub fn seek_from_start(
&mut self,
position: Duration,
cancelled: impl FnMut() -> bool,
) -> Result<SeekResult, Error>
pub fn seek_from_start( &mut self, position: Duration, cancelled: impl FnMut() -> bool, ) -> Result<SeekResult, Error>
Position a newly opened track at the source frame at or before position.
Seeking progressively decodes and discards the prefix, without sending
it through the source observer, downmix, resampler or caller’s DSP. It
preserves the ordinary decoder’s delay, padding and error semantics and
uses no whole-file buffer. Work grows with the requested position;
cancellation is checked between bounded frame steps, though one decoder
call may block on I/O. A position beyond EOF returns the actual frame
count with reached_eof set, rather than trusting tag duration.
Call at most once, before reading PCM. Set the output rate first when needed. A backward or subsequent seek requires reopening the track and resetting the driver’s output and DSP session. After cancellation or a decode error, discard this track. Measurements of the suffix are not a full-track loudness result and must not be cached as one.
Sourcepub fn read_block<E>(
&mut self,
process: impl FnOnce(&mut [f32]) -> Result<(), E>,
) -> Result<Option<PcmBlock<'_>>, StreamError<E>>
pub fn read_block<E>( &mut self, process: impl FnOnce(&mut [f32]) -> Result<(), E>, ) -> Result<Option<PcmBlock<'_>>, StreamError<E>>
Read, optionally process, and encode the next block.
Returns None only at end of file. The processing function is called
once for each nonempty block and may retain state between calls. The
returned views are valid until the next call to read_block.
Sourcepub fn read_block_observed<E>(
&mut self,
observe: impl FnMut(PcmStreamFormat, &[f32]),
process: impl FnOnce(&mut [f32]) -> Result<(), E>,
) -> Result<Option<PcmBlock<'_>>, StreamError<E>>
pub fn read_block_observed<E>( &mut self, observe: impl FnMut(PcmStreamFormat, &[f32]), process: impl FnOnce(&mut [f32]) -> Result<(), E>, ) -> Result<Option<PcmBlock<'_>>, StreamError<E>>
Read a block while observing decoded source PCM before any downmix, rate conversion or caller-supplied processing.
The observer receives each nonempty source block exactly once with its original format. One output block may require several source blocks, or contain only a converter tail; the tail and EOF are never observed. Observers that perform optional measurements should retain their own errors without interrupting playback.