S/PDIF and Dolby Digital out from MythTV

One of the nice things about getting the upstairs movie room finally bootstrapped is the return to having a real Dolby Digital receiver and more than just stereo sound.  I’ve always been a big fan of loud bass-booming movies with surround sound, but we decided to put the receiver in a closet until the upstairs was ready, instead of sqeezing it into the living room.

The last time I was really using a receiver, I didn’t have an HDTV, and thus didn’t have an HD capture card for Myth.  This meant that analog stereo out to the receiver was about as good as anything.  At the time, I didn’t have a Myth machine fast enough to reliably do DVDs, so digital audio was pointless.

Yesterday I set out to get S/PDIF output working from the Myth machine to the receiver.  My Myth machines all netboot a read-only copy of FC6 from a server on the network, so upgrading too much software and certainly bumping to a newer version of Fedora is a bit of an ordeal; I was hoping that FC6 would have everything I needed.

I started reading about digital sound with myth, and decided that most of the configuration should be done for me already.  I downed the box, and put in a spare SoundBlaster Live! card that I had lying around.  The card has a “digital output” jack on the back, which I connected to the Coaxial digital input of the receiver with a mono headphone-to-RCA adapter.

If I used something like mplayer to just play audio files (or a DVD) directly, I could see digital audio going to the receiver, but only stereo, and not Dolby Digital.  I think this is to be expected, as I wasn’t telling mplayer to pass the AC3 stream directly to the card.  Thus, alsa, or mplayer, or something, was dumping the regular audio out over the digital connection.  A good start, but not quite enough.

So, after reading a howto, I tried the following command:

mplayer -ac hwac3 -ao alsa:spdif dvd://

From this, I would get nothing.  Not even regular 2-channel audio.  Not even a blip on the receiver that something had happened on the digital audio line.  So I played around with things, including the mixer, and lots of mplayer settings.  I couldn’t figure out why the raw dump of the AC3 stream wasn’t working.  In my frustration, I tried turning back on the integrated sound, since ALSA claimed that it had a subdevice for IEC958 (S/PDIF) audio.  However, pointing mplayer at that resulted in an error, instead of just the appearance of playback without any actual sound (which is what the SoundBlaster was doing).

I put the SoundBlaster back in and fiddled some more.  I could see that the subdevice listing showed the analog surround output jacks, but no IEC958 like the integrated audio had:

[root@video2 ~]# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: Live [Dell Sound Blaster Live!], device 0: emu10k1x [EMU10K1X Front]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: Live [Dell Sound Blaster Live!], device 1: emu10k1x [EMU10K1X Rear]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: Live [Dell Sound Blaster Live!], device 2: emu10k1x [EMU10K1X Center/LFE]
Subdevices: 1/1
Subdevice #0: subdevice #0

I figured that perhaps one of these subdevices was actually responsible for the digital audio, but perhaps ALSA wasn’t detecting it.  So, I started pointing mplayer directly at the subdevices hoping to get a result:

mplayer -ac hwac3 -ao alsa:device=hw=0.2 dvd://

Finally, I saw the blue “Multichannel Decoding” light illuminate on the receiver and the Dolby Digital logo appear!  The receiver reported 6.1 channel decoding and everything.  I was curious if I had just picked the right subdevice right off, so I tried hw=0.1 and hw=0.0, and both worked just the same.  Confused about this, I tried without a subdevice using just hw=0 and that also worked.  I then thought that perhaps it was the ALSA aliases that were misdirecting the audio, but device=default worked as well.  So, it appears that only the spdif alias was wrong, and that unless you tell mplayer otherwise, it tries that alias.

So, I set off to get Myth setup to pass the AC3 from HD programs through to the card in a similar fashion.  Analog recordings already worked by just sending the stereo audio out the digital output.  To configure the passthrough, I went into Setup->Setup->General, and on the third page, I enabled AC3 and DTS to SPDIF passthrough.  I also left the passthrough device as “Default”, even though the SPDIF device was an option.

After these changes, I can watch HD programs and DVDs through Myth with full 6.1 Dolby Digital or DTS surround sound!

Category(s): Linux
Tags: ,

Comments are closed.