Describe new mixer-card getopts behavior

Also remove some other getopts and string changes to a separate PR.
This commit is contained in:
Roderick van Domburg 2021-05-25 20:17:28 +02:00
parent eca505c387
commit 9efd886e91
No known key found for this signature in database
GPG key ID: FE2585E713F9F30A

View file

@ -250,13 +250,13 @@ fn get_setup(args: &[String]) -> Setup {
.optopt( .optopt(
"m", "m",
"mixer-name", "mixer-name",
"Alsa mixer name, e.g \"PCM\" or \"Master\". Defaults to 'PCM'", "Alsa mixer control, e.g. 'PCM' or 'Master'. Defaults to 'PCM'.",
"MIXER_NAME", "MIXER_NAME",
) )
.optopt( .optopt(
"", "",
"mixer-card", "mixer-card",
"Alsa mixer card, e.g \"hw:0\" or similar from `aplay -l`. Defaults to 'default' ", "Alsa mixer card, e.g 'hw:0' or similar from `aplay -l`. Defaults to DEVICE if specified, 'default' otherwise.",
"MIXER_CARD", "MIXER_CARD",
) )
.optopt( .optopt(
@ -268,7 +268,7 @@ fn get_setup(args: &[String]) -> Setup {
.optopt( .optopt(
"", "",
"initial-volume", "initial-volume",
"Initial volume in %, once connected (must be from 0 to 100)", "Initial volume (%) once connected {0..100}. Defaults to 50 for softvol and for Alsa mixer the current volume.",
"VOLUME", "VOLUME",
) )
.optopt( .optopt(
@ -327,13 +327,13 @@ fn get_setup(args: &[String]) -> Setup {
.optopt( .optopt(
"", "",
"volume-ctrl", "volume-ctrl",
"Volume control type - [cubic, fixed, linear, log]. Default is log.", "Volume control type {cubic|fixed|linear|log}. Defaults to log.",
"VOLUME_CTRL" "VOLUME_CTRL"
) )
.optopt( .optopt(
"", "",
"volume-range", "volume-range",
"Range of the volume control (dB). Defaults to 60 for softvol and for alsa what the mixer supports.", "Range of the volume control (dB). Defaults to 60 for softvol and for Alsa mixer what the mixer supports.",
"RANGE", "RANGE",
) )
.optflag( .optflag(
@ -423,7 +423,7 @@ fn get_setup(args: &[String]) -> Setup {
}); });
if volume_range < 0.0 { if volume_range < 0.0 {
// User might have specified range as minimum dB volume. // User might have specified range as minimum dB volume.
volume_range *= -1.0; volume_range = -volume_range;
warn!( warn!(
"Please enter positive volume ranges only, assuming {:.2} dB", "Please enter positive volume ranges only, assuming {:.2} dB",
volume_range volume_range
@ -546,15 +546,15 @@ fn get_setup(args: &[String]) -> Setup {
match Url::parse(&s) { match Url::parse(&s) {
Ok(url) => { Ok(url) => {
if url.host().is_none() || url.port_or_known_default().is_none() { if url.host().is_none() || url.port_or_known_default().is_none() {
panic!("Invalid proxy url, only URLs on the format \"http://host:port\" are allowed"); panic!("Invalid proxy url, only urls on the format \"http://host:port\" are allowed");
} }
if url.scheme() != "http" { if url.scheme() != "http" {
panic!("Only insecure http:// proxies are supported"); panic!("Only unsecure http:// proxies are supported");
} }
url url
}, },
Err(err) => panic!("Invalid proxy URL: {}, only URLs in the format \"http://host:port\" are allowed", err) Err(err) => panic!("Invalid proxy url: {}, only urls on the format \"http://host:port\" are allowed", err)
} }
}, },
), ),
@ -575,8 +575,8 @@ fn get_setup(args: &[String]) -> Setup {
let normalisation_method = matches let normalisation_method = matches
.opt_str("normalisation-method") .opt_str("normalisation-method")
.as_ref() .as_ref()
.map(|gain_type| { .map(|method| {
NormalisationMethod::from_str(gain_type).expect("Invalid normalisation method") NormalisationMethod::from_str(method).expect("Invalid normalisation method")
}) })
.unwrap_or_default(); .unwrap_or_default();
let normalisation_type = matches let normalisation_type = matches