mirror of
https://github.com/librespot-org/librespot.git
synced 2025-01-17 17:34:04 +00:00
Fix audio file streaming
This commit is contained in:
parent
0cc4466245
commit
7fe13be564
1 changed files with 11 additions and 4 deletions
|
@ -96,6 +96,16 @@ async fn receive_data(
|
||||||
|
|
||||||
drop(request.streamer);
|
drop(request.streamer);
|
||||||
|
|
||||||
|
let bytes_remaining = request.length - actual_length;
|
||||||
|
if bytes_remaining > 0 {
|
||||||
|
{
|
||||||
|
let missing_range = Range::new(offset, bytes_remaining);
|
||||||
|
let mut download_status = shared.download_status.lock();
|
||||||
|
download_status.requested.subtract_range(&missing_range);
|
||||||
|
shared.cond.notify_all();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
shared
|
shared
|
||||||
.number_of_open_requests
|
.number_of_open_requests
|
||||||
.fetch_sub(1, Ordering::SeqCst);
|
.fetch_sub(1, Ordering::SeqCst);
|
||||||
|
@ -139,10 +149,7 @@ impl AudioFileFetch {
|
||||||
}
|
}
|
||||||
|
|
||||||
if offset + length > self.shared.file_size {
|
if offset + length > self.shared.file_size {
|
||||||
return Err(Error::out_of_range(format!(
|
length = self.shared.file_size - offset;
|
||||||
"Range {} +{} exceeds file size {}",
|
|
||||||
offset, length, self.shared.file_size
|
|
||||||
)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut ranges_to_request = RangeSet::new();
|
let mut ranges_to_request = RangeSet::new();
|
||||||
|
|
Loading…
Reference in a new issue