From 8dbc93a94cdc3c8e08ac9df5af0c26d470751f46 Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 20 Apr 2016 10:41:09 +0200 Subject: player: minor simplification to buffering property updates Strictly schedule an update in regular intervals as long as either stream cache or demuxer are prefetching. Don't update just always because the stream cache is enabled ("idle != -1") or cache-related properties are observed (mp_client_event_is_registered()). Also, the "idle" variable was awkard; get rid of it with equivalent code. --- player/playloop.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/player/playloop.c b/player/playloop.c index a7b21850dd..fc31c74616 100644 --- a/player/playloop.c +++ b/player/playloop.c @@ -523,16 +523,15 @@ static void handle_pause_on_low_cache(struct MPContext *mpctx) if (!mpctx->demuxer) return; - struct stream_cache_info info = {0}; - demux_stream_control(mpctx->demuxer, STREAM_CTRL_GET_CACHE_INFO, &info); - int idle = info.size > 0 ? info.idle : -1; + struct stream_cache_info c = {.idle = true}; + demux_stream_control(mpctx->demuxer, STREAM_CTRL_GET_CACHE_INFO, &c); struct demux_ctrl_reader_state s = {.idle = true, .ts_duration = -1}; demux_control(mpctx->demuxer, DEMUXER_CTRL_GET_READER_STATE, &s); int cache_buffer = 100; - if (mpctx->restart_complete && idle != -1) { + if (mpctx->restart_complete && c.size > 0) { if (mpctx->paused && mpctx->paused_for_cache) { if (!opts->cache_pausing || s.ts_duration >= mpctx->cache_wait_time || s.idle) @@ -567,11 +566,7 @@ static void handle_pause_on_low_cache(struct MPContext *mpctx) } // Also update cache properties. - bool busy = idle == 0; - if (!s.idle) { - busy |= idle != -1; - busy |= mp_client_event_is_registered(mpctx, MP_EVENT_CACHE_UPDATE); - } + bool busy = !s.idle || !c.idle; if (busy || mpctx->next_cache_update > 0) { double now = mp_time_sec(); if (mpctx->next_cache_update <= now) { -- cgit v1.2.3