Fix streaming on slow connections

This commit is contained in:
Roderick van Domburg 2022-01-10 21:19:47 +01:00
parent c067c1524f
commit 0b7ccc803c
No known key found for this signature in database
GPG key ID: A9EF5222A26F0451

View file

@ -61,6 +61,10 @@ impl From<AudioFileError> for Error {
/// Note: smaller requests can happen if part of the block is downloaded already. /// Note: smaller requests can happen if part of the block is downloaded already.
pub const MINIMUM_DOWNLOAD_SIZE: usize = 1024 * 128; pub const MINIMUM_DOWNLOAD_SIZE: usize = 1024 * 128;
/// The minimum network throughput that we expect. Together with the minimum download size,
/// this will determine the time we will wait for a response.
pub const MINIMUM_THROUGHPUT: usize = 8192;
/// The amount of data that is requested when initially opening a file. /// The amount of data that is requested when initially opening a file.
/// Note: if the file is opened to play from the beginning, the amount of data to /// Note: if the file is opened to play from the beginning, the amount of data to
/// read ahead is requested in addition to this amount. If the file is opened to seek to /// read ahead is requested in addition to this amount. If the file is opened to seek to
@ -119,7 +123,8 @@ pub const FAST_PREFETCH_THRESHOLD_FACTOR: f32 = 1.5;
pub const MAX_PREFETCH_REQUESTS: usize = 4; pub const MAX_PREFETCH_REQUESTS: usize = 4;
/// The time we will wait to obtain status updates on downloading. /// The time we will wait to obtain status updates on downloading.
pub const DOWNLOAD_TIMEOUT: Duration = Duration::from_secs(1); pub const DOWNLOAD_TIMEOUT: Duration =
Duration::from_secs((MINIMUM_DOWNLOAD_SIZE / MINIMUM_THROUGHPUT) as u64);
pub enum AudioFile { pub enum AudioFile {
Cached(fs::File), Cached(fs::File),