mirror of
https://github.com/ivabus/speakersafetyd
synced 2024-11-22 08:15:07 +03:00
main: Implement main magic unlock control
Signed-off-by: Hector Martin <marcan@marcan.st>
This commit is contained in:
parent
6cb6c45083
commit
3660fd85d8
1 changed files with 12 additions and 0 deletions
12
src/main.rs
12
src/main.rs
|
@ -26,6 +26,8 @@ static VERSION: &str = "0.0.1";
|
|||
|
||||
const DEFAULT_CONFIG_PATH: &str = "share/speakersafetyd";
|
||||
|
||||
const UNLOCK_MAGIC: i32 = 0xdec1be15u32 as i32;
|
||||
|
||||
/// Simple program to greet a person
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(version, about, long_about = None)]
|
||||
|
@ -152,6 +154,14 @@ fn main() {
|
|||
);
|
||||
let mut sample_rate = sample_rate_elem.read_int(&ctl);
|
||||
|
||||
let mut unlock_elem = types::Elem::new(
|
||||
"Speaker Volume Unlock".to_string(),
|
||||
&ctl,
|
||||
alsa::ctl::ElemType::Integer,
|
||||
);
|
||||
|
||||
unlock_elem.write_int(&ctl, UNLOCK_MAGIC);
|
||||
|
||||
loop {
|
||||
// Block while we're reading into the buffer
|
||||
io.readi(&mut buf).unwrap();
|
||||
|
@ -182,5 +192,7 @@ fn main() {
|
|||
group.gain = gain;
|
||||
}
|
||||
}
|
||||
|
||||
unlock_elem.write_int(&ctl, UNLOCK_MAGIC);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue