momo zone


Pulse audio and SPDIF output in Kubuntu (Hardy Heron 8.04)

Pulse audio and SPDIF output in Kubuntu (Hardy Heron 8.04)

1:16 AM


Here I will explain how I got my Realteck ALC888 SPDIF digital output working with pulseaudio in Kubuntu Hardy Heron (8.04).

Background (rant so skip if you are in a hurry)

I have a MSI board with integrated Realtek ALC888 Audio card that came with analog outputs only. Fortunately these boards usually come with a SPDIF header where you can connect a SPDIF
bracket to get a digital output. These brackets are difficult to get
and in my case I had to call the main board dealer (calling customer
support) and they sold me one for about USD/30.00. Another alternative
I considered was to buy a cheap sound card with SPDIF outputs for about the same amount like the ENVY24HTS-PCI or the CMI8768-8CHPCI but the idea of wasting the ALC888 was daunting.

I needed the SPDIF ouput because my ALLA VIBRAR 5.1ch Headphones have only SPDIF (Coax and Fiber) inputs.

After trying a lot, and I mean a LOT!, alsa
was not working well with my Headphones, anything I played througth the
digial output would be accompanied by all kinds of artifacts (cracks,
skips, pauses) coming out from the headphones.

So I decided to try the recent pulseaudio and once I got my audio working I never looked back at alsa again.

some reason pulseaudio did not came as default with any of the beta, rc
and final installations of Hardy Heron (Kubuntu 8.04 KDE4) so here is
how I managed to get Pulseaudio working for me.

Pulse Audio in Kubuntu (Hardy Heron 8.04)

First we install the necessary packages:

sudo aptitude install pulseaudio libao-pulse pulseaudio-module-hal

  pulseaudio-module-x11 pulseaudio-utils libsdl1.2debian-pulseaudio

and then create a .asoundrc configuration file to tell all ALSA applications to use pulse.

pcm.!default {

    type plug

    slave {

         pcm "spdif"



configuration file will set pulseaudio as the default sound server and
in this particular case it will also set the digital (SPDIF) output as default. If you prefer the analog outputs simply remove the type plug and slave sections.

The above configuration works and I get sound on the SPDIF
output but I also have a stereo jack in the front panel of the PC that
was getting wasted. So after some research I got the following asoundrc
configuration file:

pcm.!default {

    type pulse

    type plug

     slave {

         #pcm "spdif"

         pcm multi


     ttable.0.0 1.0

     ttable.1.1 1.0

     ttable.0.2 1.0

     ttable.1.3 1.0


clt.!default {

   type pulse


pcm.stereo {

  type pulse

  type plug

  slave {

  pcm multi


  ttable.0.0 1.0

  ttable.1.1 1.0

  ttable.0.2 1.0

  ttable.1.3 1.0



 ctl.stereo {

  type pulse

  card 0


pcm.multi {

  type multi

  slaves.a.pcm "analog-hw"

  slaves.a.channels 2

  slaves.b.pcm "digital-hw"

  slaves.b.channels 2

  bindings.0.slave a 0

  bindings.1.slave a 1

  bindings.2.slave b 0

  bindings.3.slave b 1



 ctl.multi {

  type hw

  card 0


really do not understand this file so don’t ask. This configuration
file also allows output from the front stereo jack so I can have both
the 5.1ch headphones on SPDIF and an additional stereo headphone working simultaneously.

Starting the server
Let us start the pulseaudio server so we can test some applications:

1 pulseaudio –system=1 –high-priority=1 -D

The recomended way to start the pulseaudio system is per user/session so instead of editing the /etc/default/pulseaudio file I simply create a script and put it in our KDE Autostart dir (i.e. $HOME/.kde4/Autostart).

1 !#/bin/bash

2 pulseaudio –system=1 –high-priority=1 -D

way everytime I start KDE the pulseaudio server gets started too. Now
with the server running we need to tell our applications to use it
instead of directly accessing alsa.

Pulse audio with Amarok in Kubuntu (Hardy Heron 8.04)
This one is the easiest as it has a configuration panel that allows you to choose the output plugin. See screenshot:

Pulse audio with MPlayer in Kubuntu (Hardy Heron 8.04)

in Kubuntu Hardy Heron comes by default with pulseaudio support and in
fact uses it as default. If it is not default then you can also force
mplayer to use pulse audio with the -ao pulse switch. One way
to check if mplayer is really using pulseaudio is to run mplayer from
command line and look for a line that looks like AO: [pulse] 48000Hz 2ch s16le (2 bytes per sample). If instead you see alsa or anything else between the square brackets then something is wrong with your installation.

Pulse audio with SDL applications in Kubuntu (Hardy Heron 8.04)

games in Linux (i.e. Urban Terror) use SDL audio so we must ensure all
SDL applications use the pulseaudio server. When you install the
pulseaudio packages this should be done automatically but one bug was preventing the dependency manager to install the needed package: libsdl1.2debian-pulseaudio with:

sudo aptitude install libsdl1.2debian-pulseaudio

Installing this package will enable SDL applications to use the pulseaudio server. We can check this by running a game like Urban Terror and looking at the console. We should see something like:

—— Initializing Sound ——
Initializing SDL audio driver…
SDL audio driver is "pulse".
Format: AUDIO_S16LSB
Freq: 22050
Samples: 1024
Channels: 2
Starting SDL audio callback…
SDL audio initialized.

Pay attention to the SDL audio driver and see what it says. If it says alsa or anything different from pulse then you are not using pulse audio.

Pulse audio with Flash player in Kubuntu (Hardy Heron 8.04)

This one is a little more complicated as we need to install an experimental library but not that complicated and it worked flawlessly in Konqueror and Firefox. Simply follow the next steps:

1 sudo aptitude install  build-essential automake1.9 autoconf libtool libesd0-dev libpulse-dev libssl-dev

2 git-clone libflashsupport

3 cd libflashsupport

4 ./

5 make

6 sudo make install

we are doing here is installing some dependencies, downloading the
source code of the library from a Git repository, compiling, installing
and that is it. Now we have pulse audio support in flash.

only way I can test that flash is really using the pulseaudio server is
to play a flash video and at the same time play music in amarok. If
flash is using pulseaudio then you should be able to hear both the
flash audio and amarok music simultaneously. If flash is not using
pulse audio then the flash video will have no sound or amarok will not
play any audio.

Pulse audio with AC3/DTS pass thru in Kubuntu (Hardy Heron 8.04)
Ok so not everything is perfect and pulseaudio does not solves all my desires. The whole idea of the digital ouput (SPDIF)
is to be able to send raw AC3 sound to my headphones receivers. This
offers the best quality since these headphones have a hardware AC3
decoder so I can get full 5.1 channel surround sound out of them. The
problem is that pulseaudio is not able to pass thru the AC3/DTS streams
to the SPDIF output.

The solution is to use alsa in this case with the mplayer hwac3 switch like:

mplayer -ac hwac3

works perfect and there is no need to stop the pulseaudio server. The
only inconvenient is that you cannot use any other sound application
while the AC3 audio is playing. This is because during the time the AC3
audio is playing alsa is taking control of the sound card and all other applications that rely now in pulseaudio cannot get access to the card.

my case is not really that big of a problem because when I am seeing a
DVD I do not want to hear any other sounds from my PC like knotify.



Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s

%d 博主赞过: