Jun 24, 2013

Use an optical cable to get surround from your HTPC

I've been running my Ubuntu based XBMC HTPC for over a year now, and problems have been few and far between. But recently I started having issues with the sound of a show I'm watching. I only got the message "failed to initialize audio device" - which made a few bells go off. I have had the same issues previously, but just used a different file (ahem) and got sound from that.

So, it turns out, these last files were AAC-encoded, as opposed to for example, mp3. After some googling, I  finally realized the main thing everybody were saying was you can't have AAC over HDMI. You have to use SPDIF output for that (like an optical cable). That's fine, I have an optical port on my receiver, and on my HTPC.

So to get this to work (specific to my Ubuntu/XBMC setup) I had to:
1) Enable HD Audio output to SPDIF in my BIOS settings. They were default set to HDMI.
2) Connect the optical cable to the HTPC and the AV receiver.
3) Change XBMC's audio settings to output "Digital/Optical", tick the boxes for AC3 enabled and DTS enabled receiver, and finally play around with the bypass and audio devices - what worked for me was iec859 device 1, but you have to try the different ones available to you.

You can see the different devices using the command aplay -l, it's output looks like this:
Output of aplay -l
So according to this, choose the "device 1 iec859" option in XBMC - do not choose device 1 hdmi, for instance, that's just XBMC being a little ignorant.

Now I have no problems playing any files, and I get surround sound whenever it's available!