use crate::sounds::wrappers::Controllable;
use crate::sounds::wrappers::Wrapper;
use crate::sounds::SoundMixer;
use crate::NextSample;
use crate::Sound;
use super::backend_source::BackendSource;
pub struct Renderer {
mixer: Controllable<SoundMixer>,
}
impl Renderer {
pub(crate) fn new(mixer: Controllable<SoundMixer>) -> Self {
Renderer { mixer }
}
}
impl BackendSource for Renderer {
fn set_output_channel_count_and_sample_rate(
&mut self,
output_channel_count: u16,
output_sample_rate: u32,
) {
self.mixer
.inner_mut()
.set_output_channel_count_and_sample_rate(output_channel_count, output_sample_rate);
}
}
impl Sound for Renderer {
fn channel_count(&self) -> u16 {
self.mixer.channel_count()
}
fn sample_rate(&self) -> u32 {
self.mixer.sample_rate()
}
fn next_sample(&mut self) -> Result<NextSample, crate::Error> {
self.mixer.next_sample()
}
fn on_start_of_batch(&mut self) {
self.mixer.on_start_of_batch()
}
}