mirror of https://github.com/mpv-player/mpv
mplayer: make OSD stack a member of MPContext
This also requires that the OSD stack related functions carry a pointer to MPContext. Free the OSD stack items (mp_osd_msg) at exit by making MPContext the talloc parent. (E.g. when exiting while something is still displayed on the OSD.)
This commit is contained in:
parent
855449e67c
commit
ab63072b47
46
command.c
46
command.c
|
@ -542,12 +542,12 @@ static int mp_property_chapter(m_option_t *prop, int action, void *arg,
|
||||||
if (next_pts > -1.0)
|
if (next_pts > -1.0)
|
||||||
queue_seek(mpctx, MPSEEK_ABSOLUTE, next_pts, 0);
|
queue_seek(mpctx, MPSEEK_ABSOLUTE, next_pts, 0);
|
||||||
chapter_name = chapter_display_name(mpctx, chapter);
|
chapter_name = chapter_display_name(mpctx, chapter);
|
||||||
set_osd_tmsg(OSD_MSG_TEXT, 1, opts->osd_duration,
|
set_osd_tmsg(mpctx, OSD_MSG_TEXT, 1, opts->osd_duration,
|
||||||
"Chapter: %s", chapter_name);
|
"Chapter: %s", chapter_name);
|
||||||
} else if (step_all > 0)
|
} else if (step_all > 0)
|
||||||
queue_seek(mpctx, MPSEEK_RELATIVE, 1000000000, 0);
|
queue_seek(mpctx, MPSEEK_RELATIVE, 1000000000, 0);
|
||||||
else
|
else
|
||||||
set_osd_tmsg(OSD_MSG_TEXT, 1, opts->osd_duration,
|
set_osd_tmsg(mpctx, OSD_MSG_TEXT, 1, opts->osd_duration,
|
||||||
"Chapter: (%d) %s", 0, mp_gtext("unknown"));
|
"Chapter: (%d) %s", 0, mp_gtext("unknown"));
|
||||||
talloc_free(chapter_name);
|
talloc_free(chapter_name);
|
||||||
return M_PROPERTY_OK;
|
return M_PROPERTY_OK;
|
||||||
|
@ -637,7 +637,7 @@ static int mp_property_angle(m_option_t *prop, int action, void *arg,
|
||||||
resync_audio_stream(sh_audio);
|
resync_audio_stream(sh_audio);
|
||||||
}
|
}
|
||||||
|
|
||||||
set_osd_tmsg(OSD_MSG_TEXT, 1, opts->osd_duration,
|
set_osd_tmsg(mpctx, OSD_MSG_TEXT, 1, opts->osd_duration,
|
||||||
"Angle: %d/%d", angle, angles);
|
"Angle: %d/%d", angle, angles);
|
||||||
return M_PROPERTY_OK;
|
return M_PROPERTY_OK;
|
||||||
}
|
}
|
||||||
|
@ -2385,7 +2385,7 @@ static int show_property_osd(MPContext *mpctx, const char *pname)
|
||||||
char *val = mp_property_print(pname, mpctx);
|
char *val = mp_property_print(pname, mpctx);
|
||||||
if (val) {
|
if (val) {
|
||||||
int index = p - property_osd_display;
|
int index = p - property_osd_display;
|
||||||
set_osd_tmsg(p->osd_id >= 0 ? p->osd_id : OSD_MSG_PROPERTY + index,
|
set_osd_tmsg(mpctx, p->osd_id >= 0 ? p->osd_id : OSD_MSG_PROPERTY + index,
|
||||||
1, opts->osd_duration, p->osd_msg, val);
|
1, opts->osd_duration, p->osd_msg, val);
|
||||||
talloc_free(val);
|
talloc_free(val);
|
||||||
}
|
}
|
||||||
|
@ -2646,7 +2646,7 @@ static void show_chapters_on_osd(MPContext *mpctx)
|
||||||
talloc_free(name);
|
talloc_free(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
set_osd_msg(OSD_MSG_TEXT, 1, mpctx->opts.osd_duration, "%s", res);
|
set_osd_msg(mpctx, OSD_MSG_TEXT, 1, mpctx->opts.osd_duration, "%s", res);
|
||||||
talloc_free(res);
|
talloc_free(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2696,7 +2696,7 @@ static void show_tracks_on_osd(MPContext *mpctx)
|
||||||
if (v_count > 1)
|
if (v_count > 1)
|
||||||
res = talloc_asprintf_append(res, "\n(Warning: more than one video stream.)\n");
|
res = talloc_asprintf_append(res, "\n(Warning: more than one video stream.)\n");
|
||||||
|
|
||||||
set_osd_msg(OSD_MSG_TEXT, 1, opts->osd_duration, "%s", res);
|
set_osd_msg(mpctx, OSD_MSG_TEXT, 1, opts->osd_duration, "%s", res);
|
||||||
talloc_free(res);
|
talloc_free(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2902,7 +2902,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
|
||||||
(mpctx->video_pts +
|
(mpctx->video_pts +
|
||||||
sub_delay) * 1000 + .5, movement) / 1000.;
|
sub_delay) * 1000 + .5, movement) / 1000.;
|
||||||
#endif
|
#endif
|
||||||
set_osd_tmsg(OSD_MSG_SUB_DELAY, 1, osd_duration,
|
set_osd_tmsg(mpctx, OSD_MSG_SUB_DELAY, 1, osd_duration,
|
||||||
"Sub delay: %d ms", ROUND(sub_delay * 1000));
|
"Sub delay: %d ms", ROUND(sub_delay * 1000));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -2924,17 +2924,17 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
|
||||||
/* Show OSD state when disabled, but not when an explicit
|
/* Show OSD state when disabled, but not when an explicit
|
||||||
argument is given to the OSD command, i.e. in slave mode. */
|
argument is given to the OSD command, i.e. in slave mode. */
|
||||||
if (v == -1 && opts->osd_level <= 1)
|
if (v == -1 && opts->osd_level <= 1)
|
||||||
set_osd_tmsg(OSD_MSG_OSD_STATUS, 0, osd_duration,
|
set_osd_tmsg(mpctx, OSD_MSG_OSD_STATUS, 0, osd_duration,
|
||||||
"OSD: %s",
|
"OSD: %s",
|
||||||
opts->osd_level ? mp_gtext("enabled") :
|
opts->osd_level ? mp_gtext("enabled") :
|
||||||
mp_gtext("disabled"));
|
mp_gtext("disabled"));
|
||||||
else
|
else
|
||||||
rm_osd_msg(OSD_MSG_OSD_STATUS);
|
rm_osd_msg(mpctx, OSD_MSG_OSD_STATUS);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case MP_CMD_OSD_SHOW_TEXT:
|
case MP_CMD_OSD_SHOW_TEXT:
|
||||||
set_osd_msg(OSD_MSG_TEXT, cmd->args[2].v.i,
|
set_osd_msg(mpctx, OSD_MSG_TEXT, cmd->args[2].v.i,
|
||||||
(cmd->args[1].v.i <
|
(cmd->args[1].v.i <
|
||||||
0 ? osd_duration : 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);
|
||||||
|
@ -2946,7 +2946,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
|
||||||
mpctx);
|
mpctx);
|
||||||
// if no argument supplied use default osd_duration, else <arg> ms.
|
// if no argument supplied use default osd_duration, else <arg> ms.
|
||||||
if (txt) {
|
if (txt) {
|
||||||
set_osd_msg(OSD_MSG_TEXT, cmd->args[2].v.i,
|
set_osd_msg(mpctx, OSD_MSG_TEXT, cmd->args[2].v.i,
|
||||||
(cmd->args[1].v.i <
|
(cmd->args[1].v.i <
|
||||||
0 ? osd_duration : cmd->args[1].v.i),
|
0 ? osd_duration : cmd->args[1].v.i),
|
||||||
"%s", txt);
|
"%s", txt);
|
||||||
|
@ -3068,7 +3068,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
|
||||||
#ifdef CONFIG_PVR
|
#ifdef CONFIG_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(OSD_MSG_TV_CHANNEL, 1, osd_duration, "%s: %s",
|
set_osd_msg(mpctx, OSD_MSG_TV_CHANNEL, 1, 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));
|
||||||
}
|
}
|
||||||
|
@ -3082,7 +3082,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
|
||||||
#ifdef CONFIG_PVR
|
#ifdef CONFIG_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(OSD_MSG_TV_CHANNEL, 1, osd_duration, "%s: f %d",
|
set_osd_msg(mpctx, OSD_MSG_TV_CHANNEL, 1, 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));
|
||||||
}
|
}
|
||||||
|
@ -3108,7 +3108,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
|
||||||
TV_CHANNEL_LOWER);
|
TV_CHANNEL_LOWER);
|
||||||
}
|
}
|
||||||
if (tv_channel_list) {
|
if (tv_channel_list) {
|
||||||
set_osd_tmsg(OSD_MSG_TV_CHANNEL, 1, osd_duration,
|
set_osd_tmsg(mpctx, OSD_MSG_TV_CHANNEL, 1, osd_duration,
|
||||||
"Channel: %s", tv_channel_current->name);
|
"Channel: %s", tv_channel_current->name);
|
||||||
//vo_osd_changed(OSDTYPE_SUBTITLE);
|
//vo_osd_changed(OSDTYPE_SUBTITLE);
|
||||||
}
|
}
|
||||||
|
@ -3117,7 +3117,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(OSD_MSG_TV_CHANNEL, 1, osd_duration, "%s: %s",
|
set_osd_msg(mpctx, OSD_MSG_TV_CHANNEL, 1, 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));
|
||||||
}
|
}
|
||||||
|
@ -3147,7 +3147,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
|
||||||
tv_set_channel((tvi_handle_t *) (mpctx->demuxer->priv),
|
tv_set_channel((tvi_handle_t *) (mpctx->demuxer->priv),
|
||||||
cmd->args[0].v.s);
|
cmd->args[0].v.s);
|
||||||
if (tv_channel_list) {
|
if (tv_channel_list) {
|
||||||
set_osd_tmsg(OSD_MSG_TV_CHANNEL, 1, osd_duration,
|
set_osd_tmsg(mpctx, OSD_MSG_TV_CHANNEL, 1, osd_duration,
|
||||||
"Channel: %s", tv_channel_current->name);
|
"Channel: %s", tv_channel_current->name);
|
||||||
//vo_osd_changed(OSDTYPE_SUBTITLE);
|
//vo_osd_changed(OSDTYPE_SUBTITLE);
|
||||||
}
|
}
|
||||||
|
@ -3155,7 +3155,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
|
||||||
#ifdef CONFIG_PVR
|
#ifdef CONFIG_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(OSD_MSG_TV_CHANNEL, 1, osd_duration, "%s: %s",
|
set_osd_msg(mpctx, OSD_MSG_TV_CHANNEL, 1, 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));
|
||||||
}
|
}
|
||||||
|
@ -3180,7 +3180,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
|
||||||
if (mpctx->demuxer && mpctx->file_format == DEMUXER_TYPE_TV) {
|
if (mpctx->demuxer && mpctx->file_format == DEMUXER_TYPE_TV) {
|
||||||
tv_last_channel((tvi_handle_t *) (mpctx->demuxer->priv));
|
tv_last_channel((tvi_handle_t *) (mpctx->demuxer->priv));
|
||||||
if (tv_channel_list) {
|
if (tv_channel_list) {
|
||||||
set_osd_tmsg(OSD_MSG_TV_CHANNEL, 1, osd_duration,
|
set_osd_tmsg(mpctx, OSD_MSG_TV_CHANNEL, 1, osd_duration,
|
||||||
"Channel: %s", tv_channel_current->name);
|
"Channel: %s", tv_channel_current->name);
|
||||||
//vo_osd_changed(OSDTYPE_SUBTITLE);
|
//vo_osd_changed(OSDTYPE_SUBTITLE);
|
||||||
}
|
}
|
||||||
|
@ -3188,7 +3188,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
|
||||||
#ifdef CONFIG_PVR
|
#ifdef CONFIG_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(OSD_MSG_TV_CHANNEL, 1, osd_duration, "%s: %s",
|
set_osd_msg(mpctx, OSD_MSG_TV_CHANNEL, 1, 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));
|
||||||
}
|
}
|
||||||
|
@ -3391,7 +3391,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
|
||||||
mp_dvdnav_update_mouse_pos(mpctx->stream,
|
mp_dvdnav_update_mouse_pos(mpctx->stream,
|
||||||
pointer_x, pointer_y, &button);
|
pointer_x, pointer_y, &button);
|
||||||
if (opts->osd_level > 1 && button > 0)
|
if (opts->osd_level > 1 && button > 0)
|
||||||
set_osd_msg(OSD_MSG_TEXT, 1, osd_duration,
|
set_osd_msg(mpctx, OSD_MSG_TEXT, 1, osd_duration,
|
||||||
"Selected button number %d", button);
|
"Selected button number %d", button);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -3414,7 +3414,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
|
||||||
|
|
||||||
mp_dvdnav_handle_input(mpctx->stream, command, &button);
|
mp_dvdnav_handle_input(mpctx->stream, command, &button);
|
||||||
if (opts->osd_level > 1 && button > 0)
|
if (opts->osd_level > 1 && button > 0)
|
||||||
set_osd_msg(OSD_MSG_TEXT, 1, osd_duration,
|
set_osd_msg(mpctx, OSD_MSG_TEXT, 1, osd_duration,
|
||||||
"Selected button number %d", button);
|
"Selected button number %d", button);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -3432,9 +3432,9 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
|
||||||
mp_msg(MSGT_CPLAYER, MSGL_INFO, "Setting vo cmd line to '%s'.\n",
|
mp_msg(MSGT_CPLAYER, MSGL_INFO, "Setting vo cmd line to '%s'.\n",
|
||||||
s);
|
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(OSD_MSG_TEXT, 1, osd_duration, "vo='%s'", s);
|
set_osd_msg(mpctx, OSD_MSG_TEXT, 1, osd_duration, "vo='%s'", s);
|
||||||
} else {
|
} else {
|
||||||
set_osd_msg(OSD_MSG_TEXT, 1, osd_duration, "Failed!");
|
set_osd_msg(mpctx, OSD_MSG_TEXT, 1, osd_duration, "Failed!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -86,6 +86,7 @@ typedef struct MPContext {
|
||||||
struct mp_fifo *key_fifo;
|
struct mp_fifo *key_fifo;
|
||||||
struct input_ctx *input;
|
struct input_ctx *input;
|
||||||
struct osd_state *osd;
|
struct osd_state *osd;
|
||||||
|
struct mp_osd_msg *osd_msg_stack;
|
||||||
char *terminal_osd_text;
|
char *terminal_osd_text;
|
||||||
struct sub_data *subdata; // current sub_data style subtitles if any
|
struct sub_data *subdata; // current sub_data style subtitles if any
|
||||||
// last sub_data style sub line if any, used by log_sub() only
|
// last sub_data style sub line if any, used by log_sub() only
|
||||||
|
|
6
mp_osd.h
6
mp_osd.h
|
@ -37,9 +37,9 @@
|
||||||
struct MPContext;
|
struct MPContext;
|
||||||
|
|
||||||
void set_osd_bar(struct MPContext *mpctx, int type,const char* name,double min,double max,double val);
|
void set_osd_bar(struct MPContext *mpctx, int type,const char* name,double min,double max,double val);
|
||||||
void set_osd_msg(int id, int level, int time, const char* fmt, ...);
|
void set_osd_msg(struct MPContext *mpctx, int id, int level, int time, const char* fmt, ...);
|
||||||
void set_osd_tmsg(int id, int level, int time, const char* fmt, ...);
|
void set_osd_tmsg(struct MPContext *mpctx, int id, int level, int time, const char* fmt, ...);
|
||||||
void rm_osd_msg(int id);
|
void rm_osd_msg(struct MPContext *mpctx, int id);
|
||||||
void mp_show_osd_progression(struct MPContext *mpctx);
|
void mp_show_osd_progression(struct MPContext *mpctx);
|
||||||
|
|
||||||
#endif /* MPLAYER_MP_OSD_H */
|
#endif /* MPLAYER_MP_OSD_H */
|
||||||
|
|
55
mplayer.c
55
mplayer.c
|
@ -1178,9 +1178,6 @@ struct mp_osd_msg {
|
||||||
unsigned time;
|
unsigned time;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// OSD message stack.
|
|
||||||
static mp_osd_msg_t *osd_msg_stack = NULL;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Add a message on the OSD message stack
|
* \brief Add a message on the OSD message stack
|
||||||
*
|
*
|
||||||
|
@ -1188,23 +1185,23 @@ static mp_osd_msg_t *osd_msg_stack = NULL;
|
||||||
* it is pulled on top of the stack, otherwise a new message is created.
|
* it is pulled on top of the stack, otherwise a new message is created.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static void set_osd_msg_va(int id, int level, int time, const char *fmt,
|
static void set_osd_msg_va(struct MPContext *mpctx, int id, int level, int time,
|
||||||
va_list ap)
|
const char *fmt, va_list ap)
|
||||||
{
|
{
|
||||||
mp_osd_msg_t *msg, *last = NULL;
|
mp_osd_msg_t *msg, *last = NULL;
|
||||||
|
|
||||||
// look if the id is already in the stack
|
// look if the id is already in the stack
|
||||||
for (msg = osd_msg_stack; msg && msg->id != id;
|
for (msg = mpctx->osd_msg_stack; msg && msg->id != id;
|
||||||
last = msg, msg = msg->prev) ;
|
last = msg, msg = msg->prev) ;
|
||||||
// not found: alloc it
|
// not found: alloc it
|
||||||
if (!msg) {
|
if (!msg) {
|
||||||
msg = talloc_zero(NULL, mp_osd_msg_t);
|
msg = talloc_zero(mpctx, mp_osd_msg_t);
|
||||||
msg->prev = osd_msg_stack;
|
msg->prev = mpctx->osd_msg_stack;
|
||||||
osd_msg_stack = msg;
|
mpctx->osd_msg_stack = msg;
|
||||||
} else if (last) { // found, but it's not on top of the stack
|
} else if (last) { // found, but it's not on top of the stack
|
||||||
last->prev = msg->prev;
|
last->prev = msg->prev;
|
||||||
msg->prev = osd_msg_stack;
|
msg->prev = mpctx->osd_msg_stack;
|
||||||
osd_msg_stack = msg;
|
mpctx->osd_msg_stack = msg;
|
||||||
}
|
}
|
||||||
talloc_free(msg->msg);
|
talloc_free(msg->msg);
|
||||||
// write the msg
|
// write the msg
|
||||||
|
@ -1216,19 +1213,21 @@ static void set_osd_msg_va(int id, int level, int time, const char *fmt,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_osd_msg(int id, int level, int time, const char *fmt, ...)
|
void set_osd_msg(struct MPContext *mpctx, int id, int level, int time,
|
||||||
|
const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
set_osd_msg_va(id, level, time, fmt, ap);
|
set_osd_msg_va(mpctx, id, level, time, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_osd_tmsg(int id, int level, int time, const char *fmt, ...)
|
void set_osd_tmsg(struct MPContext *mpctx, int id, int level, int time,
|
||||||
|
const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
set_osd_msg_va(id, level, time, mp_gtext(fmt), ap);
|
set_osd_msg_va(mpctx, id, level, time, mp_gtext(fmt), ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1239,12 +1238,12 @@ void set_osd_tmsg(int id, int level, int time, const char *fmt, ...)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void rm_osd_msg(int id)
|
void rm_osd_msg(struct MPContext *mpctx, int id)
|
||||||
{
|
{
|
||||||
mp_osd_msg_t *msg, *last = NULL;
|
mp_osd_msg_t *msg, *last = NULL;
|
||||||
|
|
||||||
// Search for the msg
|
// Search for the msg
|
||||||
for (msg = osd_msg_stack; msg && msg->id != id;
|
for (msg = mpctx->osd_msg_stack; msg && msg->id != id;
|
||||||
last = msg, msg = msg->prev) ;
|
last = msg, msg = msg->prev) ;
|
||||||
if (!msg)
|
if (!msg)
|
||||||
return;
|
return;
|
||||||
|
@ -1253,7 +1252,7 @@ void rm_osd_msg(int id)
|
||||||
if (last)
|
if (last)
|
||||||
last->prev = msg->prev;
|
last->prev = msg->prev;
|
||||||
else
|
else
|
||||||
osd_msg_stack = msg->prev;
|
mpctx->osd_msg_stack = msg->prev;
|
||||||
talloc_free(msg);
|
talloc_free(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1262,15 +1261,15 @@ void rm_osd_msg(int id)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void clear_osd_msgs(void)
|
static void clear_osd_msgs(struct MPContext *mpctx)
|
||||||
{
|
{
|
||||||
mp_osd_msg_t *msg = osd_msg_stack, *prev = NULL;
|
mp_osd_msg_t *msg = mpctx->osd_msg_stack, *prev = NULL;
|
||||||
while (msg) {
|
while (msg) {
|
||||||
prev = msg->prev;
|
prev = msg->prev;
|
||||||
talloc_free(msg);
|
talloc_free(msg);
|
||||||
msg = prev;
|
msg = prev;
|
||||||
}
|
}
|
||||||
osd_msg_stack = NULL;
|
mpctx->osd_msg_stack = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1308,7 +1307,7 @@ static mp_osd_msg_t *get_osd_msg(struct MPContext *mpctx)
|
||||||
last_update = now;
|
last_update = now;
|
||||||
|
|
||||||
// Look for the first message in the stack with high enough level.
|
// Look for the first message in the stack with high enough level.
|
||||||
for (msg = osd_msg_stack; msg; last = msg, msg = prev) {
|
for (msg = mpctx->osd_msg_stack; msg; last = msg, msg = prev) {
|
||||||
prev = msg->prev;
|
prev = msg->prev;
|
||||||
if (msg->level > opts->osd_level && hidden_dec_done)
|
if (msg->level > opts->osd_level && hidden_dec_done)
|
||||||
continue;
|
continue;
|
||||||
|
@ -1331,7 +1330,7 @@ static mp_osd_msg_t *get_osd_msg(struct MPContext *mpctx)
|
||||||
last->prev = prev;
|
last->prev = prev;
|
||||||
msg = last;
|
msg = last;
|
||||||
} else {
|
} else {
|
||||||
osd_msg_stack = prev;
|
mpctx->osd_msg_stack = prev;
|
||||||
msg = NULL;
|
msg = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1361,7 +1360,7 @@ void set_osd_bar(struct MPContext *mpctx, int type, const char *name,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
set_osd_msg(OSD_MSG_BAR, 1, opts->osd_duration, "%s: %d %%",
|
set_osd_msg(mpctx, OSD_MSG_BAR, 1, opts->osd_duration, "%s: %d %%",
|
||||||
name, ROUND(100 * (val - min) / (max - min)));
|
name, ROUND(100 * (val - min) / (max - min)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1377,12 +1376,12 @@ void set_osd_subtitle(struct MPContext *mpctx, subtitle *subs)
|
||||||
// reverse order, since newest set_osd_msg is displayed first
|
// reverse order, since newest set_osd_msg is displayed first
|
||||||
for (i = SUB_MAX_TEXT - 1; i >= 0; i--) {
|
for (i = SUB_MAX_TEXT - 1; i >= 0; i--) {
|
||||||
if (!subs || i >= subs->lines || !subs->text[i])
|
if (!subs || i >= subs->lines || !subs->text[i])
|
||||||
rm_osd_msg(OSD_MSG_SUB_BASE + i);
|
rm_osd_msg(mpctx, OSD_MSG_SUB_BASE + i);
|
||||||
else {
|
else {
|
||||||
// HACK: currently display time for each sub line
|
// HACK: currently display time for each sub line
|
||||||
// except the last is set to 2 seconds.
|
// except the last is set to 2 seconds.
|
||||||
int display_time = i == subs->lines - 1 ? 180000 : 2000;
|
int display_time = i == subs->lines - 1 ? 180000 : 2000;
|
||||||
set_osd_msg(OSD_MSG_SUB_BASE + i, 1, display_time,
|
set_osd_msg(mpctx, OSD_MSG_SUB_BASE + i, 1, display_time,
|
||||||
"%s", subs->text[i]);
|
"%s", subs->text[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1470,7 +1469,7 @@ void mp_show_osd_progression(struct MPContext *mpctx)
|
||||||
int len = sizeof(text);
|
int len = sizeof(text);
|
||||||
|
|
||||||
sadd_osd_status(text, len, mpctx, true);
|
sadd_osd_status(text, len, mpctx, true);
|
||||||
set_osd_msg(OSD_MSG_TEXT, 1, mpctx->opts.osd_duration, "%s", text);
|
set_osd_msg(mpctx, OSD_MSG_TEXT, 1, mpctx->opts.osd_duration, "%s", text);
|
||||||
|
|
||||||
set_osd_bar(mpctx, 0, "Position", 0, 100, get_percent_pos(mpctx));
|
set_osd_bar(mpctx, 0, "Position", 0, 100, get_percent_pos(mpctx));
|
||||||
}
|
}
|
||||||
|
@ -3855,7 +3854,7 @@ goto_enable_cache:
|
||||||
opts->term_osd = 0;
|
opts->term_osd = 0;
|
||||||
|
|
||||||
// Make sure old OSD does not stay around
|
// Make sure old OSD does not stay around
|
||||||
clear_osd_msgs();
|
clear_osd_msgs(mpctx);
|
||||||
|
|
||||||
//================ SETUP STREAMS ==========================
|
//================ SETUP STREAMS ==========================
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue