Skip to content

Commit

Permalink
command: print lang in track-list
Browse files Browse the repository at this point in the history
  • Loading branch information
guidocella authored and kasper93 committed Oct 24, 2024
1 parent b1037f5 commit f0a852c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
12 changes: 9 additions & 3 deletions player/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -2102,7 +2102,7 @@ static char *append_track_info(char *res, struct track *track)
{
res = talloc_strdup_append(res, track->selected ? list_current : list_normal);
res = talloc_asprintf_append(res, "(%d) ", track->user_tid);
res = talloc_strdup_append(res, mp_format_track_metadata(res, track));
res = talloc_strdup_append(res, mp_format_track_metadata(res, track, true));

return res;
}
Expand All @@ -2113,7 +2113,7 @@ static char *append_track_info(char *res, struct track *track)
first = false; \
} while(0)

char *mp_format_track_metadata(void *ctx, struct track *t)
char *mp_format_track_metadata(void *ctx, struct track *t, bool add_lang)
{
struct sh_stream *s = t->stream;
bstr dst = {0};
Expand All @@ -2122,7 +2122,13 @@ char *mp_format_track_metadata(void *ctx, struct track *t)
bstr_xappend_asprintf(ctx, &dst, " '%s'", t->title);

const char *codec = s ? s->codec->codec : NULL;
bstr_xappend_asprintf(ctx, &dst, " (%s", codec ? codec : "<unknown>");

bstr_xappend0(ctx, &dst, " (");

if (add_lang && t->lang)
bstr_xappend_asprintf(ctx, &dst, "%s ", t->lang);

bstr_xappend0(ctx, &dst, codec ? codec : "<unknown>");

if (s && s->codec->codec_profile)
bstr_xappend_asprintf(ctx, &dst, " [%s]", s->codec->codec_profile);
Expand Down
2 changes: 1 addition & 1 deletion player/command.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,6 @@ void mp_abort_cache_dumping(struct MPContext *mpctx);
// U+25CF BLACK CIRCLE
#define WHITE_CIRCLE "\xe2\x97\x8b"
#define BLACK_CIRCLE "\xe2\x97\x8f"
char *mp_format_track_metadata(void *ctx, struct track *t);
char *mp_format_track_metadata(void *ctx, struct track *t, bool add_lang);

#endif /* MPLAYER_COMMAND_H */
2 changes: 1 addition & 1 deletion player/loadfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ static void print_stream(struct MPContext *mpctx, struct track *t, bool indent)
}

void *ctx = talloc_new(NULL);
APPEND(b, " %s", mp_format_track_metadata(ctx, t));
APPEND(b, " %s", mp_format_track_metadata(ctx, t, false));
talloc_free(ctx);

MP_INFO(mpctx, "%s\n", b);
Expand Down

0 comments on commit f0a852c

Please sign in to comment.