Skip to content

Commit

Permalink
player/osd: don't add newlines when message would be empty anyway
Browse files Browse the repository at this point in the history
When only control char is present there is no point to add part for it.
  • Loading branch information
kasper93 committed Oct 20, 2024
1 parent 8164783 commit bcf169a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions player/osd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit bcf169a

Please sign in to comment.