diff options
author | wm4 <wm4@nowhere> | 2018-04-15 11:43:49 +0200 |
---|---|---|
committer | Jan Ekström <jeebjp@gmail.com> | 2018-04-18 01:17:42 +0300 |
commit | 020730da0bcc467afee8ff9861fcc9116372003b (patch) | |
tree | c5f58fd079bec2828dc9ab03c0d875e7d3b56b54 /player/playloop.c | |
parent | 435bc003c0af7c51aa994f26ac0e80ad3e310b75 (diff) | |
download | mpv-020730da0bcc467afee8ff9861fcc9116372003b.tar.bz2 mpv-020730da0bcc467afee8ff9861fcc9116372003b.tar.xz |
player: remove in_dispatch field
(Not sure if worth the trouble, but it does seem less awkward.)
Diffstat (limited to 'player/playloop.c')
-rw-r--r-- | player/playloop.c | 13 |
1 files changed, 5 insertions, 8 deletions
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 |