summaryrefslogtreecommitdiffstats
path: root/player/osd.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-07-18 15:04:46 +0200
committerwm4 <wm4@nowhere>2014-07-18 15:04:46 +0200
commitdc00b146c487f71ef1f0a23a4f2b9948b2fac18b (patch)
tree0292395823a0bef392c4795acc8d50ca75deedea /player/osd.c
parent34fdf082d8d7d79a24962ff2d8b43b3bef5905b2 (diff)
downloadmpv-dc00b146c487f71ef1f0a23a4f2b9948b2fac18b.tar.bz2
mpv-dc00b146c487f71ef1f0a23a4f2b9948b2fac18b.tar.xz
player: remove the last instances of polling
Mouse cursor handling, --heartbeat-cmd, and OSD messages basically relied on polling. For this reason, the playloop always used a small timeout (not more than 500ms). Fix these cases, and raise the timeout to 100 seconds. There is no reason behind this number; for this specific purpose it's as close to infinity as any other number. On MS Windows, or if vo_sdl is used, the timeout remains very small. In these cases the GUI code doesn't do proper event handling in the first place, and fixing it requires much more effort. getch2_poll() still does polling, because as far as I'm aware no event- based way to detect this state change exists.
Diffstat (limited to 'player/osd.c')
-rw-r--r--player/osd.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/player/osd.c b/player/osd.c
index 939d62fd98..41d0b8d160 100644
--- a/player/osd.c
+++ b/player/osd.c
@@ -314,19 +314,21 @@ static mp_osd_msg_t *get_osd_msg(struct MPContext *mpctx)
mp_osd_msg_t *msg = mpctx->osd_msg_stack;
if (msg) {
if (!msg->started || msg->time > diff) {
+ // display it
if (msg->started)
msg->time -= diff;
else
msg->started = 1;
- // display it
- return msg;
+ } else {
+ // kill the message
+ talloc_free(msg);
+ msg = NULL;
+ mpctx->osd_msg_stack = NULL;
}
- // kill the message
- talloc_free(msg);
- mpctx->osd_msg_stack = NULL;
}
- // Nothing found
- return NULL;
+ if (msg)
+ mpctx->sleeptime = MPMIN(mpctx->sleeptime, msg->time);
+ return msg;
}
// type: mp_osd_font_codepoints, ASCII, or OSD_BAR_*