This post is from 2011 and relates to Debian Squeeze. I put up a newer post in 2013 when Debian Wheezy was released.
This post describes how I got Dolby Digital 5.1 output working over S/PDIF on my onboard Realtek chip with other audio sources mixed in. Previously I was only able to achieve either 5.1 output by sending the data stream straight to my receiver, or 2.0 output with everything mixed in. The experiences detailed in this post originate in Debian Squeeze, but if what I wrote is specific to anything, it should be my hardware — not Debian and its derivatives. Before you read on, you might want to check out this forum post instead, which describes a method that didn’t work out for me.
PulseAudio 0.9.22 is required; it won’t work on older versions of PulseAudio. Debian Squeeze comes with ALSA 1.0.23; presumably that’s much less significant. On Debian getting this most recent PulseAudio can be done through the experimental repository.
If you’re on Debian ALSA is already setup, including the required libasound2-plugins, but to get the most recent version of PulseAudio you’ll want to add deb http://ftp.debian.org/debian experimental main
to /etc/apt/sources.list
, and then type apt-get update && apt-get -t experimental install pulseaudio
in a superuser terminal (see the Debian Wiki for more information on the experimental repository). On many other distributions PulseAudio is already setup by default, but just like on Debian Squeeze that’s typically still PulseAudio 0.9.21 at present.
On Ubuntu you’d have to recompile libasound2-plugins yourself because it doesn’t include the a52 ALSA plugin by default. The link in the opening paragraph should describe that process sufficiently.
In the System Log Viewer you can keep an eye on syslog for (error) messages from ALSA as well as PulseAudio.
What follows is my /etc/asound.conf
, heavily condensed from Johannes Bauer’s Dolby Digital with Linux and ALSA guide. It works quite nicely (with some minor adjustments), but it will only allow one application to utilize audio at a time. One could utilize PulseAudio for stereo while suspending it (with pasuspender) when you want to play a movie or some such with 5.1 audio, but I’d rather mix everything together in PulseAudio so I don’t have to think about it after the initial setup, just like in Windows.
pcm.a52 {
@args [CARD]
@args.CARD {
type string
}
type rate
slave {
pcm {
type a52
card $CARD
}
rate 48000 #required somehow, otherwise nothing happens in PulseAudio
}
}
pcm.pulse {
type pulse
}
ctl.pulse {
type pulse
}
pcm.!default {
type pulse
}
ctl.!default {
type pulse
}
Now that you’ve got the ALSA configuration in order it’s time to make some slight adjustments to /etc/pulse/default.pa
or PA won’t detect the possibility for Digital Surround 5.1. According to various sources they had some kind of Digital Surround show up automatically, but I had to explicitly tell PulseAudio about its existence. Adjusted from a comment on Ubuntu bug 348353 (which incidentally is why you need PulseAudio 0.9.22).
load-module module-alsa-sink device=a52 rate=48000 channels=6 tsched=0 sink_properties=device.description=SPDIF sink_name=SPDIF channel_map=front-left,front-right,rear-left,rear-right,front-center,lfe
I initially added this line without the channel_map, but then PulseAudio thought I had something like front-left,front-left-of-center,front-center,front-right-of-center,front-right,lfe, which would be a strange setup indeed.
I’m not quite sure whether the channel map might be more appropriate in /etc/pulse/daemon.conf
, where I uncommented default-sample-rate = 48000
. I also added the appropriate settings for default-sample-channels = 6
and changed enable-lfe-remixing
to yes.
pavucontrol
is instrumental in quickly seeing what’s going on and for application-specific volume settings. Not utilizing it would be a disservice for yourself if you’ve chosen to use PulseAudio.
Now that we’ve got all the configuration set up you could reboot the computer, but one of the great things about Linux is that you rarely have to do that other than to load a different kernel.
As user: pulseaudio --kill
As superuser/sudo: /etc/init.d/alsa-utils restart
(As user: pulseaudio -D
, but that shouldn’t be necessary)
I utilized the surround test ac3 file from Lynne Music (straight to directory). I played it with mplayer -channels 6
to make sure everything was working correctly and to adjust the channel map. At this point everything was finally working fine for me, but most applications still were not cooperating because they defaulted to ALSA. Again, in Ubuntu this shouldn’t be an issue.
Various adjustments are still required in most applications. For instance, in Totem you have to explicitly set audio output to 5.1 in Edit > Preferences > Audio.
For MPlayer put channels=6 in ~/.mplayer/config
(note that if you can’t get PulseAudio to work you could add the equivalents of mplayer -ao alsa:device=spdif -srate 48000 -ac hwac3 file.avi
if you so desire).
VLC works fine if Dolby Surround is set to Auto in Tools > Preferences > Audio.
To get the 6 channel output to work in applications that use SDL (Gnash, quite a few games) you’ll need libsdl1.2debian-pulseaudio
. This will replace libsdl1.2debian-alsa
. Of course this won’t be necessary if your distro is set up with PA by default.
On a separate note, I set PulseAudio up so it can play audio from all kinds of sources (most notably my laptop).