From 020730da0bcc467afee8ff9861fcc9116372003b Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 15 Apr 2018 11:43:49 +0200 Subject: player: remove in_dispatch field (Not sure if worth the trouble, but it does seem less awkward.) --- player/playloop.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'player/playloop.c') diff --git a/player/playloop.c b/player/playloop.c index 852fc7c199..a0945db845 100644 --- a/player/playloop.c +++ b/player/playloop.c @@ -57,11 +57,8 @@ void mp_wait_events(struct MPContext *mpctx) if (sleeping) MP_STATS(mpctx, "start sleep"); - mpctx->in_dispatch = true; - mp_dispatch_queue_process(mpctx->dispatch, mpctx->sleeptime); - mpctx->in_dispatch = false; mpctx->sleeptime = INFINITY; if (sleeping) @@ -73,11 +70,11 @@ void mp_wait_events(struct MPContext *mpctx) // mp_set_timeout(c, 0) is essentially equivalent to mp_wakeup_core(c). void mp_set_timeout(struct MPContext *mpctx, double sleeptime) { - mpctx->sleeptime = MPMIN(mpctx->sleeptime, sleeptime); - - // Can't adjust timeout if called from mp_dispatch_queue_process(). - if (mpctx->in_dispatch && isfinite(sleeptime)) - mp_wakeup_core(mpctx); + if (mpctx->sleeptime > sleeptime) { + mpctx->sleeptime = sleeptime; + int64_t abstime = mp_add_timeout(mp_time_us(), sleeptime); + mp_dispatch_adjust_timeout(mpctx->dispatch, abstime); + } } // Cause the playloop to run. This can be called from any thread. If called -- cgit v1.2.3