diff options
author | wm4 <wm4@nowhere> | 2015-06-25 19:10:24 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-06-25 19:10:24 +0200 |
commit | 5a3cdb8f1e8b14daf11d44ef729a2484982b7305 (patch) | |
tree | 57369f90adb2e163dffc86b2649e7ba1d0f08077 /audio/chmap.c | |
parent | fd1194de3c4b14126269f2db918c0f8bcf2bf34a (diff) | |
download | mpv-5a3cdb8f1e8b14daf11d44ef729a2484982b7305.tar.bz2 mpv-5a3cdb8f1e8b14daf11d44ef729a2484982b7305.tar.xz |
audio: output human-readable channel layouts too
This gets you the "logical" channel layout, instead of the exact thing
we're sending to the AO. (Tired of the cryptic shit ALSA gives me.)
Diffstat (limited to 'audio/chmap.c')
-rw-r--r-- | audio/chmap.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/audio/chmap.c b/audio/chmap.c index 3bc2d2b15a..82f748b1cd 100644 --- a/audio/chmap.c +++ b/audio/chmap.c @@ -508,6 +508,25 @@ bool mp_chmap_from_str(struct mp_chmap *dst, bstr src) return true; } +// Output a human readable "canonical" channel map string. Converting this from +// a string back to a channel map can yield a different map, but the string +// looks nicer. E.g. "fc-fl-fr-na" becomes "3.0". +char *mp_chmap_to_str_hr_buf(char *buf, size_t buf_size, const struct mp_chmap *src) +{ + struct mp_chmap map = *src; + mp_chmap_remove_na(&map); + for (int n = 0; std_layout_names[n][0]; n++) { + struct mp_chmap s; + if (mp_chmap_from_str(&s, bstr0(std_layout_names[n][0])) && + mp_chmap_equals_reordered(&s, &map)) + { + map = s; + break; + } + } + return mp_chmap_to_str_buf(buf, buf_size, &map); +} + void mp_chmap_print_help(struct mp_log *log) { mp_info(log, "Speakers:\n"); |