diff options
author | wm4 <wm4@nowhere> | 2016-08-04 20:49:20 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2016-08-04 20:49:20 +0200 |
commit | 0b144eac39bbae51c3f2b7683f6982eb91b66393 (patch) | |
tree | 63f0585f4dece4195da5745a4969159d9b5d8122 /demux/demux_raw.c | |
parent | c30aa2340132e50994cdf168aaba011ecb4f6b0c (diff) | |
download | mpv-0b144eac39bbae51c3f2b7683f6982eb91b66393.tar.bz2 mpv-0b144eac39bbae51c3f2b7683f6982eb91b66393.tar.xz |
audio: use --audio-channels=auto behavior, except on ALSA
This commit adds an --audio-channel=auto-safe mode, and makes it the
default. This mode behaves like "auto" with most AOs, except with
ao_alsa. The intention is to allow multichannel output by default on
sane APIs. ALSA is not sane as in it's so low level that it will e.g.
configure any layout over HDMI, even if the connected A/V receiver does
not support it. The HDMI fuckup is of course not ALSA's fault, but other
audio APIs normally isolate applications from dealing with this and
require the user to globally configure the correct output layout.
This will help with other AOs too. ao_lavc (encoding) is changed to the
new semantics as well, because it used to force stereo (perhaps because
encoding mode is supposed to produce safe files for crap devices?).
Exclusive mode output on Windows might need to be adjusted accordingly,
as it grants the same kind of low level access as ALSA (requires more
research).
In addition to the things mentioned above, the --audio-channels option
is extended to accept a set of channel layouts. This is supposed to be
the correct way to configure mpv ALSA multichannel output. You need to
put a list of channel layouts that your A/V receiver supports.
Diffstat (limited to 'demux/demux_raw.c')
-rw-r--r-- | demux/demux_raw.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/demux/demux_raw.c b/demux/demux_raw.c index e4cf596768..bd8e11306d 100644 --- a/demux/demux_raw.c +++ b/demux/demux_raw.c @@ -36,7 +36,7 @@ #include "osdep/endian.h" struct demux_rawaudio_opts { - struct mp_chmap channels; + struct m_channels channels; int samplerate; int aformat; }; @@ -49,7 +49,7 @@ struct demux_rawaudio_opts { #define OPT_BASE_STRUCT struct demux_rawaudio_opts const struct m_sub_options demux_rawaudio_conf = { .opts = (const m_option_t[]) { - OPT_CHMAP("channels", channels, CONF_MIN, .min = 1), + OPT_CHANNELS("channels", channels, 0, .min = 1), OPT_INTRANGE("rate", samplerate, 0, 1000, 8 * 48000), OPT_CHOICE("format", aformat, 0, ({"u8", PCM(0, 0, 8, 0)}, @@ -75,7 +75,11 @@ const struct m_sub_options demux_rawaudio_conf = { .size = sizeof(struct demux_rawaudio_opts), .defaults = &(const struct demux_rawaudio_opts){ // Note that currently, stream_cdda expects exactly these parameters! - .channels = MP_CHMAP_INIT_STEREO, + .channels = { + .set = 1, + .chmaps = (struct mp_chmap[]){ MP_CHMAP_INIT_STEREO, }, + .num_chmaps = 1, + }, .samplerate = 44100, .aformat = PCM(1, 0, 16, 0), // s16le }, @@ -130,9 +134,14 @@ static int demux_rawaudio_open(demuxer_t *demuxer, enum demux_check check) if (check != DEMUX_CHECK_REQUEST && check != DEMUX_CHECK_FORCE) return -1; + if (opts->channels.num_chmaps != 1) { + MP_ERR(demuxer, "Invalid channels option given.\n"); + return -1; + } + struct sh_stream *sh = demux_alloc_sh_stream(STREAM_AUDIO); struct mp_codec_params *c = sh->codec; - c->channels = opts->channels; + c->channels = opts->channels.chmaps[0]; c->force_channels = true; c->samplerate = opts->samplerate; |