1
0
Fork 0
mirror of https://github.com/librespot-org/librespot.git synced 2025-10-06 03:50:06 +02:00

Fix error hitting play when loading

Further changes:

 - Improve some debug and trace messages

 - Default to streaming download strategy

 - Synchronize mixer volume on loading play

 - Use default normalisation values when the file position isn't
   exactly what we need it to be

 - Update track position only when the decoder reports a
   successful seek
This commit is contained in:
Roderick van Domburg 2021-12-28 23:46:37 +01:00
parent 0f78fc277e
commit 332f9f04b1
No known key found for this signature in database
GPG key ID: A9EF5222A26F0451
3 changed files with 116 additions and 65 deletions

View file

@ -341,6 +341,8 @@ impl AudioFile {
let session_ = session.clone();
session.spawn(complete_rx.map_ok(move |mut file| {
debug!("Downloading file {} complete", file_id);
if let Some(cache) = session_.cache() {
if let Some(cache_id) = cache.file(file_id) {
if let Err(e) = cache.save_file(file_id, &mut file) {
@ -349,8 +351,6 @@ impl AudioFile {
debug!("File {} cached to {:?}", file_id, cache_id);
}
}
debug!("Downloading file {} complete", file_id);
}
}));
@ -399,10 +399,12 @@ impl AudioFileStreaming {
INITIAL_DOWNLOAD_SIZE
};
trace!("Streaming {}", file_id);
let cdn_url = CdnUrl::new(file_id).resolve_audio(&session).await?;
if let Ok(url) = cdn_url.try_get_url() {
trace!("Streaming from {}", url);
}
let mut streamer = session
.spclient()
.stream_from_cdn(&cdn_url, 0, download_size)?;
@ -438,7 +440,7 @@ impl AudioFileStreaming {
requested: RangeSet::new(),
downloaded: RangeSet::new(),
}),
download_strategy: Mutex::new(DownloadStrategy::RandomAccess()), // start with random access mode until someone tells us otherwise
download_strategy: Mutex::new(DownloadStrategy::Streaming()),
number_of_open_requests: AtomicUsize::new(0),
ping_time_ms: AtomicUsize::new(0),
read_position: AtomicUsize::new(0),