From 6ac98c042f16d6b6a6f370905345678b42adf9e8 Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 9 Apr 2014 19:07:50 +0200 Subject: cache: minor simplification The only difference is that the MP_DBG message is not printed anymore if the current user read position is outside of the current cache range. (In order to handle seek_limit==0 gracefully in the normal case of linear reading, change the comparison from ">=" to ">".) --- stream/cache.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/stream/cache.c b/stream/cache.c index c992764522..6333eeb0e9 100644 --- a/stream/cache.c +++ b/stream/cache.c @@ -240,19 +240,15 @@ static bool cache_fill(struct priv *s) int64_t read = s->read_filepos; int len; - if (read < s->min_filepos || read > s->max_filepos) { - // seek... - MP_DBG(s, "Out of boundaries... seeking to %" PRId64 " \n", read); - // drop cache contents only if seeking backward or too much fwd. - // This is also done for on-disk files, since it loses the backseek cache. - // That in turn can cause major bandwidth increase and performance - // issues with e.g. mov or badly interleaved files - if (read < s->min_filepos || read >= s->max_filepos + s->seek_limit) { - MP_VERBOSE(s, "Dropping cache at pos %"PRId64", " + // drop cache contents only if seeking backward or too much fwd. + // This is also done for on-disk files, since it loses the backseek cache. + // That in turn can cause major bandwidth increase and performance + // issues with e.g. mov or badly interleaved files + if (read < s->min_filepos || read > s->max_filepos + s->seek_limit) { + MP_VERBOSE(s, "Dropping cache at pos %"PRId64", " "cached range: %"PRId64"-%"PRId64".\n", read, s->min_filepos, s->max_filepos); - cache_drop_contents(s); - } + cache_drop_contents(s); } if (stream_tell(s->stream) != s->max_filepos) { -- cgit v1.2.3