mirror of
https://github.com/librespot-org/librespot.git
synced 2025-10-04 02:09:26 +02:00
added comments and edited README
This commit is contained in:
parent
94e4cd853a
commit
de2b4cc8e3
2 changed files with 8 additions and 2 deletions
|
@ -135,27 +135,32 @@ fn setup(args: &[String]) -> Setup {
|
|||
let mixer = mixer::find(mixer_name.as_ref())
|
||||
.expect("Invalid mixer");
|
||||
let initial_volume;
|
||||
// check if initial-volume argument is present
|
||||
if matches.opt_present("initial-volume"){
|
||||
// check if value is a number
|
||||
if matches.opt_str("initial-volume").unwrap().parse::<i32>().is_ok(){
|
||||
// check if value is in [0-100] range, otherwise put the bound values
|
||||
if matches.opt_str("initial-volume").unwrap().parse::<i32>().unwrap() < 0 {
|
||||
initial_volume = 0 as i32;
|
||||
}
|
||||
else if matches.opt_str("initial-volume").unwrap().parse::<i32>().unwrap() > 100{
|
||||
initial_volume = 0xFFFF as i32;
|
||||
}
|
||||
// checks ok
|
||||
else{
|
||||
initial_volume = matches.opt_str("initial-volume").unwrap().parse::<i32>().unwrap()* 0xFFFF as i32 / 100 ;
|
||||
}
|
||||
|
||||
}
|
||||
// if value is not a number use default value (50%)
|
||||
else {
|
||||
initial_volume = 0x8000 as i32;
|
||||
}
|
||||
}
|
||||
// if argument not present use default values (50%)
|
||||
else{
|
||||
initial_volume = 0x8000 as i32;
|
||||
}
|
||||
info!("Volume \"{}\" !", initial_volume);
|
||||
debug!("Volume \"{}\" !", initial_volume);
|
||||
|
||||
let name = matches.opt_str("name").unwrap();
|
||||
let use_audio_cache = !matches.opt_present("disable-audio-cache");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue