This page will help you to output 5.1 AC-3 through Alsa, enabling Pulseaudio to use it. The default is to export audio over SPDIF using PCM, which is stereo-only.

Configuring asound.conf

If you are using Oneiric Ocelot or later, add the following text to a new file, /usr/share/alsa/alsa.conf.d/a52.conf .For versions prior to Oneiric Ocelot (11.10) , add the following to /etc/asound.conf:

pcm.a52 {
  @args [CARD]
  @args.CARD {
    type string
  }
  type rate
  slave {
    pcm {
      type a52
      bitrate 448
      channels 6
      card $CARD
    }
  rate 48000 #required somehow, otherwise nothing happens in PulseAudio
  }
}

Building/Installing Required a52 Plugin

Install dependencies

Install the dependencies for building the asound2 a52 plugin with the following commands:

sudo apt-get build-dep libasound2-plugins
sudo apt-get install libavcodec-dev libavformat-dev

N.b! If this fails, make sure that you have the source code lines enabled in Software Center/apt.

Get source for plugin

Create a tmp directory to work in, and install the asound2 source:

mkdir ~/tmp
cd ~/tmp
apt-get source libasound2-plugins

Build plugin

Build the plugins:

cd alsa-plugins-*
./configure
libtoolize --force --copy && aclocal && autoconf && automake && make

Install plugin

For Oneiric Ocelot (11.10) or Later

The alsa-libs have been moved to /usr/lib/(i386 or x64)-linux-gnu/alsa-lib

We need to copy the a52 plugin to /usr/lib/alsa-lib and /usr/lib/xxx-linux-gnu/alsa-lib (these commands work for all architectures)

cd a52/.libs
sudo cp libasound_module_pcm_a52.la libasound_module_pcm_a52.so /usr/lib/alsa-lib/
sudo cp libasound_module_pcm_a52.so /usr/lib/`uname -i`-linux-gnu/alsa-lib/

For Versions prior to Oneiric Ocelot (11.10)

Copy the a52 plugin to /usr/lib/alsa-lib:

cd a52/.libs
sudo cp libasound_module_pcm_a52.la libasound_module_pcm_a52.so /usr/lib/alsa-lib/

Restart ALSA

Either restart your computer or reload ALSA with the following:

sudo alsa reload
killall pulseaudio

(At this point, Pulseaudio should restart unless you've disabled 'autospawning')

PulseAudio Setup

Set Sound Hardware Device

Now pulse should be aware of your digital surround output. Go to System -> Preferences -> Sound. Click on the "Hardware" tab and change the profile to one of the 'Digital Surround 5.1' profiles. Play some sound (I like to test with www.pandora.com) and enjoy!

2ch Output For Music

If 2 channel output (fl, fr, sub) for music is desired then both audacious and mplayer can bypass pulse.

Audacious

  • Preferences -> Audio -> Output: alsa, Plugin preference: iec958

MPlayer

  • Edit ~/.mplayer/config:

ao=alsa:device=spdif
  • Also this can be added to ignore regular music files:

afm=hwac3

Troubleshooting

If the 'Digital Surround 5.1' profile does not show up, it probably means that alsa didn't create it correctly. To test if alsa sees the a52 device, type:

aplay -D a52:0

More Information

http://ubuntuforums.org/showthread.php?t=1608804

DigitalAC-3Pulseaudio (last edited 2014-01-04 12:15:59 by knome)