mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
Small refactoring
This commit is contained in:
parent
3446864838
commit
f67ceb5f6d
1 changed files with 9 additions and 14 deletions
|
@ -651,18 +651,14 @@ impl PlayerTrackLoader {
|
||||||
FileFormat::OGG_VORBIS_96,
|
FileFormat::OGG_VORBIS_96,
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
let format = formats
|
|
||||||
.iter()
|
|
||||||
.find(|format| audio.files.contains_key(format))
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let file_id = match audio.files.get(&format) {
|
let (format, file_id) = formats
|
||||||
Some(&file_id) => file_id,
|
.iter()
|
||||||
None => {
|
.find_map(|format| Some((format, *audio.files.get(&format)?)))
|
||||||
warn!("<{}> in not available in format {:?}", audio.name, format);
|
.or_else(|| {
|
||||||
return None;
|
warn!("<{}> is not available in any supported format", audio.name);
|
||||||
}
|
None
|
||||||
};
|
})?;
|
||||||
|
|
||||||
let bytes_per_second = self.stream_data_rate(*format);
|
let bytes_per_second = self.stream_data_rate(*format);
|
||||||
let play_from_beginning = position_ms == 0;
|
let play_from_beginning = position_ms == 0;
|
||||||
|
@ -739,9 +735,8 @@ impl PlayerTrackLoader {
|
||||||
};
|
};
|
||||||
|
|
||||||
if position_ms != 0 {
|
if position_ms != 0 {
|
||||||
match decoder.seek(position_ms as i64) {
|
if let Err(err) = decoder.seek(position_ms as i64) {
|
||||||
Ok(_) => (),
|
error!("Vorbis error: {}", err);
|
||||||
Err(err) => error!("Vorbis error: {:?}", err),
|
|
||||||
}
|
}
|
||||||
stream_loader_controller.set_stream_mode();
|
stream_loader_controller.set_stream_mode();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue