From 914c8dc577ef782d8e350d9a5d68657108d04c19 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 31 Aug 2012 18:08:47 +0200 Subject: [PATCH] osd: reset OSD progression display The code for showing OSD progression ('P' key) set a flag in a mp_osd_msg_t to do its work. OSD messages can be re-used for completely unrelated purposes (it's unclear why), so this has to be reset if an old OSD progression message is reused for something different. Be sure to reset the full message. Remove the messy code for searching the OSD stack. Use the existing rm_osd_msg() function to remove the old message (if there was one), and always create a new message. The new code should be functionally equivalent to the old code. The "started" flag wasn't reset before, but since the time is always overwritten, this might be actually more correct. --- mplayer.c | 37 +++++++++---------------------------- 1 file changed, 9 insertions(+), 28 deletions(-) diff --git a/mplayer.c b/mplayer.c index 1d5f08fa50..b097047caa 100644 --- a/mplayer.c +++ b/mplayer.c @@ -1157,37 +1157,18 @@ struct mp_osd_msg { bool show_position; }; -/** - * \brief Add a message on the OSD message stack - * - * If a message with the same id is already present in the stack - * it is pulled on top of the stack, otherwise a new message is created. - * - */ static mp_osd_msg_t *add_osd_msg(struct MPContext *mpctx, int id, int level, int time) { - mp_osd_msg_t *msg, *last = NULL; - - // look if the id is already in the stack - for (msg = mpctx->osd_msg_stack; msg && msg->id != id; - last = msg, msg = msg->prev) ; - // not found: alloc it - if (!msg) { - msg = talloc_zero(mpctx, mp_osd_msg_t); - msg->prev = mpctx->osd_msg_stack; - mpctx->osd_msg_stack = msg; - } else if (last) { // found, but it's not on top of the stack - last->prev = msg->prev; - msg->prev = mpctx->osd_msg_stack; - mpctx->osd_msg_stack = msg; - } - talloc_free_children(msg); - msg->msg = ""; - // set id and time - msg->id = id; - msg->level = level; - msg->time = time; + rm_osd_msg(mpctx, id); + mp_osd_msg_t *msg = talloc_struct(mpctx, mp_osd_msg_t, { + .prev = mpctx->osd_msg_stack, + .msg = "", + .id = id, + .level = level, + .time = time, + }); + mpctx->osd_msg_stack = msg; return msg; }