It appears to me that there is no way to simultaneously set up a pass-through of DD or DTS surround while also allowing AAC surround in the content to be sent through as decoded multi-channel PCM. You can do one or the other correctly but it seems not both. This appears (to me) an unnecessary and perhaps unintended constraint and so I am trying to figure out whether this is a feature or a bug.
To make things simple (because there are so many moving parts in the audio setting), let me describe my findings in the simplest possible configuration. I am avoiding availability of SPDIF, etc so as not to complicate things. Just HDMI. I am also ignoring the option to transcode to AC3 as irrelevant to this context.
Audio is played through Pulseaudio which has the possibility to select (keeping it simple here)
- Digital Stereo HDMI
- Digital Surround 5.1 Surround
There are two media files with the following audio (again to keep it simple)
- Dolby Digital 5.1
- AAC 5.1
The objective is to arrive at a setting where DD 5.1 is passed through with no decoding by Kodi and because AAC is not supported by most devices, Kodi should decode AAC 5.1 to multi-channel PCM and send it out as 5.1 multi-channel PCM (not as stereo). A single setting configuration should support both of the above to happen automatically.
Here is why it does not (and each one can be achieved only at the expense of the other). Do let me know if I have made any error in the assumptions or observations below.
To make sure pass through is possible for the DD 5.1, in Pulseaudio (through pavucontrol) one must select Digital Stereo HDMI for output and NOT Digital Surround 5.1 HDMI. Only then will the option to enable Pass through will be available inside Kodi System->Audio setting. Kodi on startup enumerates available devices and only allows pass through to devices that report as two channels.
So when pass through is enabled with Pulseaudio outputting to Digital Stereo HDMI, the pass through of DD5.1 works just fine. No problems here.
But if you then play the AAC 5.1 media, it is encoded as 2 channel stereo PCM (regardless of what setting one has in the number of channels or output configuration - fixed or best match). It appears the AAC decoding does not use those number of channel setting in this context. Without doing that Kodi has no way of knowing how many channels to send via PCM and depends on the selected device being stereo to send as stereo PCM downmixing the original. This is what appears unnecessary to me and can be handled differently (more below).
On the other hand, if I select Digital Surround 5.1 in Pulseaudio as the output device, then no pass through is available. Kodi decodes all audio to send it out as PCM. There are some issues here that results in low volume or missing channels depending on whether it is AAC or DD and the number of channels in the content but that is a different problem (already pointed out in some other threads). It is possible that Kodi here isn't doing the right things here in how it mixes to output. It seems to work best when the number of channels in the content and the number of channels supported by the device coincide. But I don't wish to go off on this tangent here although the decision logic may be related.
My question is in the first case of enabling pass through to a stereo sink, for content that cannot be passed through (AAC, e.g), isn't it possible for Kodi to check the number of channels setting in System->Audio and mix to that many channels in the PCM encoding instead of just assuming two channels only from the device characteristics (so the AVR gets stereo PCM only instead of multi channel PCM)? Because of the pass through requirements the selected device will always answer two channels - FR and FL (at least in Linux setups). The Fixed or Best Match setting is also ignored it appears.
Am I missing something here or is there a technical reason for not using the number of channels settings (if pass through is enabled) to decide on the number of channels to mix to as PCM for content that cannot be passed through? Or is this an unintended consequence?
Thanks for any input from the audio people at Kodi.