From 249789c256ddffb6fc6eaf628b2653c195dcdac8 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 10 Mar 2014 02:09:18 +0100 Subject: audio: make --channels option always force the output layout Use the --channels value directly on the AO, instead of doing it only in the --channels=stereo (default) case and if the decoder output is not stereo. --- DOCS/man/en/changes.rst | 1 + DOCS/man/en/options.rst | 25 ++++++++++++++----------- options/options.c | 2 +- player/audio.c | 7 +------ 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/DOCS/man/en/changes.rst b/DOCS/man/en/changes.rst index 6aecc9b4f5..b7ded44e4a 100644 --- a/DOCS/man/en/changes.rst +++ b/DOCS/man/en/changes.rst @@ -179,6 +179,7 @@ Command Line Switches ``-panscanrange`` ``--video-zoom``, ``--video-pan-x/y`` ``-pp ...`` ``'--vf=pp=[...]'`` ``-pphelp`` ``--vf=pp:help`` + ``-channels`` ``--channels`` (changed semantics) ``dvdnav://`` ``dvdnav://menu`` =========================== ======================================== diff --git a/DOCS/man/en/options.rst b/DOCS/man/en/options.rst index fc8b778ac8..b08117aa0b 100644 --- a/DOCS/man/en/options.rst +++ b/DOCS/man/en/options.rst @@ -455,12 +455,10 @@ OPTIONS Specify the CD-ROM device (default: ``/dev/cdrom``). ``--channels=`` - Request the number of playback channels (default: 2). mpv asks the - decoder to decode the audio into as many channels as specified. Then it is - up to the decoder to fulfill the requirement. This is usually only - important when playing videos with AC-3, AAC or DTS audio. In that case - libavcodec downmixes the audio into the requested number of channels if - possible. + Request a channel layout for audio output (default: stereo). This will ask + the AO to open a device with the given channel layout. It's up to the AO + to accept this layout, or to pick a fallback or to error out if the + requested layout is not supported. The ``--channels`` option either takes a channel number or an explicit channel layout. Channel numbers refer to default layouts, e.g. 2 channels @@ -470,12 +468,17 @@ OPTIONS lists speaker names, which can be used to express arbitrary channel layouts (e.g. ``fl-fr-lfe`` is 2.1). - .. note:: + You can use ``--channels=empty`` to disable this. In this case, the AO + use the channel layout as the audio filter chain indicates. + + This will also request the channel layout from the decoder. If the decoder + does not support the layout, it will fall back to its native channel layout. + (You can use ``--ad-lavc-downmix=no`` to make the decoder always output + its native layout.) Note that only some decoders support remixing audio. + Some that do include AC-3, AAC or DTS audio. - Currently, this option is not very useful. The main effect of this - option is that automatic stereo downmixing is disabled. It depends - mainly on the selected audio output and the associated audio subsystem - how playback of files with surround audio will behave. + If the channel layout of the media file (i.e. the decoder) and the AO's + channel layout don't match, mpv will attempt to insert a conversion filter. ``--chapter=`` Specify which chapter to start playing at. Optionally specify which diff --git a/options/options.c b/options/options.c index 30564ba018..4dd9957e47 100644 --- a/options/options.c +++ b/options/options.c @@ -359,7 +359,7 @@ const m_option_t mp_opts[] = { // force video/audio rate: OPT_DOUBLE("fps", force_fps, CONF_MIN | M_OPT_FIXED), OPT_INTRANGE("srate", force_srate, 0, 1000, 8*48000), - OPT_CHMAP("channels", audio_output_channels, CONF_MIN, .min = 1), + OPT_CHMAP("channels", audio_output_channels, CONF_MIN, .min = 0), OPT_AUDIOFORMAT("format", audio_output_format, 0), OPT_DOUBLE("speed", playback_speed, M_OPT_RANGE | M_OPT_FIXED, .min = 0.01, .max = 100.0), diff --git a/player/audio.c b/player/audio.c index 5d8d60ccd1..bbe4174890 100644 --- a/player/audio.c +++ b/player/audio.c @@ -143,12 +143,7 @@ void reinit_audio_chain(struct MPContext *mpctx) ao_format = out_format.format; ao_channels = out_format.channels; } else { - // Automatic downmix - if (mp_chmap_is_stereo(&opts->audio_output_channels) && - !mp_chmap_is_stereo(&in_format.channels)) - { - mp_chmap_from_channels(&ao_channels, 2); - } + ao_channels = opts->audio_output_channels; // automatic downmix } // Determine what the filter chain outputs. build_afilter_chain() also -- cgit v1.2.3