summaryrefslogtreecommitdiffstats
path: root/mplayer.c
diff options
context:
space:
mode:
authorUoti Urpala <uau@mplayer2.org>2012-08-22 00:12:12 +0300
committerwm4 <wm4@nowhere>2012-08-28 23:18:33 +0200
commit3972642cb8ee4629be0d64fee06f67bf7e95c98d (patch)
treefc314a6b2ece2400643678d91d808ef4ef1aca2e /mplayer.c
parent413c6f5b306ec3b36b3003d1834328960504ec1c (diff)
downloadmpv-3972642cb8ee4629be0d64fee06f67bf7e95c98d.tar.bz2
mpv-3972642cb8ee4629be0d64fee06f67bf7e95c98d.tar.xz
OSD/commands: use osdlevel=3 for osd_show_progression command
The osd_show_progression command ('P' key) created text similar to what --osdlevel=3 shows, and set that as an OSD message. This message was static and wasn't updated while visible, even if video position changed (very noticeable during fast forward, when real OSD position changes rapidly). Instead of setting a static message, create a new message type that makes the OSD update code behave as if osd level was set to 3 for the duration of the message. The OSD progress bar isn't updated while the message is active. Based on mplayer2 commit 458001463b2252fc by uau.
Diffstat (limited to 'mplayer.c')
-rw-r--r--mplayer.c39
1 files changed, 25 insertions, 14 deletions
diff --git a/mplayer.c b/mplayer.c
index 2ed4a3d257..1d5f08fa50 100644
--- a/mplayer.c
+++ b/mplayer.c
@@ -1152,6 +1152,9 @@ struct mp_osd_msg {
int id, level, started;
/// Display duration in ms.
unsigned time;
+ // Show full OSD for duration of message instead of msg
+ // (osd_show_progression command)
+ bool show_position;
};
/**
@@ -1161,8 +1164,8 @@ struct mp_osd_msg {
* it is pulled on top of the stack, otherwise a new message is created.
*
*/
-static void set_osd_msg_va(struct MPContext *mpctx, int id, int level, int time,
- const char *fmt, va_list ap)
+static mp_osd_msg_t *add_osd_msg(struct MPContext *mpctx, int id, int level,
+ int time)
{
mp_osd_msg_t *msg, *last = NULL;
@@ -1179,14 +1182,20 @@ static void set_osd_msg_va(struct MPContext *mpctx, int id, int level, int time,
msg->prev = mpctx->osd_msg_stack;
mpctx->osd_msg_stack = msg;
}
- talloc_free(msg->msg);
- // write the msg
- msg->msg = talloc_vasprintf(msg, fmt, ap);
+ talloc_free_children(msg);
+ msg->msg = "";
// set id and time
msg->id = id;
msg->level = level;
msg->time = time;
+ return msg;
+}
+static void set_osd_msg_va(struct MPContext *mpctx, int id, int level, int time,
+ const char *fmt, va_list ap)
+{
+ mp_osd_msg_t *msg = add_osd_msg(mpctx, id, level, time);
+ msg->msg = talloc_vasprintf(msg, fmt, ap);
}
void set_osd_msg(struct MPContext *mpctx, int id, int level, int time,
@@ -1397,7 +1406,6 @@ static void sadd_osd_status(char *buffer, int len, struct MPContext *mpctx,
static void update_osd_msg(struct MPContext *mpctx)
{
struct MPOpts *opts = &mpctx->opts;
- mp_osd_msg_t *msg;
struct osd_state *osd = mpctx->osd;
if (mpctx->add_osd_seek_info) {
@@ -1406,7 +1414,8 @@ static void update_osd_msg(struct MPContext *mpctx)
}
// Look if we have a msg
- if ((msg = get_osd_msg(mpctx))) {
+ mp_osd_msg_t *msg = get_osd_msg(mpctx);
+ if (msg && !msg->show_position) {
if (mpctx->sh_video && opts->term_osd != 1) {
osd_set_text(osd, msg->msg);
} else if (opts->term_osd) {
@@ -1420,13 +1429,17 @@ static void update_osd_msg(struct MPContext *mpctx)
return;
}
+ int osd_level = opts->osd_level;
+ if (msg && msg->show_position)
+ osd_level = 3;
+
if (mpctx->sh_video && opts->term_osd != 1) {
// fallback on the timer
char text[128] = "";
int len = sizeof(text);
- if (opts->osd_level >= 2)
- sadd_osd_status(text, len, mpctx, opts->osd_level == 3);
+ if (osd_level >= 2)
+ sadd_osd_status(text, len, mpctx, osd_level == 3);
osd_set_text(osd, text);
return;
@@ -1441,11 +1454,9 @@ static void update_osd_msg(struct MPContext *mpctx)
void mp_show_osd_progression(struct MPContext *mpctx)
{
- char text[128] = "";
- int len = sizeof(text);
-
- sadd_osd_status(text, len, mpctx, true);
- set_osd_msg(mpctx, OSD_MSG_TEXT, 1, mpctx->opts.osd_duration, "%s", text);
+ mp_osd_msg_t *msg = add_osd_msg(mpctx, OSD_MSG_TEXT, 1,
+ mpctx->opts.osd_duration);
+ msg->show_position = true;
set_osd_bar(mpctx, 0, "Position", 0, 100, get_percent_pos(mpctx));
}