mirror of
https://github.com/mpv-player/mpv
synced 2024-12-27 17:42:17 +00:00
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.
This commit is contained in:
parent
cafa00841f
commit
914c8dc577
37
mplayer.c
37
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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user