pub trait AudioSource {
// Required method
fn fill(&mut self, out: &mut [f32]) -> usize;
// Provided method
fn reset(&mut self) { ... }
}Expand description
A block-serving audio source: fill out (interleaved stereo L,R,L,R…) and
return the number of frames written. Runs indefinitely. This is the single
seam host output adapters target, so a cpal callback, an AudioWorklet, or a
Bevy source never depend on a concrete engine type.
Implementations overwrite the whole out buffer (silence where there is
nothing to play), so a caller may mix several sources through one scratch
buffer without re-zeroing.
Required Methods§
Provided Methods§
Sourcefn reset(&mut self)
fn reset(&mut self)
Rewind the source to its start (playback position / phase to zero).
Defaults to a no-op; a looping source overrides it so a transport can
restart it from the top. AdaptiveMusic::reset
calls this on each layer.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".