Fix audio file streaming

This commit is contained in:
Roderick van Domburg 2022-01-14 23:24:43 +01:00
parent 0cc4466245
commit 7fe13be564
No known key found for this signature in database
GPG key ID: A9EF5222A26F0451

View file

@ -96,6 +96,16 @@ async fn receive_data(
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
.number_of_open_requests
.fetch_sub(1, Ordering::SeqCst);
@ -139,10 +149,7 @@ impl AudioFileFetch {
}
if offset + length > self.shared.file_size {
return Err(Error::out_of_range(format!(
"Range {} +{} exceeds file size {}",
offset, length, self.shared.file_size
)));
length = self.shared.file_size - offset;
}
let mut ranges_to_request = RangeSet::new();