mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
Somewhat uniform coding style might help myself to better understand Rust :-)
This commit is contained in:
parent
f3bb85c33a
commit
12487966b2
2 changed files with 15 additions and 22 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -2,3 +2,5 @@ target
|
||||||
.cargo
|
.cargo
|
||||||
spotify_appkey.key
|
spotify_appkey.key
|
||||||
.vagrant/
|
.vagrant/
|
||||||
|
.project
|
||||||
|
.history
|
35
src/main.rs
35
src/main.rs
|
@ -135,30 +135,21 @@ fn setup(args: &[String]) -> Setup {
|
||||||
let mixer = mixer::find(mixer_name.as_ref())
|
let mixer = mixer::find(mixer_name.as_ref())
|
||||||
.expect("Invalid mixer");
|
.expect("Invalid mixer");
|
||||||
|
|
||||||
let initial_volume: i32;
|
let initial_volume = matches
|
||||||
if matches.opt_present("initial-volume") && matches.opt_str("initial-volume").unwrap().parse::<i32>().is_ok() {
|
.opt_str("initial-volume")
|
||||||
let iv = matches.opt_str("initial-volume").unwrap().parse::<i32>().unwrap();
|
.map(|volume| {
|
||||||
match iv {
|
let volume = volume.parse::<i32>().unwrap();
|
||||||
iv if iv >= 0 && iv <= 100 => { initial_volume = iv * 0xFFFF / 100 }
|
if volume < 0 || volume > 100 {
|
||||||
_ => {
|
panic!("Initial volume must be in the range 0-100");
|
||||||
debug!("Volume needs to be a value from 0-100; set volume level to 50%");
|
|
||||||
initial_volume = 0x8000;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
initial_volume = 0x8000;
|
|
||||||
}
|
}
|
||||||
|
volume * 0xFFFF / 100
|
||||||
|
})
|
||||||
|
.unwrap_or(0x8000);
|
||||||
|
|
||||||
let zeroconf_port: u16;
|
let zeroconf_port =
|
||||||
if matches.opt_present("zeroconf-port") && matches.opt_str("zeroconf-port").unwrap().parse::<u16>().is_ok() {
|
matches.opt_str("zeroconf-port")
|
||||||
let z = matches.opt_str("zeroconf-port").unwrap().parse::<u16>().unwrap();
|
.map(|port| port.parse::<u16>().unwrap())
|
||||||
match z {
|
.unwrap_or(0);
|
||||||
z if z >= 1024 => { zeroconf_port = z }
|
|
||||||
_ => { zeroconf_port = 0 }
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
zeroconf_port = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
let name = matches.opt_str("name").unwrap();
|
let name = matches.opt_str("name").unwrap();
|
||||||
let use_audio_cache = !matches.opt_present("disable-audio-cache");
|
let use_audio_cache = !matches.opt_present("disable-audio-cache");
|
||||||
|
|
Loading…
Reference in a new issue