summaryrefslogtreecommitdiffstats
path: root/mplayer.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-08-31 18:08:47 +0200
committerwm4 <wm4@nowhere>2012-09-07 16:06:32 +0200
commit914c8dc577ef782d8e350d9a5d68657108d04c19 (patch)
tree74d88a24bcd49d2cf2eef5279cf0d47876653384 /mplayer.c
parentcafa00841fc1d0515a2063e7c64d884ad2019658 (diff)
downloadmpv-914c8dc577ef782d8e350d9a5d68657108d04c19.tar.bz2
mpv-914c8dc577ef782d8e350d9a5d68657108d04c19.tar.xz
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.
Diffstat (limited to 'mplayer.c')
-rw-r--r--mplayer.c37
1 files 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;
}