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 {
// TODO: implement turning on V/ISENSE
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(
name.to_owned() + " " + &globals.ctl_vsense,
prefix.clone() + &globals.ctl_vsense,
card,
alsa::ctl::ElemType::Boolean,
);
@ -91,7 +97,7 @@ impl Mixer {
assert!(vs.val.get_boolean(0).unwrap());
let mut is = Elem::new(
name.to_owned() + " " + &globals.ctl_isense,
prefix.clone() + &globals.ctl_isense,
card,
alsa::ctl::ElemType::Boolean,
);
@ -104,12 +110,12 @@ impl Mixer {
Mixer {
drv: name.to_owned(),
level: Elem::new(
name.to_owned() + " " + &globals.ctl_volume,
prefix.clone() + &globals.ctl_volume,
card,
alsa::ctl::ElemType::Integer,
),
amp_gain: Elem::new(
name.to_owned() + " " + &globals.ctl_amp_gain,
prefix + &globals.ctl_amp_gain,
card,
alsa::ctl::ElemType::Integer,
),