From b4f24544bbfdd2bec765db08f5d745fadeb4d111 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 31 Jul 2014 04:19:41 +0200 Subject: client API: make "cache" property and similar observable Achieve this by polling. Will be used by the OSC. Basically a bad hack - but the point is that the mpv core itself is in the best position to improve this later. --- player/playloop.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'player/playloop.c') diff --git a/player/playloop.c b/player/playloop.c index 90d46cc178..b1d3efeecf 100644 --- a/player/playloop.c +++ b/player/playloop.c @@ -541,6 +541,18 @@ static void handle_pause_on_low_cache(struct MPContext *mpctx) opts->pause = prev_paused_user; } } + // Also update cache properties. + if (cache_kb > 0 || mpctx->next_cache_update > 0) { + double now = mp_time_sec(); + if (mpctx->next_cache_update <= now) { + mpctx->next_cache_update = cache_kb > 0 ? now + 0.25 : 0; + mp_notify(mpctx, MP_EVENT_CACHE_UPDATE, NULL); + } + if (mpctx->next_cache_update > 0) { + mpctx->sleeptime = + MPMIN(mpctx->sleeptime, mpctx->next_cache_update - now); + } + } } static void handle_heartbeat_cmd(struct MPContext *mpctx) -- cgit v1.2.3