diff --git a/playback/src/mixer/mod.rs b/playback/src/mixer/mod.rs index f19a86614..fdbc6e0cf 100644 --- a/playback/src/mixer/mod.rs +++ b/playback/src/mixer/mod.rs @@ -39,12 +39,16 @@ impl Default for MixerConfig { pub mod softmixer; use self::softmixer::SoftMixer; +pub mod nullmixer; +use self::nullmixer::NullMixer; + fn mk_sink(device: Option) -> Box { Box::new(M::open(device)) } pub fn find>(name: Option) -> Option) -> Box> { match name.as_ref().map(AsRef::as_ref) { + Some("null") => Some(mk_sink::), None | Some("softvol") => Some(mk_sink::), #[cfg(feature = "alsa-backend")] Some("alsa") => Some(mk_sink::), diff --git a/playback/src/mixer/nullmixer.rs b/playback/src/mixer/nullmixer.rs new file mode 100644 index 000000000..d2a993284 --- /dev/null +++ b/playback/src/mixer/nullmixer.rs @@ -0,0 +1,29 @@ +use std::sync::Arc; +use std::sync::atomic::{AtomicUsize, Ordering}; + +use super::AudioFilter; +use super::{Mixer, MixerConfig}; + +#[derive(Clone)] +pub struct NullMixer { + volume: Arc, +} + +impl Mixer for NullMixer { + fn open(_: Option) -> NullMixer { + NullMixer { + volume: Arc::new(AtomicUsize::new(0xFFFF)), + } + } + fn start(&self) {} + fn stop(&self) {} + fn volume(&self) -> u16 { + self.volume.load(Ordering::Relaxed) as u16 + } + fn set_volume(&self, volume: u16) { + self.volume.store(volume as usize, Ordering::Relaxed); + } + fn get_audio_filter(&self) -> Option> { + None + } +}