types: Do not prefix speaker name "Mono"

For single-speaker devices, there is no control prefix. So treat the
special name "Mono" as a null prefix in that case.

Signed-off-by: Hector Martin <marcan@marcan.st>
This commit is contained in:
Hector Martin 2023-10-28 02:51:45 +09:00
parent 83a53ba99f
commit 91e7c14b8e

View file

@ -79,8 +79,14 @@ struct Mixer {
impl Mixer { impl Mixer {
// TODO: implement turning on V/ISENSE // TODO: implement turning on V/ISENSE
fn new(name: &str, card: &Ctl, globals: &Globals) -> Mixer { fn new(name: &str, card: &Ctl, globals: &Globals) -> Mixer {
let prefix = if name == "Mono" {
"".to_string()
} else {
name.to_owned() + " "
};
let mut vs = Elem::new( let mut vs = Elem::new(
name.to_owned() + " " + &globals.ctl_vsense, prefix.clone() + &globals.ctl_vsense,
card, card,
alsa::ctl::ElemType::Boolean, alsa::ctl::ElemType::Boolean,
); );
@ -91,7 +97,7 @@ impl Mixer {
assert!(vs.val.get_boolean(0).unwrap()); assert!(vs.val.get_boolean(0).unwrap());
let mut is = Elem::new( let mut is = Elem::new(
name.to_owned() + " " + &globals.ctl_isense, prefix.clone() + &globals.ctl_isense,
card, card,
alsa::ctl::ElemType::Boolean, alsa::ctl::ElemType::Boolean,
); );
@ -104,12 +110,12 @@ impl Mixer {
Mixer { Mixer {
drv: name.to_owned(), drv: name.to_owned(),
level: Elem::new( level: Elem::new(
name.to_owned() + " " + &globals.ctl_volume, prefix.clone() + &globals.ctl_volume,
card, card,
alsa::ctl::ElemType::Integer, alsa::ctl::ElemType::Integer,
), ),
amp_gain: Elem::new( amp_gain: Elem::new(
name.to_owned() + " " + &globals.ctl_amp_gain, prefix + &globals.ctl_amp_gain,
card, card,
alsa::ctl::ElemType::Integer, alsa::ctl::ElemType::Integer,
), ),