Ubuntu – 5.1 audio via HDMI only plays on two channels

hdmisound

I have my Intel NUC54250 hooked up to my TV via HDMI, and then my TV is connected to my speakers via S/PDIF. I've configured Ubuntu 16.04 to output 5.1 surround sound via HDMI. Here's the configuration in the built-in sound panel and PAVUControl:
Sound control
PAVU Control

When I use the built-in Ubuntu speaker test, however, only the left and right front speakers play sound. If I click on any other speakers, I just get silence.
speaker test

I know that my receiver and speakers work and are configured correctly, because other devices hooked up via HDMI play 5.1 audio just fine.

What's really bizarre to me is that Ubuntu knows that the HDMI out supports 5.1 and is configured to use it. But for whatever reason, no sound comes out on most speakers.

I'm guessing this is either an internal problem with Ubuntu or the NUC, or a problem with the HDMI full-to-mini adapter on the NUC HDMI port. But I'm leaning towards Ubuntu. If it was a problem with the adapter, I would expect no channels to work, rather than just left/right.

Best Answer

Ah, I figured it out!

tl;dr: the problem was the S/PDIF link between my TV and speakers, which can only carry two uncompressed audio channels.

What triggered my understanding and a very deep dive down the rabbit hole of various incompatible drivers, audio containers/codecs, and cable types was this forum post: http://www.tomsguide.com/forum/59518-6-working-connected-hdmi-optical#561415

Basically, the problem is that when I do that speaker test, Ubuntu is outputting uncompressed 5.1 audio over HDMI. My TV receives that and tries to transmit it to my speakers over S/PDIF, but S/PDIF only supports 2 channels of uncompressed audio! So, it gets downsampled to only 2 channels.

I was fooled into thinking this should work because I've obviously played 5.1 audio over S/PDIF prior to this, but what I didn't realize is that it was encoded via Dolby or DTS to work over S/PDIF.

It seems like my possible solutions are:

  1. Continue to output 5.1 uncompressed audio and replace my S/PDIF cable with an HDMI cable.
  2. Change PulseAudio to output 2 channel audio and enable DTS/AC3 passthru both in PulseAudio and Kodi, as described here: Enabling 7.1 audio passthru in 14.04 for Kodi

I'm not sure that either has a particular advantage. Option 2 involves fewer cables, but if I try to play a file with 5.1 channel PCM encoding (I imagine that's pretty rare) I'll be out of luck.

Another thing that wasn't obvious to me in setting up PAVU Control is that Dolby technically AC3, and Dolby Plus is EAC3.