mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
rustfmt
This commit is contained in:
parent
db0e4a0422
commit
e550b7f729
1 changed files with 17 additions and 9 deletions
|
@ -83,7 +83,6 @@ const MAX_PREFETCH_REQUESTS: usize = 4;
|
||||||
// for playback to be delayed leading to a buffer underrun. This limit has the effect that a new
|
// for playback to be delayed leading to a buffer underrun. This limit has the effect that a new
|
||||||
// pre-fetch request is only sent if less than MAX_PREFETCH_REQUESTS are pending.
|
// pre-fetch request is only sent if less than MAX_PREFETCH_REQUESTS are pending.
|
||||||
|
|
||||||
|
|
||||||
pub enum AudioFile {
|
pub enum AudioFile {
|
||||||
Cached(fs::File),
|
Cached(fs::File),
|
||||||
Streaming(AudioFileStreaming),
|
Streaming(AudioFileStreaming),
|
||||||
|
@ -758,7 +757,7 @@ impl AudioFileFetch {
|
||||||
let offset = range.start;
|
let offset = range.start;
|
||||||
let length = min(range.length, bytes_to_go);
|
let length = min(range.length, bytes_to_go);
|
||||||
self.download_range(offset, length);
|
self.download_range(offset, length);
|
||||||
requests_to_go -=1;
|
requests_to_go -= 1;
|
||||||
bytes_to_go -= length;
|
bytes_to_go -= length;
|
||||||
} else if !missing_data.is_empty() {
|
} else if !missing_data.is_empty() {
|
||||||
// ok, the tail is downloaded, download something fom the beginning.
|
// ok, the tail is downloaded, download something fom the beginning.
|
||||||
|
@ -766,7 +765,7 @@ impl AudioFileFetch {
|
||||||
let offset = range.start;
|
let offset = range.start;
|
||||||
let length = min(range.length, bytes_to_go);
|
let length = min(range.length, bytes_to_go);
|
||||||
self.download_range(offset, length);
|
self.download_range(offset, length);
|
||||||
requests_to_go -=1;
|
requests_to_go -= 1;
|
||||||
bytes_to_go -= length;
|
bytes_to_go -= length;
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
|
@ -909,11 +908,12 @@ impl Future for AudioFileFetch {
|
||||||
}
|
}
|
||||||
|
|
||||||
if let DownloadStrategy::Streaming() = self.get_download_strategy() {
|
if let DownloadStrategy::Streaming() = self.get_download_strategy() {
|
||||||
|
let number_of_open_requests =
|
||||||
|
self.shared.number_of_open_requests.load(atomic::Ordering::SeqCst);
|
||||||
|
let max_requests_to_send =
|
||||||
|
MAX_PREFETCH_REQUESTS - min(MAX_PREFETCH_REQUESTS, number_of_open_requests);
|
||||||
|
|
||||||
let number_of_open_requests = self.shared.number_of_open_requests.load(atomic::Ordering::SeqCst);
|
if max_requests_to_send > 0 {
|
||||||
let max_requests_to_send = MAX_PREFETCH_REQUESTS - min(MAX_PREFETCH_REQUESTS, number_of_open_requests);
|
|
||||||
|
|
||||||
if (max_requests_to_send > 0) {
|
|
||||||
let bytes_pending: usize = {
|
let bytes_pending: usize = {
|
||||||
let download_status = self.shared.download_status.lock().unwrap();
|
let download_status = self.shared.download_status.lock().unwrap();
|
||||||
download_status.requested.minus(&download_status.downloaded).len()
|
download_status.requested.minus(&download_status.downloaded).len()
|
||||||
|
@ -930,7 +930,10 @@ impl Future for AudioFileFetch {
|
||||||
);
|
);
|
||||||
|
|
||||||
if bytes_pending < desired_pending_bytes {
|
if bytes_pending < desired_pending_bytes {
|
||||||
self.pre_fetch_more_data(desired_pending_bytes - bytes_pending, max_requests_to_send);
|
self.pre_fetch_more_data(
|
||||||
|
desired_pending_bytes - bytes_pending,
|
||||||
|
max_requests_to_send,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1009,7 +1012,12 @@ impl Read for AudioFileStreaming {
|
||||||
let read_len = try!(self.read_file.read(&mut output[..read_len]));
|
let read_len = try!(self.read_file.read(&mut output[..read_len]));
|
||||||
|
|
||||||
if download_message_printed {
|
if download_message_printed {
|
||||||
debug!("Read at postion {} completed. {} bytes returned, {} bytes were requested.", offset, read_len, output.len());
|
debug!(
|
||||||
|
"Read at postion {} completed. {} bytes returned, {} bytes were requested.",
|
||||||
|
offset,
|
||||||
|
read_len,
|
||||||
|
output.len()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.position += read_len as u64;
|
self.position += read_len as u64;
|
||||||
|
|
Loading…
Reference in a new issue