From cd62cc7ecb9f1c7a05349025d329872a3ada1456 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Sun, 20 Oct 2024 22:15:08 +0200 Subject: [PATCH] player/osd: don't add newlines when message would be empty anyway When only control char is present there is no point to add part for it. --- player/osd.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/player/osd.c b/player/osd.c index 3ed0dbeab0..52677d15f3 100644 --- a/player/osd.c +++ b/player/osd.c @@ -67,6 +67,11 @@ static char *join_lines(void *ta_ctx, char **parts, int num_parts) return res; } +static bool term_osd_empty(char *text) +{ + return !text || !text[0] || !strcmp(text, TERM_MSG_0); +} + static void term_osd_update(struct MPContext *mpctx) { int num_parts = 0; @@ -75,11 +80,11 @@ static void term_osd_update(struct MPContext *mpctx) if (!mpctx->opts->use_terminal) return; - if (mpctx->term_osd_subs && mpctx->term_osd_subs[0]) + if (!term_osd_empty(mpctx->term_osd_subs)) parts[num_parts++] = mpctx->term_osd_subs; - if (mpctx->term_osd_text && mpctx->term_osd_text[0]) + if (!term_osd_empty(mpctx->term_osd_text)) parts[num_parts++] = mpctx->term_osd_text; - if (mpctx->term_osd_status && mpctx->term_osd_status[0]) + if (!term_osd_empty(mpctx->term_osd_status)) parts[num_parts++] = mpctx->term_osd_status; char *s = join_lines(mpctx, parts, num_parts);