mirror of
https://github.com/ivabus/speakersafetyd
synced 2024-11-22 08:15:07 +03:00
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:
parent
83a53ba99f
commit
91e7c14b8e
1 changed files with 10 additions and 4 deletions
14
src/types.rs
14
src/types.rs
|
@ -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,
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in a new issue