|
@@ -37,7 +37,7 @@ use librespot::connect::discovery::{discovery, DiscoveryStream};
|
|
|
use librespot::connect::spirc::{Spirc, SpircTask};
|
|
|
use librespot::playback::audio_backend::{self, Sink, BACKENDS};
|
|
|
use librespot::playback::config::{Bitrate, PlayerConfig};
|
|
|
-use librespot::playback::mixer::{self, Mixer};
|
|
|
+use librespot::playback::mixer::{self, Mixer, MixerConfig};
|
|
|
use librespot::playback::player::{Player, PlayerEvent};
|
|
|
|
|
|
mod player_event_handler;
|
|
@@ -90,12 +90,13 @@ struct Setup {
|
|
|
backend: fn(Option<String>) -> Box<Sink>,
|
|
|
device: Option<String>,
|
|
|
|
|
|
- mixer: fn(Option<String>) -> Box<Mixer>,
|
|
|
+ mixer: fn(Option<MixerConfig>) -> Box<Mixer>,
|
|
|
|
|
|
cache: Option<Cache>,
|
|
|
player_config: PlayerConfig,
|
|
|
session_config: SessionConfig,
|
|
|
connect_config: ConnectConfig,
|
|
|
+ mixer_config: MixerConfig,
|
|
|
credentials: Option<Credentials>,
|
|
|
enable_discovery: bool,
|
|
|
zeroconf_port: u16,
|
|
@@ -142,7 +143,25 @@ fn setup(args: &[String]) -> Setup {
|
|
|
"Audio device to use. Use '?' to list options if using portaudio",
|
|
|
"DEVICE",
|
|
|
)
|
|
|
- .optopt("", "mixer", "Mixer to use", "MIXER")
|
|
|
+ .optopt("", "mixer", "Mixer to use (Alsa or softmixer)", "MIXER")
|
|
|
+ .optopt(
|
|
|
+ "m",
|
|
|
+ "mixer-name",
|
|
|
+ "Alsa mixer name, e.g \"PCM\" or \"Master\". Defaults to 'PCM'",
|
|
|
+ "MIXER_NAME",
|
|
|
+ )
|
|
|
+ .optopt(
|
|
|
+ "",
|
|
|
+ "mixer-card",
|
|
|
+ "Alsa mixer card, e.g \"hw:0\" or similar from `aplay -l`. Defaults to 'default' ",
|
|
|
+ "MIXER_CARD",
|
|
|
+ )
|
|
|
+ .optopt(
|
|
|
+ "",
|
|
|
+ "mixer-index",
|
|
|
+ "Alsa mixer index, Index of the cards mixer. Defaults to 0",
|
|
|
+ "MIXER_INDEX",
|
|
|
+ )
|
|
|
.optopt(
|
|
|
"",
|
|
|
"initial-volume",
|
|
@@ -208,6 +227,12 @@ fn setup(args: &[String]) -> Setup {
|
|
|
let mixer_name = matches.opt_str("mixer");
|
|
|
let mixer = mixer::find(mixer_name.as_ref()).expect("Invalid mixer");
|
|
|
|
|
|
+ let mixer_config = MixerConfig {
|
|
|
+ card: matches.opt_str("mixer-card").unwrap_or(String::from("default")),
|
|
|
+ mixer: matches.opt_str("mixer-name").unwrap_or(String::from("PCM")),
|
|
|
+ index: matches.opt_str("mixer-index").map(|index| index.parse::<u32>().unwrap()).unwrap_or(0),
|
|
|
+ };
|
|
|
+
|
|
|
let use_audio_cache = !matches.opt_present("disable-audio-cache");
|
|
|
|
|
|
let cache = matches
|
|
@@ -324,6 +349,7 @@ fn setup(args: &[String]) -> Setup {
|
|
|
enable_discovery: enable_discovery,
|
|
|
zeroconf_port: zeroconf_port,
|
|
|
mixer: mixer,
|
|
|
+ mixer_config: mixer_config,
|
|
|
player_event_program: matches.opt_str("onevent"),
|
|
|
}
|
|
|
}
|
|
@@ -335,7 +361,8 @@ struct Main {
|
|
|
connect_config: ConnectConfig,
|
|
|
backend: fn(Option<String>) -> Box<Sink>,
|
|
|
device: Option<String>,
|
|
|
- mixer: fn(Option<String>) -> Box<Mixer>,
|
|
|
+ mixer: fn(Option<MixerConfig>) -> Box<Mixer>,
|
|
|
+ mixer_config: MixerConfig,
|
|
|
handle: Handle,
|
|
|
|
|
|
discovery: Option<DiscoveryStream>,
|
|
@@ -362,6 +389,7 @@ impl Main {
|
|
|
backend: setup.backend,
|
|
|
device: setup.device,
|
|
|
mixer: setup.mixer,
|
|
|
+ mixer_config: setup.mixer_config,
|
|
|
|
|
|
connect: Box::new(futures::future::empty()),
|
|
|
discovery: None,
|
|
@@ -422,8 +450,8 @@ impl Future for Main {
|
|
|
|
|
|
if let Async::Ready(session) = self.connect.poll().unwrap() {
|
|
|
self.connect = Box::new(futures::future::empty());
|
|
|
- let device = self.device.clone();
|
|
|
- let mixer = (self.mixer)(device);
|
|
|
+ let mixer_config = self.mixer_config.clone();
|
|
|
+ let mixer = (self.mixer)(Some(mixer_config));
|
|
|
let player_config = self.player_config.clone();
|
|
|
let connect_config = self.connect_config.clone();
|
|
|
|