diff options
author | wm4 <wm4@nowhere> | 2015-07-22 23:30:05 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-07-22 23:30:05 +0200 |
commit | 63d112746dcf6b3c62b16cfd50eee91128054ce2 (patch) | |
tree | 37301a384927ad07f26f9008a9ed4aacc6b90367 /stream/cache.c | |
parent | aeb99f27180ad4e2fa915f21c66ad1bd28643940 (diff) | |
download | mpv-63d112746dcf6b3c62b16cfd50eee91128054ce2.tar.bz2 mpv-63d112746dcf6b3c62b16cfd50eee91128054ce2.tar.xz |
cache: fix backbuffer logic
Currently, this is perfectly equivalent, because back_size is hardcoded
to buffer_size/2. But this fixes the logic for the case the back_size
can be configured freely.
Diffstat (limited to 'stream/cache.c')
-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); |