diff options
-rw-r--r-- | stream/cache.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/stream/cache.c b/stream/cache.c index fc4b2761da..da8c841571 100644 --- a/stream/cache.c +++ b/stream/cache.c @@ -215,11 +215,12 @@ static bool cache_fill(struct priv *s) // number of buffer bytes which should be preserved in backwards direction int64_t back = MPCLAMP(read - s->min_filepos, 0, s->back_size); - // limit maximum readahead to half the total buffer size, to ensure that - // we don't stall the network when starting a file (not reading new data - // by preserving the backbuffer) - unless the whole file fits in the cache + // limit maximum readahead so that the backbuffer space is reserved, even + // if the backbuffer is not used. limit it to ensure that we don't stall the + // network when starting a file, or we wouldn't download new data until we + // get new free space again. (unless everything fits in the cache.) if (s->stream_size > s->buffer_size) - back = MPMAX(back, s->buffer_size / 2); + back = MPMAX(back, s->back_size); // number of buffer bytes that are valid and can be read int64_t newb = FFMAX(s->max_filepos - read, 0); |