From 68daee220c305220bfeb8f4f473b981b2d34af70 Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 20 Feb 2013 23:05:02 +0100 Subject: osd: prevent osd bar from sticking around on seeks This was supposed to be fixed in f897138, but there's another corner case. Basically, set_osd_function() reset the OSD time, which is not nice at all and breaks the logic of letting OSD elements disappear when they're not wanted anymore. Fix this by adding a separate timer for this. Additionally, make sure the OSD bar is _really_ always updated when visible. Also, redraw the OSD only if the OSD bar actually changes to prevent redrawing too often (every vo_osd_changed() will flag that the OSD should be redrawn, even if nothing changes). --- core/mp_core.h | 3 ++- core/mplayer.c | 18 ++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/core/mp_core.h b/core/mp_core.h index 97aeb0d00e..c9c6a57487 100644 --- a/core/mp_core.h +++ b/core/mp_core.h @@ -127,8 +127,9 @@ typedef struct MPContext { subtitle subs; // subtitle list used when reading subtitles from demuxer int add_osd_seek_info; // bitfield of enum mp_osd_seek_info - unsigned int osd_visible; + unsigned int osd_visible; // for the osd bar only int osd_function; + unsigned int osd_function_visible; struct playlist *playlist; char *filename; // currently playing file diff --git a/core/mplayer.c b/core/mplayer.c index f442fa24a8..0e4e1076b8 100644 --- a/core/mplayer.c +++ b/core/mplayer.c @@ -1311,6 +1311,11 @@ static mp_osd_msg_t *get_osd_msg(struct MPContext *mpctx) mpctx->osd_visible = 0; mpctx->osd->progbar_type = -1; // disable vo_osd_changed(OSDTYPE_PROGBAR); + } + } + if (mpctx->osd_function_visible) { + if (mpctx->osd_function_visible - now > 36000000) { + mpctx->osd_function_visible = 0; mpctx->osd_function = 0; } } @@ -1380,8 +1385,11 @@ static void update_osd_bar(struct MPContext *mpctx, int type, double min, double max, double val) { if (mpctx->osd->progbar_type == type) { - mpctx->osd->progbar_value = 256 * (val - min) / (max - min); - vo_osd_changed(OSDTYPE_PROGBAR); + int new_value = 256 * (val - min) / (max - min); + if (new_value != mpctx->osd->progbar_value) { + mpctx->osd->progbar_value = new_value; + vo_osd_changed(OSDTYPE_PROGBAR); + } } } @@ -1390,7 +1398,7 @@ void set_osd_function(struct MPContext *mpctx, int osd_function) struct MPOpts *opts = &mpctx->opts; mpctx->osd_function = osd_function; - mpctx->osd_visible = (GetTimerMS() + opts->osd_duration) | 1; + mpctx->osd_function_visible = (GetTimerMS() + opts->osd_duration) | 1; } /** @@ -1502,6 +1510,7 @@ static void update_osd_msg(struct MPContext *mpctx) struct osd_state *osd = mpctx->osd; add_seek_osd_messages(mpctx); + update_osd_bar(mpctx, OSD_BAR_SEEK, 0, 100, get_percent_pos(mpctx)); // Look if we have a msg mp_osd_msg_t *msg = get_osd_msg(mpctx); @@ -1535,9 +1544,6 @@ static void update_osd_msg(struct MPContext *mpctx) osd_set_text(osd, text); talloc_free(text); - - if (msg && msg->show_position) - update_osd_bar(mpctx, OSD_BAR_SEEK, 0, 100, get_percent_pos(mpctx)); return; } -- cgit v1.2.3