mirror of
https://github.com/mpv-player/mpv
synced 2025-04-01 14:50:07 +00:00
audio: print channel map additionally to channel count on terminal
This commit is contained in:
parent
bc03eb0295
commit
3b1956608d
@ -17,6 +17,7 @@
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "core/mp_talloc.h"
|
||||
#include "audio.h"
|
||||
|
||||
void mp_audio_set_format(struct mp_audio *mpa, int format)
|
||||
@ -54,3 +55,17 @@ void mp_audio_copy_config(struct mp_audio *dst, const struct mp_audio *src)
|
||||
mp_audio_set_channels(dst, &src->channels);
|
||||
dst->rate = src->rate;
|
||||
}
|
||||
|
||||
char *mp_audio_fmt_to_str(int srate, const struct mp_chmap *chmap, int format)
|
||||
{
|
||||
char *chstr = mp_chmap_to_str(chmap);
|
||||
char *res = talloc_asprintf(NULL, "%dHz %s %dch %s", srate, chstr,
|
||||
chmap->num, af_fmt2str_short(format));
|
||||
talloc_free(chstr);
|
||||
return res;
|
||||
}
|
||||
|
||||
char *mp_audio_config_to_str(struct mp_audio *mpa)
|
||||
{
|
||||
return mp_audio_fmt_to_str(mpa->rate, &mpa->channels, mpa->format);
|
||||
}
|
||||
|
@ -39,4 +39,7 @@ void mp_audio_set_channels_old(struct mp_audio *mpa, int num_channels);
|
||||
void mp_audio_set_channels(struct mp_audio *mpa, const struct mp_chmap *chmap);
|
||||
void mp_audio_copy_config(struct mp_audio *dst, const struct mp_audio *src);
|
||||
|
||||
char *mp_audio_fmt_to_str(int srate, const struct mp_chmap *chmap, int format);
|
||||
char *mp_audio_config_to_str(struct mp_audio *mpa);
|
||||
|
||||
#endif
|
||||
|
@ -218,11 +218,12 @@ int init_audio_filters(sh_audio_t *sh_audio, int in_samplerate,
|
||||
// filter config:
|
||||
memcpy(&afs->cfg, &af_cfg, sizeof(struct af_cfg));
|
||||
|
||||
char *s_from = mp_audio_config_to_str(&afs->input);
|
||||
char *s_to = mp_audio_config_to_str(&afs->output);
|
||||
mp_tmsg(MSGT_DECAUDIO, MSGL_V,
|
||||
"Building audio filter chain for %dHz/%dch/%s -> %dHz/%dch/%s...\n",
|
||||
afs->input.rate, afs->input.nch,
|
||||
af_fmt2str_short(afs->input.format), afs->output.rate,
|
||||
afs->output.nch, af_fmt2str_short(afs->output.format));
|
||||
"Building audio filter chain for %s -> %s...\n", s_from, s_to);
|
||||
talloc_free(s_from);
|
||||
talloc_free(s_to);
|
||||
|
||||
// let's autoprobe it!
|
||||
if (0 != af_init(afs)) {
|
||||
|
@ -301,18 +301,6 @@ repeat:
|
||||
}
|
||||
}
|
||||
|
||||
static void print_fmt(struct mp_audio *d, int msg_level)
|
||||
{
|
||||
if (d) {
|
||||
char *chstr = mp_chmap_to_str(&d->channels);
|
||||
mp_msg(MSGT_AFILTER, msg_level, "%dHz/%s(%dch)/%s", d->rate,
|
||||
chstr ? chstr : "?", d->nch,
|
||||
af_fmt2str_short(d->format));
|
||||
talloc_free(chstr);
|
||||
} else
|
||||
mp_msg(MSGT_AFILTER, msg_level, "(?)");
|
||||
}
|
||||
|
||||
static void af_print_filter_chain(struct af_stream *s, struct af_instance *at,
|
||||
int msg_level)
|
||||
{
|
||||
@ -321,7 +309,11 @@ static void af_print_filter_chain(struct af_stream *s, struct af_instance *at,
|
||||
struct af_instance *af = s->first;
|
||||
while (af) {
|
||||
mp_msg(MSGT_AFILTER, msg_level, " [%s] ", af->info->name);
|
||||
print_fmt(af->data, msg_level);
|
||||
if (af->data) {
|
||||
char *info = mp_audio_config_to_str(af->data);
|
||||
mp_msg(MSGT_AFILTER, msg_level, "%s", info);
|
||||
talloc_free(info);
|
||||
}
|
||||
if (af == at)
|
||||
mp_msg(MSGT_AFILTER, msg_level, " <-");
|
||||
mp_msg(MSGT_AFILTER, msg_level, "\n");
|
||||
@ -330,8 +322,9 @@ static void af_print_filter_chain(struct af_stream *s, struct af_instance *at,
|
||||
}
|
||||
|
||||
mp_msg(MSGT_AFILTER, msg_level, " [ao] ");
|
||||
print_fmt(&s->output, msg_level);
|
||||
mp_msg(MSGT_AFILTER, msg_level, "\n");
|
||||
char *info = mp_audio_config_to_str(&s->output);
|
||||
mp_msg(MSGT_AFILTER, msg_level, "%s\n", info);
|
||||
talloc_free(info);
|
||||
}
|
||||
|
||||
static const char *af_find_conversion_filter(int srcfmt, int dstfmt)
|
||||
|
@ -1593,12 +1593,10 @@ void reinit_audio_chain(struct MPContext *mpctx)
|
||||
goto init_error;
|
||||
}
|
||||
ao->buffer.start = talloc_new(ao);
|
||||
mp_msg(MSGT_CPLAYER, MSGL_INFO,
|
||||
"AO: [%s] %dHz %dch %s (%d bytes per sample)\n",
|
||||
ao->driver->info->short_name,
|
||||
ao->samplerate, ao->channels.num,
|
||||
af_fmt2str_short(ao->format),
|
||||
af_fmt2bits(ao->format) / 8);
|
||||
char *s = mp_audio_fmt_to_str(ao->samplerate, &ao->channels, ao->format);
|
||||
mp_msg(MSGT_CPLAYER, MSGL_INFO, "AO: [%s] %s\n",
|
||||
ao->driver->info->short_name, s);
|
||||
talloc_free(s);
|
||||
mp_msg(MSGT_CPLAYER, MSGL_V, "AO: Description: %s\nAO: Author: %s\n",
|
||||
ao->driver->info->name, ao->driver->info->author);
|
||||
if (strlen(ao->driver->info->comment) > 0)
|
||||
|
Loading…
Reference in New Issue
Block a user