mirror of https://github.com/mpv-player/mpv
osd: add setting to display OSD always on terminal
Now the option --term-osd=force will cause mplayer to display all OSD messages on the terminal, even if there is video. Possible values for --term-osd: - auto: use video OSD, or of there's no video, the terminal (default) - off: always use video for OSD - force: always use terminal for OSD -term-osd and --term-osd are equivalent to --term-osd=force. This changes the meaning of the option, since -term-osd used to enable the OSD default behavior, i.e. --term-osd=auto. -noterm-osd has the same effect as --term-osd=off, and is kept for compatibility. Implementation note: The location for the OSD text was shared between the two code paths (it was in osd_state.osd_text). We can't rely on the fact that the video-OSD update code normally isn't run when --term-osd is called. When e.g. panscan is updated, the video OSD code will draw the OSD anyway. This would sometimes show unwanted OSD text on the video. Deal with this by putting the current terminal-OSD text in a different place (in MPContext.terminal_osd_text) to deal with this.
This commit is contained in:
parent
6340b54d5c
commit
fee4d3b473
|
@ -907,7 +907,15 @@ const m_option_t mplayer_opts[]={
|
||||||
OPT_STRING("rtc-device", rtc_device, 0),
|
OPT_STRING("rtc-device", rtc_device, 0),
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
OPT_MAKE_FLAGS("term-osd", term_osd, 0),
|
OPT_CHOICE("term-osd", term_osd, M_OPT_IMPLICIT_DEFAULT,
|
||||||
|
({"force", 1},
|
||||||
|
{"auto", 2},
|
||||||
|
{"off", 0})),
|
||||||
|
|
||||||
|
// set term_osd to 0
|
||||||
|
// this is for compatibility
|
||||||
|
{"noterm-osd", NULL, &m_option_type_flag, 0, 1, 0, NULL, 1, offsetof(struct MPOpts, term_osd)},
|
||||||
|
|
||||||
OPT_STRING("term-osd-esc", term_osd_esc, 0),
|
OPT_STRING("term-osd-esc", term_osd_esc, 0),
|
||||||
OPT_STRING("playing-msg", playing_msg, 0),
|
OPT_STRING("playing-msg", playing_msg, 0),
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ void set_default_mplayer_options(struct MPOpts *opts)
|
||||||
.edition_id = -1,
|
.edition_id = -1,
|
||||||
.user_correct_pts = -1,
|
.user_correct_pts = -1,
|
||||||
.initial_audio_sync = 1,
|
.initial_audio_sync = 1,
|
||||||
.term_osd = 1,
|
.term_osd = 2,
|
||||||
.term_osd_esc = "\x1b[A\r\x1b[K",
|
.term_osd_esc = "\x1b[A\r\x1b[K",
|
||||||
.consolecontrols = 1,
|
.consolecontrols = 1,
|
||||||
.doubleclick_time = 300,
|
.doubleclick_time = 300,
|
||||||
|
|
|
@ -90,6 +90,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;
|
||||||
|
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
|
||||||
struct subtitle *vo_sub_last;
|
struct subtitle *vo_sub_last;
|
||||||
|
|
26
mplayer.c
26
mplayer.c
|
@ -1610,7 +1610,7 @@ void set_osd_bar(struct MPContext *mpctx, int type, const char *name,
|
||||||
if (opts->osd_level < 1)
|
if (opts->osd_level < 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (mpctx->sh_video) {
|
if (mpctx->sh_video && opts->term_osd != 1) {
|
||||||
mpctx->osd_visible = (GetTimerMS() + 1000) | 1;
|
mpctx->osd_visible = (GetTimerMS() + 1000) | 1;
|
||||||
vo_osd_progbar_type = type;
|
vo_osd_progbar_type = type;
|
||||||
vo_osd_progbar_value = 256 * (val - min) / (max - min);
|
vo_osd_progbar_value = 256 * (val - min) / (max - min);
|
||||||
|
@ -1665,25 +1665,30 @@ static void update_osd_msg(struct MPContext *mpctx)
|
||||||
if (mpctx->add_osd_seek_info) {
|
if (mpctx->add_osd_seek_info) {
|
||||||
double percentage = get_percent_pos(mpctx);
|
double percentage = get_percent_pos(mpctx);
|
||||||
set_osd_bar(mpctx, 0, "Position", 0, 100, percentage);
|
set_osd_bar(mpctx, 0, "Position", 0, 100, percentage);
|
||||||
if (mpctx->sh_video)
|
if (mpctx->sh_video && opts->term_osd != 1)
|
||||||
mpctx->osd_show_percentage_until = (GetTimerMS() + 1000) | 1;
|
mpctx->osd_show_percentage_until = (GetTimerMS() + 1000) | 1;
|
||||||
mpctx->add_osd_seek_info = false;
|
mpctx->add_osd_seek_info = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Look if we have a msg
|
// Look if we have a msg
|
||||||
if ((msg = get_osd_msg(mpctx))) {
|
if ((msg = get_osd_msg(mpctx))) {
|
||||||
if (strcmp(osd->osd_text, msg->msg)) {
|
if (mpctx->sh_video && opts->term_osd != 1) {
|
||||||
osd_set_text(osd, msg->msg);
|
if (strcmp(osd->osd_text, msg->msg)) {
|
||||||
if (mpctx->sh_video)
|
osd_set_text(osd, msg->msg);
|
||||||
vo_osd_changed(OSDTYPE_OSD);
|
vo_osd_changed(OSDTYPE_OSD);
|
||||||
else if (opts->term_osd)
|
}
|
||||||
|
} else if (opts->term_osd) {
|
||||||
|
if (strcmp(mpctx->terminal_osd_text, msg->msg)) {
|
||||||
|
talloc_free(mpctx->terminal_osd_text);
|
||||||
|
mpctx->terminal_osd_text = talloc_strdup(mpctx, msg->msg);
|
||||||
mp_msg(MSGT_CPLAYER, MSGL_STATUS, "%s%s\n", opts->term_osd_esc,
|
mp_msg(MSGT_CPLAYER, MSGL_STATUS, "%s%s\n", opts->term_osd_esc,
|
||||||
msg->msg);
|
mpctx->terminal_osd_text);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mpctx->sh_video) {
|
if (mpctx->sh_video && opts->term_osd != 1) {
|
||||||
// fallback on the timer
|
// fallback on the timer
|
||||||
if (opts->osd_level >= 2) {
|
if (opts->osd_level >= 2) {
|
||||||
int len = get_time_length(mpctx);
|
int len = get_time_length(mpctx);
|
||||||
|
@ -1748,8 +1753,8 @@ static void update_osd_msg(struct MPContext *mpctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear the term osd line
|
// Clear the term osd line
|
||||||
if (opts->term_osd && osd->osd_text[0]) {
|
if (opts->term_osd && mpctx->terminal_osd_text[0]) {
|
||||||
osd->osd_text[0] = 0;
|
mpctx->terminal_osd_text[0] = '\0';
|
||||||
printf("%s\n", opts->term_osd_esc);
|
printf("%s\n", opts->term_osd_esc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3962,6 +3967,7 @@ int main(int argc, char *argv[])
|
||||||
.file_format = DEMUXER_TYPE_UNKNOWN,
|
.file_format = DEMUXER_TYPE_UNKNOWN,
|
||||||
.last_dvb_step = 1,
|
.last_dvb_step = 1,
|
||||||
.paused_cache_fill = -1,
|
.paused_cache_fill = -1,
|
||||||
|
.terminal_osd_text = talloc_strdup(mpctx, ""),
|
||||||
};
|
};
|
||||||
|
|
||||||
InitTimer();
|
InitTimer();
|
||||||
|
|
Loading…
Reference in New Issue