Skip to main content

AudioSource

Trait AudioSource 

Source
pub trait AudioSource: Send {
    // Required methods
    fn channels(&self) -> u16;
    fn sample_rate(&self) -> u32;
    fn duration(&self) -> Option<f64>;
    fn next_block(&mut self) -> Option<Block<'_>>;
    fn seek(&mut self, secs: f64) -> Result<f64, AudioError>;
    fn position(&self) -> f64;
    fn backend(&self) -> &'static str;
}
Expand description

A decoded audio stream.

Required Methods§

Source

fn channels(&self) -> u16

Channels in each block’s frames.

Source

fn sample_rate(&self) -> u32

Frames per second.

Source

fn duration(&self) -> Option<f64>

The stream’s length in seconds, when the file says.

Source

fn next_block(&mut self) -> Option<Block<'_>>

The next block of samples, or None at the end.

Source

fn seek(&mut self, secs: f64) -> Result<f64, AudioError>

Moves so the next block starts at secs (clamped to the stream) and returns the time it starts at.

Source

fn position(&self) -> f64

Where the next block starts, in seconds.

Source

fn backend(&self) -> &'static str

Which decoder backs the stream, for messages and tests.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§