command: print lang in track-list

This commit is contained in:
Guido Cella 2024-10-24 13:58:07 +02:00 committed by Kacper Michajłow
parent b1037f5d63
commit f0a852cda3
3 changed files with 11 additions and 5 deletions

View File

@ -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_strdup_append(res, track->selected ? list_current : list_normal);
res = talloc_asprintf_append(res, "(%d) ", track->user_tid); 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; return res;
} }
@ -2113,7 +2113,7 @@ static char *append_track_info(char *res, struct track *track)
first = false; \ first = false; \
} while(0) } 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; struct sh_stream *s = t->stream;
bstr dst = {0}; bstr dst = {0};
@ -2122,7 +2122,13 @@ char *mp_format_track_metadata(void *ctx, struct track *t)
bstr_xappend_asprintf(ctx, &dst, " '%s'", t->title); bstr_xappend_asprintf(ctx, &dst, " '%s'", t->title);
const char *codec = s ? s->codec->codec : NULL; 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) if (s && s->codec->codec_profile)
bstr_xappend_asprintf(ctx, &dst, " [%s]", s->codec->codec_profile); bstr_xappend_asprintf(ctx, &dst, " [%s]", s->codec->codec_profile);

View File

@ -126,6 +126,6 @@ void mp_abort_cache_dumping(struct MPContext *mpctx);
// U+25CF BLACK CIRCLE // U+25CF BLACK CIRCLE
#define WHITE_CIRCLE "\xe2\x97\x8b" #define WHITE_CIRCLE "\xe2\x97\x8b"
#define BLACK_CIRCLE "\xe2\x97\x8f" #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 */ #endif /* MPLAYER_COMMAND_H */

View File

@ -272,7 +272,7 @@ static void print_stream(struct MPContext *mpctx, struct track *t, bool indent)
} }
void *ctx = talloc_new(NULL); 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); talloc_free(ctx);
MP_INFO(mpctx, "%s\n", b); MP_INFO(mpctx, "%s\n", b);