From 3fa76c84bee5786518d8fb855d0c36f8598263d9 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 29 Nov 2015 17:51:48 +0100 Subject: osd: do not let OSD messages overwrite --osd-msgN text Requested. Don't overwrite permanent OSD text set with e.g. --osd-msg1. Instead, append the OSD message to it (on the next line). Note that with --osd-msg1, seeking will still overwrite the OSD with the playback status for a while. If you do not want this, use --osd-msg3 --osd-level=3 instead. --- player/osd.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/player/osd.c b/player/osd.c index 353c301942..da1fb41521 100644 --- a/player/osd.c +++ b/player/osd.c @@ -116,7 +116,8 @@ void term_osd_set_subs(struct MPContext *mpctx, const char *text) static void term_osd_set_text(struct MPContext *mpctx, const char *text) { - if ((mpctx->video_out && mpctx->opts->term_osd != 1) || !mpctx->opts->term_osd) + if ((mpctx->video_out && mpctx->opts->term_osd != 1) || + !mpctx->opts->term_osd || !text) text = ""; // disable talloc_free(mpctx->term_osd_text); mpctx->term_osd_text = talloc_strdup(mpctx, text); @@ -543,26 +544,19 @@ void update_osd_msg(struct MPContext *mpctx) update_osd_bar(mpctx, OSD_BAR_SEEK, 0, 1, MPCLAMP(pos, 0, 1)); } + term_osd_set_text(mpctx, mpctx->osd_msg_text); print_status(mpctx); - // Look if we have a msg - if (mpctx->osd_msg_text && !mpctx->osd_show_pos) { - osd_set_text(osd, OSDTYPE_OSD, mpctx->osd_msg_text); - term_osd_set_text(mpctx, mpctx->osd_msg_text); - return; - } - int osd_level = opts->osd_level; - if (mpctx->osd_msg_text && mpctx->osd_show_pos) + if (mpctx->osd_show_pos) osd_level = 3; - // clear, or if OSD level demands it, show the status char *text = NULL; sadd_osd_status(&text, mpctx, osd_level); - + if (mpctx->osd_msg_text && mpctx->osd_msg_text[0]) { + text = talloc_asprintf_append(text, "%s%s", text ? "\n" : "", + mpctx->osd_msg_text); + } osd_set_text(osd, OSDTYPE_OSD, text); talloc_free(text); - - // always clear (term-osd has separate status line) - term_osd_set_text(mpctx, ""); } -- cgit v1.2.3