From 17256f13dcf47dd8493f888ff7879b6c25928852 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 21 Jul 2014 19:35:20 +0200 Subject: osd: properly handle OSD bar timeout This could just remain stuck on the screen, until the playloop happened to be run again. --- player/osd.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'player') diff --git a/player/osd.c b/player/osd.c index 41d0b8d160..2c0986e2df 100644 --- a/player/osd.c +++ b/player/osd.c @@ -295,10 +295,15 @@ static mp_osd_msg_t *get_osd_msg(struct MPContext *mpctx) double now = mp_time_sec(); double diff; - if (mpctx->osd_visible && now >= mpctx->osd_visible) { - mpctx->osd_visible = 0; - mpctx->osd_progbar.type = -1; // disable - osd_set_progbar(mpctx->osd, &mpctx->osd_progbar); + if (mpctx->osd_visible) { + double sleep = mpctx->osd_visible - now; + if (sleep > 0) { + mpctx->sleeptime = MPMIN(mpctx->sleeptime, sleep); + } else { + mpctx->osd_visible = 0; + mpctx->osd_progbar.type = -1; // disable + osd_set_progbar(mpctx->osd, &mpctx->osd_progbar); + } } if (mpctx->osd_function_visible && now >= mpctx->osd_function_visible) { mpctx->osd_function_visible = 0; @@ -342,6 +347,7 @@ void set_osd_bar(struct MPContext *mpctx, int type, const char* name, if (mpctx->video_out && opts->term_osd != 1) { mpctx->osd_visible = mp_time_sec() + opts->osd_duration / 1000.0; + mpctx->sleeptime = 0; mpctx->osd_progbar.type = type; mpctx->osd_progbar.value = (val - min) / (max - min); mpctx->osd_progbar.num_stops = 0; -- cgit v1.2.3