summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2018-04-15 11:43:49 +0200
committerJan Ekström <jeebjp@gmail.com>2018-04-18 01:17:42 +0300
commit020730da0bcc467afee8ff9861fcc9116372003b (patch)
treec5f58fd079bec2828dc9ab03c0d875e7d3b56b54 /player
parent435bc003c0af7c51aa994f26ac0e80ad3e310b75 (diff)
downloadmpv-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')
-rw-r--r--player/core.h1
-rw-r--r--player/playloop.c13
2 files changed, 5 insertions, 9 deletions
diff --git a/player/core.h b/player/core.h
index ff4719926d..bc6cf28ff0 100644
--- a/player/core.h
+++ b/player/core.h
@@ -234,7 +234,6 @@ typedef struct MPContext {
struct mp_client_api *clients;
struct mp_dispatch_queue *dispatch;
struct mp_cancel *playback_abort;
- bool in_dispatch;
// Number of asynchronous tasks that still need to finish until MPContext
// destruction is ok. It's implied that the async tasks call
// mp_wakeup_core() each time this is decremented.
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