ao_alsa: add an option to ignore ALSA channel map negotiation

This was requested, more or less.
This commit is contained in:
wm4 2015-03-28 23:53:49 +01:00
parent 36d1b28849
commit b561ec99ff
2 changed files with 14 additions and 2 deletions

View File

@ -55,6 +55,14 @@ Available audio output drivers are:
Allow output of non-interleaved formats (if the audio decoder uses Allow output of non-interleaved formats (if the audio decoder uses
this format). Currently disabled by default, because some popular this format). Currently disabled by default, because some popular
ALSA plugins are utterly broken with non-interleaved formats. ALSA plugins are utterly broken with non-interleaved formats.
``ingore-chmap``
Don't read or set the channel map of the ALSA device - only request the
required number of channels, and then pass the audio as-is to it. This
option most likely should not be used. It can be useful for debugging,
or for static setups with a specially engineered ALSA configuration (in
this case you should always force the same layout with ``--audio-channels``,
or it will work only for files which use the layout implicit to your
ALSA device).
.. note:: .. note::

View File

@ -64,6 +64,7 @@ struct priv {
int cfg_mixer_index; int cfg_mixer_index;
int cfg_resample; int cfg_resample;
int cfg_ni; int cfg_ni;
int cfg_ignore_chmap;
}; };
#define BUFFER_TIME 250000 // 250ms #define BUFFER_TIME 250000 // 250ms
@ -478,7 +479,7 @@ static int init_device(struct ao *ao)
CHECK_ALSA_ERROR("Unable to set access type"); CHECK_ALSA_ERROR("Unable to set access type");
struct mp_chmap dev_chmap = ao->channels; struct mp_chmap dev_chmap = ao->channels;
if (AF_FORMAT_IS_IEC61937(ao->format)) { if (AF_FORMAT_IS_IEC61937(ao->format) || p->cfg_ignore_chmap) {
dev_chmap.num = 0; // disable chmap API dev_chmap.num = 0; // disable chmap API
} else if (query_chmaps(ao, &dev_chmap)) { } else if (query_chmaps(ao, &dev_chmap)) {
ao->channels = dev_chmap; ao->channels = dev_chmap;
@ -571,7 +572,9 @@ static int init_device(struct ao *ao)
MP_VERBOSE(ao, "which we understand as: %s\n", mp_chmap_to_str(&chmap)); MP_VERBOSE(ao, "which we understand as: %s\n", mp_chmap_to_str(&chmap));
if (AF_FORMAT_IS_IEC61937(ao->format)) { if (p->cfg_ignore_chmap) {
MP_VERBOSE(ao, "user set ignore-chmap; ignoring the channel map.\n");
} else if (AF_FORMAT_IS_IEC61937(ao->format)) {
MP_VERBOSE(ao, "using spdif passthrough; ignoring the channel map.\n"); MP_VERBOSE(ao, "using spdif passthrough; ignoring the channel map.\n");
} else if (mp_chmap_is_valid(&chmap)) { } else if (mp_chmap_is_valid(&chmap)) {
if (mp_chmap_equals(&chmap, &ao->channels)) { if (mp_chmap_equals(&chmap, &ao->channels)) {
@ -934,6 +937,7 @@ const struct ao_driver audio_out_alsa = {
OPT_STRING("mixer-name", cfg_mixer_name, 0), OPT_STRING("mixer-name", cfg_mixer_name, 0),
OPT_INTRANGE("mixer-index", cfg_mixer_index, 0, 0, 99), OPT_INTRANGE("mixer-index", cfg_mixer_index, 0, 0, 99),
OPT_FLAG("non-interleaved", cfg_ni, 0), OPT_FLAG("non-interleaved", cfg_ni, 0),
OPT_FLAG("ignore-chmap", cfg_ignore_chmap, 0),
{0} {0}
}, },
}; };