Skip to main content

AudioSource

Trait AudioSource 

Source
pub trait AudioSource: Send + Sync {
    // Required methods
    fn sample_rate(&self) -> u32;
    fn channels(&self) -> u8;
    fn total_samples(&self) -> Option<u64>;
    fn read_frame(&mut self, frame_size: usize) -> Result<Option<AudioFrame>>;
    fn is_exhausted(&self) -> bool;
    fn reset(&mut self) -> Result<()>;
}
Expand description

Audio source trait for unified input handling.

Required Methods§

Source

fn sample_rate(&self) -> u32

Get the sample rate in Hz.

Source

fn channels(&self) -> u8

Get the number of channels.

Source

fn total_samples(&self) -> Option<u64>

Get the total number of samples (None for streams).

Source

fn read_frame(&mut self, frame_size: usize) -> Result<Option<AudioFrame>>

Read the next frame of audio.

Source

fn is_exhausted(&self) -> bool

Check if the source is exhausted.

Source

fn reset(&mut self) -> Result<()>

Reset to the beginning (if supported).

Implementors§