player: remove OSD message IDs

These were needed before the last commit, but now they don't do anything
anymore. (They were used to decide whether to replace or stack the
previous OSD message when a new one was displayed.)
This commit is contained in:
wm4 2014-01-17 22:34:47 +01:00
parent a0a2ea8713
commit 49ebbce3e0
4 changed files with 39 additions and 66 deletions

View File

@ -2098,8 +2098,6 @@ static struct property_osd_display {
const char *osd_name; const char *osd_name;
// progressbar type // progressbar type
int osd_progbar; int osd_progbar;
// osd msg id if it must be shared
int osd_id;
// Needs special ways to display the new value (seeks are delayed) // Needs special ways to display the new value (seeks are delayed)
int seek_msg, seek_bar; int seek_msg, seek_bar;
// Free-form message (if NULL, osd_name or the property name is used) // Free-form message (if NULL, osd_name or the property name is used)
@ -2142,7 +2140,7 @@ static struct property_osd_display {
{ "sub", "Subtitles" }, { "sub", "Subtitles" },
{ "secondary-sid", "Secondary subtitles" }, { "secondary-sid", "Secondary subtitles" },
{ "sub-pos", "Sub position" }, { "sub-pos", "Sub position" },
{ "sub-delay", "Sub delay", .osd_id = OSD_MSG_SUB_DELAY }, { "sub-delay", "Sub delay" },
{ "sub-visibility", "Subtitles" }, { "sub-visibility", "Subtitles" },
{ "sub-forced-only", "Forced sub only" }, { "sub-forced-only", "Forced sub only" },
{ "sub-scale", "Sub Scale"}, { "sub-scale", "Sub Scale"},
@ -2238,14 +2236,8 @@ static void show_property_osd(MPContext *mpctx, const char *pname, int osd_mode)
osd_msg && osd_msg[0] ? " " : "", t); osd_msg && osd_msg[0] ? " " : "", t);
} }
if (osd_msg && osd_msg[0]) { if (osd_msg && osd_msg[0])
int osd_id = 0; set_osd_msg(mpctx, 1, opts->osd_duration, "%s", osd_msg);
if (p) {
int index = p - property_osd_display;
osd_id = p->osd_id ? p->osd_id : OSD_MSG_PROPERTY + index;
}
set_osd_msg(mpctx, osd_id, 1, opts->osd_duration, "%s", osd_msg);
}
talloc_free(tmp); talloc_free(tmp);
} }
@ -2344,7 +2336,7 @@ static int edit_filters_osd(struct MPContext *mpctx, enum stream_type mediatype,
const char *prop = filter_opt[mediatype]; const char *prop = filter_opt[mediatype];
show_property_osd(mpctx, prop, MP_ON_OSD_MSG); show_property_osd(mpctx, prop, MP_ON_OSD_MSG);
} else { } else {
set_osd_msg(mpctx, OSD_MSG_TEXT, 1, mpctx->opts->osd_duration, set_osd_msg(mpctx, 1, mpctx->opts->osd_duration,
"Changing filters failed!"); "Changing filters failed!");
} }
} }
@ -2604,10 +2596,10 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
if (r == M_PROPERTY_OK || r == M_PROPERTY_UNAVAILABLE) { if (r == M_PROPERTY_OK || r == M_PROPERTY_UNAVAILABLE) {
show_property_osd(mpctx, cmd->args[0].v.s, on_osd); show_property_osd(mpctx, cmd->args[0].v.s, on_osd);
} else if (r == M_PROPERTY_UNKNOWN) { } else if (r == M_PROPERTY_UNKNOWN) {
set_osd_msg(mpctx, OSD_MSG_TEXT, osdl, osd_duration, set_osd_msg(mpctx, osdl, osd_duration,
"Unknown property: '%s'", cmd->args[0].v.s); "Unknown property: '%s'", cmd->args[0].v.s);
} else if (r <= 0) { } else if (r <= 0) {
set_osd_msg(mpctx, OSD_MSG_TEXT, osdl, osd_duration, set_osd_msg(mpctx, osdl, osd_duration,
"Failed to set property '%s' to '%s'", "Failed to set property '%s' to '%s'",
cmd->args[0].v.s, cmd->args[1].v.s); cmd->args[0].v.s, cmd->args[1].v.s);
} }
@ -2633,10 +2625,10 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
if (r == M_PROPERTY_OK || r == M_PROPERTY_UNAVAILABLE) { if (r == M_PROPERTY_OK || r == M_PROPERTY_UNAVAILABLE) {
show_property_osd(mpctx, property, on_osd); show_property_osd(mpctx, property, on_osd);
} else if (r == M_PROPERTY_UNKNOWN) { } else if (r == M_PROPERTY_UNKNOWN) {
set_osd_msg(mpctx, OSD_MSG_TEXT, osdl, osd_duration, set_osd_msg(mpctx, osdl, osd_duration,
"Unknown property: '%s'", property); "Unknown property: '%s'", property);
} else if (r <= 0) { } else if (r <= 0) {
set_osd_msg(mpctx, OSD_MSG_TEXT, osdl, osd_duration, set_osd_msg(mpctx, osdl, osd_duration,
"Failed to increment property '%s' by %g", "Failed to increment property '%s' by %g",
property, s.inc); property, s.inc);
} }
@ -2651,10 +2643,10 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
if (r == M_PROPERTY_OK || r == M_PROPERTY_UNAVAILABLE) { if (r == M_PROPERTY_OK || r == M_PROPERTY_UNAVAILABLE) {
show_property_osd(mpctx, property, on_osd); show_property_osd(mpctx, property, on_osd);
} else if (r == M_PROPERTY_UNKNOWN) { } else if (r == M_PROPERTY_UNKNOWN) {
set_osd_msg(mpctx, OSD_MSG_TEXT, osdl, osd_duration, set_osd_msg(mpctx, osdl, osd_duration,
"Unknown property: '%s'", property); "Unknown property: '%s'", property);
} else if (r <= 0) { } else if (r <= 0) {
set_osd_msg(mpctx, OSD_MSG_TEXT, osdl, osd_duration, set_osd_msg(mpctx, osdl, osd_duration,
"Failed to multiply property '%s' by %g", property, f); "Failed to multiply property '%s' by %g", property, f);
} }
break; break;
@ -2684,10 +2676,10 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
if (r == M_PROPERTY_OK || r == M_PROPERTY_UNAVAILABLE) { if (r == M_PROPERTY_OK || r == M_PROPERTY_UNAVAILABLE) {
show_property_osd(mpctx, property, on_osd); show_property_osd(mpctx, property, on_osd);
} else if (r == M_PROPERTY_UNKNOWN) { } else if (r == M_PROPERTY_UNKNOWN) {
set_osd_msg(mpctx, OSD_MSG_TEXT, osdl, osd_duration, set_osd_msg(mpctx, osdl, osd_duration,
"Unknown property: '%s'", property); "Unknown property: '%s'", property);
} else if (r <= 0) { } else if (r <= 0) {
set_osd_msg(mpctx, OSD_MSG_TEXT, osdl, osd_duration, set_osd_msg(mpctx, osdl, osd_duration,
"Failed to set property '%s' to '%s'", "Failed to set property '%s' to '%s'",
property, value); property, value);
} }
@ -2756,7 +2748,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
if (cmd->id == MP_CMD_SUB_STEP) { if (cmd->id == MP_CMD_SUB_STEP) {
opts->sub_delay -= a[0]; opts->sub_delay -= a[0];
osd_changed_all(mpctx->osd); osd_changed_all(mpctx->osd);
set_osd_msg(mpctx, OSD_MSG_SUB_DELAY, osdl, osd_duration, set_osd_msg(mpctx, osdl, osd_duration,
"Sub delay: %d ms", ROUND(opts->sub_delay * 1000)); "Sub delay: %d ms", ROUND(opts->sub_delay * 1000));
} else { } else {
// We can easily get stuck by failing to seek to the video // We can easily get stuck by failing to seek to the video
@ -2788,7 +2780,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
else else
opts->osd_level = v > max ? max : v; opts->osd_level = v > max ? max : v;
if (msg_osd && opts->osd_level <= 1) if (msg_osd && opts->osd_level <= 1)
set_osd_msg(mpctx, OSD_MSG_OSD_STATUS, 0, osd_duration, set_osd_msg(mpctx, 0, osd_duration,
"OSD: %s", opts->osd_level ? "yes" : "no"); "OSD: %s", opts->osd_level ? "yes" : "no");
break; break;
} }
@ -2800,7 +2792,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
case MP_CMD_SHOW_TEXT: { case MP_CMD_SHOW_TEXT: {
// if no argument supplied use default osd_duration, else <arg> ms. // if no argument supplied use default osd_duration, else <arg> ms.
set_osd_msg(mpctx, OSD_MSG_TEXT, cmd->args[2].v.i, set_osd_msg(mpctx, cmd->args[2].v.i,
(cmd->args[1].v.i < 0 ? osd_duration : cmd->args[1].v.i), (cmd->args[1].v.i < 0 ? osd_duration : cmd->args[1].v.i),
"%s", cmd->args[0].v.s); "%s", cmd->args[0].v.s);
break; break;
@ -2904,7 +2896,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
#if HAVE_PVR #if HAVE_PVR
else if (mpctx->stream && mpctx->stream->type == STREAMTYPE_PVR) { else if (mpctx->stream && mpctx->stream->type == STREAMTYPE_PVR) {
pvr_set_freq(mpctx->stream, ROUND(cmd->args[0].v.f)); pvr_set_freq(mpctx->stream, ROUND(cmd->args[0].v.f));
set_osd_msg(mpctx, OSD_MSG_TV_CHANNEL, osdl, osd_duration, "%s: %s", set_osd_msg(mpctx, osdl, osd_duration, "%s: %s",
pvr_get_current_channelname(mpctx->stream), pvr_get_current_channelname(mpctx->stream),
pvr_get_current_stationname(mpctx->stream)); pvr_get_current_stationname(mpctx->stream));
} }
@ -2917,7 +2909,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
#if HAVE_PVR #if HAVE_PVR
else if (mpctx->stream && mpctx->stream->type == STREAMTYPE_PVR) { else if (mpctx->stream && mpctx->stream->type == STREAMTYPE_PVR) {
pvr_force_freq_step(mpctx->stream, ROUND(cmd->args[0].v.f)); pvr_force_freq_step(mpctx->stream, ROUND(cmd->args[0].v.f));
set_osd_msg(mpctx, OSD_MSG_TV_CHANNEL, osdl, osd_duration, "%s: f %d", set_osd_msg(mpctx, osdl, osd_duration, "%s: f %d",
pvr_get_current_channelname(mpctx->stream), pvr_get_current_channelname(mpctx->stream),
pvr_get_current_frequency(mpctx->stream)); pvr_get_current_frequency(mpctx->stream));
} }
@ -2938,7 +2930,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
tv_step_channel(get_tvh(mpctx), TV_CHANNEL_LOWER); tv_step_channel(get_tvh(mpctx), TV_CHANNEL_LOWER);
} }
if (tv_channel_list) { if (tv_channel_list) {
set_osd_msg(mpctx, OSD_MSG_TV_CHANNEL, osdl, osd_duration, set_osd_msg(mpctx, osdl, osd_duration,
"Channel: %s", tv_channel_current->name); "Channel: %s", tv_channel_current->name);
} }
} }
@ -2946,7 +2938,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
else if (mpctx->stream && else if (mpctx->stream &&
mpctx->stream->type == STREAMTYPE_PVR) { mpctx->stream->type == STREAMTYPE_PVR) {
pvr_set_channel_step(mpctx->stream, cmd->args[0].v.i); pvr_set_channel_step(mpctx->stream, cmd->args[0].v.i);
set_osd_msg(mpctx, OSD_MSG_TV_CHANNEL, osdl, osd_duration, "%s: %s", set_osd_msg(mpctx, osdl, osd_duration, "%s: %s",
pvr_get_current_channelname(mpctx->stream), pvr_get_current_channelname(mpctx->stream),
pvr_get_current_stationname(mpctx->stream)); pvr_get_current_stationname(mpctx->stream));
} }
@ -2974,14 +2966,14 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
if (get_tvh(mpctx)) { if (get_tvh(mpctx)) {
tv_set_channel(get_tvh(mpctx), cmd->args[0].v.s); tv_set_channel(get_tvh(mpctx), cmd->args[0].v.s);
if (tv_channel_list) { if (tv_channel_list) {
set_osd_msg(mpctx, OSD_MSG_TV_CHANNEL, osdl, osd_duration, set_osd_msg(mpctx, osdl, osd_duration,
"Channel: %s", tv_channel_current->name); "Channel: %s", tv_channel_current->name);
} }
} }
#if HAVE_PVR #if HAVE_PVR
else if (mpctx->stream && mpctx->stream->type == STREAMTYPE_PVR) { else if (mpctx->stream && mpctx->stream->type == STREAMTYPE_PVR) {
pvr_set_channel(mpctx->stream, cmd->args[0].v.s); pvr_set_channel(mpctx->stream, cmd->args[0].v.s);
set_osd_msg(mpctx, OSD_MSG_TV_CHANNEL, osdl, osd_duration, "%s: %s", set_osd_msg(mpctx, osdl, osd_duration, "%s: %s",
pvr_get_current_channelname(mpctx->stream), pvr_get_current_channelname(mpctx->stream),
pvr_get_current_stationname(mpctx->stream)); pvr_get_current_stationname(mpctx->stream));
} }
@ -3005,14 +2997,14 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
if (get_tvh(mpctx)) { if (get_tvh(mpctx)) {
tv_last_channel(get_tvh(mpctx)); tv_last_channel(get_tvh(mpctx));
if (tv_channel_list) { if (tv_channel_list) {
set_osd_msg(mpctx, OSD_MSG_TV_CHANNEL, osdl, osd_duration, set_osd_msg(mpctx, osdl, osd_duration,
"Channel: %s", tv_channel_current->name); "Channel: %s", tv_channel_current->name);
} }
} }
#if HAVE_PVR #if HAVE_PVR
else if (mpctx->stream && mpctx->stream->type == STREAMTYPE_PVR) { else if (mpctx->stream && mpctx->stream->type == STREAMTYPE_PVR) {
pvr_set_lastchannel(mpctx->stream); pvr_set_lastchannel(mpctx->stream);
set_osd_msg(mpctx, OSD_MSG_TV_CHANNEL, osdl, osd_duration, "%s: %s", set_osd_msg(mpctx, osdl, osd_duration, "%s: %s",
pvr_get_current_channelname(mpctx->stream), pvr_get_current_channelname(mpctx->stream),
pvr_get_current_stationname(mpctx->stream)); pvr_get_current_stationname(mpctx->stream));
} }
@ -3105,9 +3097,9 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
char *s = cmd->args[0].v.s; char *s = cmd->args[0].v.s;
MP_INFO(mpctx, "Setting vo cmd line to '%s'.\n", s); MP_INFO(mpctx, "Setting vo cmd line to '%s'.\n", s);
if (vo_control(mpctx->video_out, VOCTRL_SET_COMMAND_LINE, s) > 0) { if (vo_control(mpctx->video_out, VOCTRL_SET_COMMAND_LINE, s) > 0) {
set_osd_msg(mpctx, OSD_MSG_TEXT, osdl, osd_duration, "vo='%s'", s); set_osd_msg(mpctx, osdl, osd_duration, "vo='%s'", s);
} else { } else {
set_osd_msg(mpctx, OSD_MSG_TEXT, osdl, osd_duration, "Failed!"); set_osd_msg(mpctx, osdl, osd_duration, "Failed!");
} }
} }
break; break;

View File

@ -80,19 +80,6 @@ enum mp_osd_seek_info {
enum { enum {
OSD_MSG_TEXT = 1,
OSD_MSG_SUB_DELAY,
OSD_MSG_SPEED,
OSD_MSG_OSD_STATUS,
OSD_MSG_BAR,
OSD_MSG_PAUSE,
OSD_MSG_RADIO_CHANNEL,
OSD_MSG_TV_CHANNEL,
// Base id for messages generated from the commmand to property bridge.
OSD_MSG_PROPERTY = 0x100,
OSD_MSG_SUB_BASE = 0x1000,
// other constants // other constants
MAX_OSD_LEVEL = 3, MAX_OSD_LEVEL = 3,
MAX_TERM_OSD_LEVEL = 1, MAX_TERM_OSD_LEVEL = 1,
@ -414,8 +401,8 @@ void stream_dump(struct MPContext *mpctx);
void print_status(struct MPContext *mpctx); void print_status(struct MPContext *mpctx);
void set_osd_bar(struct MPContext *mpctx, int type, const char* name, void set_osd_bar(struct MPContext *mpctx, int type, const char* name,
double min, double max, double val); double min, double max, double val);
void set_osd_msg(struct MPContext *mpctx, int id, int level, int time, void set_osd_msg(struct MPContext *mpctx, int level, int time,
const char* fmt, ...) PRINTF_ATTRIBUTE(5,6); const char* fmt, ...) PRINTF_ATTRIBUTE(4,5);
void set_osd_function(struct MPContext *mpctx, int osd_function); void set_osd_function(struct MPContext *mpctx, int osd_function);
void set_osd_subtitle(struct MPContext *mpctx, const char *text); void set_osd_subtitle(struct MPContext *mpctx, const char *text);

View File

@ -235,7 +235,7 @@ typedef struct mp_osd_msg mp_osd_msg_t;
struct mp_osd_msg { struct mp_osd_msg {
/// Message text. /// Message text.
char *msg; char *msg;
int id, level, started; int started;
/// Display duration in seconds. /// Display duration in seconds.
double time; double time;
// Show full OSD for duration of message instead of msg // Show full OSD for duration of message instead of msg
@ -244,8 +244,7 @@ struct mp_osd_msg {
}; };
// time is in ms // time is in ms
static mp_osd_msg_t *add_osd_msg(struct MPContext *mpctx, int id, int level, static mp_osd_msg_t *add_osd_msg(struct MPContext *mpctx, int level, int time)
int time)
{ {
struct MPOpts *opts = mpctx->opts; struct MPOpts *opts = mpctx->opts;
if (level > opts->osd_level) if (level > opts->osd_level)
@ -254,29 +253,27 @@ static mp_osd_msg_t *add_osd_msg(struct MPContext *mpctx, int id, int level,
talloc_free(mpctx->osd_msg_stack); talloc_free(mpctx->osd_msg_stack);
mpctx->osd_msg_stack = talloc_struct(mpctx, mp_osd_msg_t, { mpctx->osd_msg_stack = talloc_struct(mpctx, mp_osd_msg_t, {
.msg = "", .msg = "",
.id = id,
.level = level,
.time = time / 1000.0, .time = time / 1000.0,
}); });
return mpctx->osd_msg_stack; return mpctx->osd_msg_stack;
} }
static void set_osd_msg_va(struct MPContext *mpctx, int id, int level, int time, static void set_osd_msg_va(struct MPContext *mpctx, int level, int time,
const char *fmt, va_list ap) const char *fmt, va_list ap)
{ {
if (level == OSD_LEVEL_INVISIBLE) if (level == OSD_LEVEL_INVISIBLE)
return; return;
mp_osd_msg_t *msg = add_osd_msg(mpctx, id, level, time); mp_osd_msg_t *msg = add_osd_msg(mpctx, level, time);
if (msg) if (msg)
msg->msg = talloc_vasprintf(msg, fmt, ap); msg->msg = talloc_vasprintf(msg, fmt, ap);
} }
void set_osd_msg(struct MPContext *mpctx, int id, int level, int time, void set_osd_msg(struct MPContext *mpctx, int level, int time,
const char *fmt, ...) const char *fmt, ...)
{ {
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
set_osd_msg_va(mpctx, id, level, time, fmt, ap); set_osd_msg_va(mpctx, level, time, fmt, ap);
va_end(ap); va_end(ap);
} }
@ -345,7 +342,7 @@ void set_osd_bar(struct MPContext *mpctx, int type, const char *name,
return; return;
} }
set_osd_msg(mpctx, OSD_MSG_BAR, 1, opts->osd_duration, "%s: %d %%", set_osd_msg(mpctx, 1, opts->osd_duration, "%s: %d %%",
name, ROUND(100 * (val - min) / (max - min))); name, ROUND(100 * (val - min) / (max - min)));
} }
@ -453,22 +450,21 @@ static void add_seek_osd_messages(struct MPContext *mpctx)
if (mpctx->add_osd_seek_info & OSD_SEEK_INFO_TEXT) { if (mpctx->add_osd_seek_info & OSD_SEEK_INFO_TEXT) {
// Never in term-osd mode // Never in term-osd mode
if (mpctx->video_out && mpctx->opts->term_osd != 1) { if (mpctx->video_out && mpctx->opts->term_osd != 1) {
mp_osd_msg_t *msg = add_osd_msg(mpctx, OSD_MSG_TEXT, 1, mp_osd_msg_t *msg = add_osd_msg(mpctx, 1, mpctx->opts->osd_duration);
mpctx->opts->osd_duration);
if (msg) if (msg)
msg->show_position = true; msg->show_position = true;
} }
} }
if (mpctx->add_osd_seek_info & OSD_SEEK_INFO_CHAPTER_TEXT) { if (mpctx->add_osd_seek_info & OSD_SEEK_INFO_CHAPTER_TEXT) {
char *chapter = chapter_display_name(mpctx, get_current_chapter(mpctx)); char *chapter = chapter_display_name(mpctx, get_current_chapter(mpctx));
set_osd_msg(mpctx, OSD_MSG_TEXT, 1, mpctx->opts->osd_duration, set_osd_msg(mpctx, 1, mpctx->opts->osd_duration,
"Chapter: %s", chapter); "Chapter: %s", chapter);
talloc_free(chapter); talloc_free(chapter);
} }
if ((mpctx->add_osd_seek_info & OSD_SEEK_INFO_EDITION) if ((mpctx->add_osd_seek_info & OSD_SEEK_INFO_EDITION)
&& mpctx->master_demuxer) && mpctx->master_demuxer)
{ {
set_osd_msg(mpctx, OSD_MSG_TEXT, 1, mpctx->opts->osd_duration, set_osd_msg(mpctx, 1, mpctx->opts->osd_duration,
"Playing edition %d of %d.", "Playing edition %d of %d.",
mpctx->master_demuxer->edition + 1, mpctx->master_demuxer->edition + 1,
mpctx->master_demuxer->num_editions); mpctx->master_demuxer->num_editions);

View File

@ -79,10 +79,8 @@ static void screenshot_msg(screenshot_ctx *ctx, int status, const char *msg,
va_end(ap); va_end(ap);
MP_MSG(ctx->mpctx, status == SMSG_ERR ? MSGL_ERR : MSGL_INFO, "%s\n", s); MP_MSG(ctx->mpctx, status == SMSG_ERR ? MSGL_ERR : MSGL_INFO, "%s\n", s);
if (ctx->osd) { if (ctx->osd)
set_osd_msg(ctx->mpctx, OSD_MSG_TEXT, 1, ctx->mpctx->opts->osd_duration, set_osd_msg(ctx->mpctx, 1, ctx->mpctx->opts->osd_duration, "%s", s);
"%s", s);
}
talloc_free(s); talloc_free(s);
} }