Skip to content

Commit 4c00b19

Browse files
committed
Fix Alsa mixer
1 parent 68bec41 commit 4c00b19

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

src/main.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ fn get_setup(args: &[String]) -> Setup {
205205
const FORMAT: &str = "format";
206206
const HELP: &str = "h";
207207
const INITIAL_VOLUME: &str = "initial-volume";
208+
const MIXER_TYPE: &str = "mixer";
208209
const MIXER_CARD: &str = "mixer-card";
209210
const MIXER_INDEX: &str = "mixer-index";
210211
const MIXER_NAME: &str = "mixer-name";
@@ -295,7 +296,7 @@ fn get_setup(args: &[String]) -> Setup {
295296
"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.",
296297
"DITHER",
297298
)
298-
.optopt("", "mixer", "Mixer to use {alsa|softvol}.", "MIXER")
299+
.optopt("", MIXER_TYPE, "Mixer to use {alsa|softvol}.", "MIXER")
299300
.optopt(
300301
"m",
301302
MIXER_NAME,
@@ -454,8 +455,8 @@ fn get_setup(args: &[String]) -> Setup {
454455
exit(0);
455456
}
456457

457-
let mixer_name = matches.opt_str(MIXER_NAME);
458-
let mixer = mixer::find(mixer_name.as_deref()).expect("Invalid mixer");
458+
let mixer_type = matches.opt_str(MIXER_TYPE);
459+
let mixer = mixer::find(mixer_type.as_deref()).expect("Invalid mixer");
459460

460461
let mixer_config = {
461462
let card = matches.opt_str(MIXER_CARD).unwrap_or_else(|| {
@@ -475,7 +476,7 @@ fn get_setup(args: &[String]) -> Setup {
475476
let mut volume_range = matches
476477
.opt_str(VOLUME_RANGE)
477478
.map(|range| range.parse::<f64>().unwrap())
478-
.unwrap_or_else(|| match mixer_name.as_deref() {
479+
.unwrap_or_else(|| match mixer_type.as_deref() {
479480
#[cfg(feature = "alsa-backend")]
480481
Some(AlsaMixer::NAME) => 0.0, // let Alsa query the control
481482
_ => VolumeCtrl::DEFAULT_DB_RANGE,
@@ -563,7 +564,7 @@ fn get_setup(args: &[String]) -> Setup {
563564
}
564565
(volume as f32 / 100.0 * VolumeCtrl::MAX_VOLUME as f32) as u16
565566
})
566-
.or_else(|| match mixer_name.as_deref() {
567+
.or_else(|| match mixer_type.as_deref() {
567568
#[cfg(feature = "alsa-backend")]
568569
Some(AlsaMixer::NAME) => None,
569570
_ => cache.as_ref().and_then(Cache::volume),

0 commit comments

Comments
 (0)