CAPTCHA
Image CAPTCHA
Enter the characters shown in the image.
This question is for testing whether or not you are human.
  • Create new account
  • Reset your password

User account menu

Home
The Hyperlogos
Read Everything

Main navigation

  • Home
  • My Resumé
  • blog
  • Howtos
  • Pages
  • Contact
  • Search

Untangling audio on Ubuntu Gutsy

Breadcrumb

  • Home
  • Untangling audio on Ubuntu Gutsy

While Linux marches ever closer to being user-friendly, there are still a few loose ends to be tied up. Networking continues to be a bit of a sticky spot, and Bluetooth support is definitely in need of some refinement. But another area, and one which you would expect to have been tied up nearly by now, is sound. The PulseAudio server can help you take care of this problem, but simply installing it doesn't clear up the problems with programs taking the sound card and never letting you have it back.

The Past

Linux sound support has had a long and tortured history. It begins with the OSS, or Open Sound System, an open source system for sound support on Linux. The creator took a later version of the project commercial, so the community at large mostly abandoned the official fork for ALSA, the Advanced Linux Sound Architecture. ALSA is now the de facto standard, though OSS has since been released under various Open/Free licenses."Open Sound System." Wikipedia, The Free Encyclopedia. 6 Feb 2008, 09:30 UTC. Wikimedia Foundation, Inc. 18 Feb 2008 <http://en.wikipedia.org/w/index.php?title=Open_Sound_System&oldid=189464434>. The missing ingredient, unfortunately, is sound device sharing that works properly.

The Present

ALSA has somewhat recently been updated to automatically launch the software mixing plugin dmix in order to support mixing multiple audio streams. Unfortunately, Linux programs don't all speak to ALSA; depending on what they support and how they are configured, they may support OSS, ALSA, JACK, pulseaudio, SDL, ESD, or others. OSS and ALSA are by far the most common, but there's plenty of programs out there which only use SDL or JACK. Your primary savior is PulseAudio, formerly Polypaudio, a software-mixing audio daemon intended to provide compatibility with ESD.ESD is the Enlightened Sound Daemon, the standard under GNOME 2. Rip ESD out of your system and replace it with PulseAudio, then set ALSA's default output to pulse, and finally run OSS programs with the padsp wrapper command by simply prefixing it to the command line. SDL programs can be convinced to speak to pulse by convincing them they're talking to ESD, via a simple environment variable.

The Details

All of this is detailed on the PulseAudio site in their document "PerfectSetup". There are just a few loose ends, however. I will detail my answers here. I am using a Compaq nw9440 laptop, with Intel HDA audio, and Ubuntu Gutsy. This is a specific guide to adapting the PerfectSetup guide to this distribution, and tested on this system.

The Packages

On Ubuntu Gutsy, you will need to install some or all of the following packages:

  • pulseaudio - pulseaudio server (required)
    The pulseaudio server, where the magic happens. If you are lucky this will be installed automatically.
  • pulseaudio-esound-compat - pulseaudio ESD compatibility library (required)
    This is required for ESD compatibility, which permits pulseaudio to function as the replacement audio server for GNOME 2 and numerous other applications. It is what makes pulseaudio useful.
  • libgstreamer-plugins-pulse0.10-0 - pulseaudio output for gstreamer (suggested)
    Provides pulseaudio output functionality to gstreamer. This covers a handful of programs. It's not strictly necessary because we can go through ESD compatibility.
  • pavucontrol - pulseaudio GTK volume control (suggested)
    In theory, you don't need this as you can use other utilities. In practice...
  • pavumeter - pulseaudio GTK VU meter (suggested)
    An easy and quiet way to check if audio input is working, among other things.
  • paman - pulseaudio manager (suggested)
    Lets you fiddle with various volumes, see connected clients, and do some other nice things.
  • padevchooser - pulseaudio device chooser (suggested)
    This provides a tray icon that gives you easy access to inputs and outputs, paman, pavumeter, and others.
  • paprefs - pulseaudio server preferences (suggested)
    Sets some networking-related pulseaudio preferences via the GUI.

Configuring the Server

Some pulseaudio output plugins (for various programs) may need to speak to pulseaudio via the network directly (and not through a module.) They will need access via the network. You can make this work only from the local system, or for more clients. Here's some examples. Just edit /etc/pulse/default.pa.

This is what it looks like for access from localhost only:

load-module module-esound-protocol-tcp auth-ip-acl=127.0.0.1
load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1

This is the example given in the PerfectSetup document:

load-module module-esound-protocol-tcp auth-ip-acl=127.0.0.1;192.168.0.0/16
load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1;192.168.0.0/16
load-module module-zeroconf-publish

In this example, access is limited to localhost and any 192.168.x.x address. The zeroconf module is loaded to permit automatic discovery. You could load that module even for localhost only, and it might even do you some good. I used the full example.

Configuring ALSA

Here's my /etc/asound.conf:

pcm.pulse {
    type pulse
}
ctl.pulse {
    type pulse
}
pcm.!default {
    type pulse
}
ctl.!default {
    type pulse
}

Ubuntu uses the HAL. As per PerfectSetup, add the following lines if you are not using the HAL:

load-module module-alsa-sink device=hw:0
load-module module-alsa-source device=hw:0

This was all it took to get all ALSA functionality working perfectly (including recording!)

GStreamer

Also per PerfectSetup, run the following two commands (IF you installed the libgstreamer-plugins-pulse0.10-0 package:)

gconftool -t string --set /system/gstreamer/0.10/default/audiosink pulsesink
gconftool -t string --set /system/gstreamer/0.10/default/audiosrc pulsesrc

You probably need to run this for each user. You can also use gstreamer-properties and just pick pulse from the list.

MPD

If you're using MPD to play music (as I am) then you should configure it to use pulseaudio. Edit /etc/mpd.conf and add the following anywhere:

audio_output {
        type    "pulse"
        name    "My MPD PulseAudio Output"
        server  "localhost"
}

PerfectSetup says the server setting is optional; I did not find it to be so.

mplayer

Pretty much based on the PerfectSetup. Comment any uncommented lines beginning with ao= or mixer= and add the following anywhere:

ao=pulse,alsa
mixer=hw:0

The pulse,alsa value for ao (audio output) attempts to fall back to ALSA if pulse is not running or cannot be contacted.

SDL and OpenAL

I've lumped these together because they do the same thing (in this case anyway) and because you need to configure SDL to configure OpenAL as PerfectSetup suggests. Edit /etc/environment and add:

SDL_AUDIODRIVER="esd"

Then edit /etc/openalrc:

(define devices '(sdl))

The SDL change will work after the next login.

Everything Else

If you've made all the above changes, then you can cover practically every other program through one of the following methods:

  • For programs which can use network audio, use PulseAudio, ESD, ARTS, OpenAL, SDL, or gstreamer, which we have already configured. You could also use JACK, and instruct it to output to any of the above.
  • For programs which use the Open Sound System, use the padsp wrapper program to convince them that they have their own sound card. This is not 100% reliable! Sorry.

Troubleshooting

Broken Intel HDA audio in Ubuntu Gutsy (7.10)

Recently, some Ubuntu update broke my audio. No, I'm really not kidding; without even updating to a new minor version my audio mysteriously stopped working. My nw9440 has intel HDA audio and a Conexant HSF modem, which is a problematic combination in that the drivers do not play well together. I went so far as to spend twenty bucks on the official, commercial driver from Linuxant, but it doesn't really work and they really aren't responsive at all. In fact, their suggestion to me was that I go and roll my own Linuxant-driver-compatible version of the Linux ALSA sound system from beta sources, and that I then provide it to them! This is pretty much what I thought I was paying them to do, but I didn't get my money back as I expect it to work, you know, someday. For the moment I'm using another laptop with a Xircom PCMCIA modem as an internet gateway. If you have a Conexant modem, I suggest investing in an external USB or serial modem. Just make sure to check for Linux compatibility ahead of time if it's USB. I mention the modem here because the driver possibly exacerbated the problem. As far as I can tell, though, I corrected the changes it made before attempting any other troubleshooting.

Just to be clear, I did not experience this problem during my upgrade from Feisty to Gutsy. This was a later, ostensibly minor update that caused this problem. But regardless of the cause, the solution to the HDA audio problem was to install the linux-backports-modules-generic package - probably it would be best to install linux-backports-modules instead, so that the package linux-backports-modules-arch (see the end of the output of uname -r) is installed automatically, and so that if you change kernel flavors, the proper package is installed.

howto
Ubuntu
audio
  • Log in or register to post comments

Footer menu

  • Contact
Powered by Drupal

Copyright © 2025 Martin Espinoza - All rights reserved