librespot/src/mixer/mod.rs

29 lines
677 B
Rust
Raw Normal View History

pub trait Mixer : Send {
fn open() -> Self where Self: Sized;
fn start(&self);
fn stop(&self);
fn set_volume(&self, volume: u16);
fn volume(&self) -> u16;
2017-01-27 13:20:31 +00:00
fn get_audio_filter(&self) -> Option<Box<AudioFilter + Send>> {
None
}
}
2017-01-27 13:20:31 +00:00
pub trait AudioFilter {
2017-02-21 21:49:45 +00:00
fn modify_stream(&self, data: &mut [i16]);
2017-01-25 21:49:18 +00:00
}
2017-02-21 21:49:45 +00:00
pub mod softmixer;
use self::softmixer::SoftMixer;
fn mk_sink<M: Mixer + 'static>() -> Box<Mixer> {
Box::new(M::open())
}
pub fn find<T: AsRef<str>>(name: Option<T>) -> Option<fn() -> Box<Mixer>> {
2017-02-21 21:49:45 +00:00
match name.as_ref().map(AsRef::as_ref) {
None | Some("softvol") => Some(mk_sink::<SoftMixer>),
2017-02-21 21:49:45 +00:00
_ => None,
}
}