pub struct AudioPipeline { /* private fields */ }Expand description
Streaming audio pipeline that decodes and resamples in background
Implementations§
Source§impl AudioPipeline
impl AudioPipeline
Sourcepub fn new(
path: &str,
target_sample_rate: Option<u32>,
_resample_quality: ResampleQuality,
) -> Result<Self, PipelineError>
pub fn new( path: &str, target_sample_rate: Option<u32>, _resample_quality: ResampleQuality, ) -> Result<Self, PipelineError>
Create a new pipeline from a file path.
This opens the decoder once to read the source format (sample rate,
channel count, and frame count) so callers can query the pipeline before
starting the background worker. Call AudioPipeline::start to begin
decoding and resampling.
Sourcepub fn start(
&mut self,
path: String,
target_sample_rate: Option<u32>,
quality: ResampleQuality,
)
pub fn start( &mut self, path: String, target_sample_rate: Option<u32>, quality: ResampleQuality, )
Start the background processing thread
Sourcepub fn read(&self, output: &mut [f64]) -> usize
pub fn read(&self, output: &mut [f64]) -> usize
Read audio data from the pipeline Returns number of frames actually read
Sourcepub fn read_position(&self) -> u64
pub fn read_position(&self) -> u64
Get current read position in frames
Sourcepub fn set_read_position(&self, frame: u64)
pub fn set_read_position(&self, frame: u64)
Set read position (for seeking)
Sourcepub fn total_frames(&self) -> u64
pub fn total_frames(&self) -> u64
Get total frames
Sourcepub fn buffered_frames(&self) -> u64
pub fn buffered_frames(&self) -> u64
Get buffered frames
Sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
Check if pipeline has finished processing
Sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
Check if pipeline is running
Sourcepub fn buffer_ratio(&self) -> f32
pub fn buffer_ratio(&self) -> f32
Get buffering ratio (0.0 - 1.0)
Sourcepub fn available_frames(&self) -> u64
pub fn available_frames(&self) -> u64
Get available frames from current read position
Sourcepub fn sample_rate(&self) -> u32
pub fn sample_rate(&self) -> u32
Output (post-resample) sample rate in Hz.
Sourcepub fn original_sample_rate(&self) -> u32
pub fn original_sample_rate(&self) -> u32
Source (pre-resample) sample rate in Hz.
Trait Implementations§
Source§impl Drop for AudioPipeline
impl Drop for AudioPipeline
Auto Trait Implementations§
impl !RefUnwindSafe for AudioPipeline
impl !UnwindSafe for AudioPipeline
impl Freeze for AudioPipeline
impl Send for AudioPipeline
impl Sync for AudioPipeline
impl Unpin for AudioPipeline
impl UnsafeUnpin for AudioPipeline
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more