From 4c00b19c29d1c29a528e332113f20a0ce9cdcb34 Mon Sep 17 00:00:00 2001 From: Roderick van Domburg Date: Fri, 9 Jul 2021 20:12:44 +0200 Subject: [PATCH] Fix Alsa mixer --- src/main.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index a3687aaa..aa04d0d4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -205,6 +205,7 @@ fn get_setup(args: &[String]) -> Setup { const FORMAT: &str = "format"; const HELP: &str = "h"; const INITIAL_VOLUME: &str = "initial-volume"; + const MIXER_TYPE: &str = "mixer"; const MIXER_CARD: &str = "mixer-card"; const MIXER_INDEX: &str = "mixer-index"; const MIXER_NAME: &str = "mixer-name"; @@ -295,7 +296,7 @@ fn get_setup(args: &[String]) -> Setup { "Specify the dither algorithm to use - [none, gpdf, tpdf, tpdf_hp]. Defaults to 'tpdf' for formats S16, S24, S24_3 and 'none' for other formats.", "DITHER", ) - .optopt("", "mixer", "Mixer to use {alsa|softvol}.", "MIXER") + .optopt("", MIXER_TYPE, "Mixer to use {alsa|softvol}.", "MIXER") .optopt( "m", MIXER_NAME, @@ -454,8 +455,8 @@ fn get_setup(args: &[String]) -> Setup { exit(0); } - let mixer_name = matches.opt_str(MIXER_NAME); - let mixer = mixer::find(mixer_name.as_deref()).expect("Invalid mixer"); + let mixer_type = matches.opt_str(MIXER_TYPE); + let mixer = mixer::find(mixer_type.as_deref()).expect("Invalid mixer"); let mixer_config = { let card = matches.opt_str(MIXER_CARD).unwrap_or_else(|| { @@ -475,7 +476,7 @@ fn get_setup(args: &[String]) -> Setup { let mut volume_range = matches .opt_str(VOLUME_RANGE) .map(|range| range.parse::().unwrap()) - .unwrap_or_else(|| match mixer_name.as_deref() { + .unwrap_or_else(|| match mixer_type.as_deref() { #[cfg(feature = "alsa-backend")] Some(AlsaMixer::NAME) => 0.0, // let Alsa query the control _ => VolumeCtrl::DEFAULT_DB_RANGE, @@ -563,7 +564,7 @@ fn get_setup(args: &[String]) -> Setup { } (volume as f32 / 100.0 * VolumeCtrl::MAX_VOLUME as f32) as u16 }) - .or_else(|| match mixer_name.as_deref() { + .or_else(|| match mixer_type.as_deref() { #[cfg(feature = "alsa-backend")] Some(AlsaMixer::NAME) => None, _ => cache.as_ref().and_then(Cache::volume),