Thursday, April 22, 2010

Fixing a problem with pulseaudio

I had a problem on my new machine - after bootup there was no sound. Starting "pulseaudio volume control" (= pavucontrol) I could see in the "Output Devices" tab, that the sound was muted. Just clicking on the mute button would enable sound.

However each time I would boot the sound was muted again. Also in the system log I found this:

alsa-mixer.c: Your kernel driver is broken: it reports a volume range from 18.00 dB to 18.00 dB which makes no sense.

(Not quite certain if that's actually related to the mute issue, but perhaps pulseaudio turns the output off because the driver reports an invalid volume range.)

Anyway I didn't want to unmute this all the time, so I figured out how to let pulseaudio do the job:

First enable sound manually via pavucontrol, then in a terminal window enter:

pacmd "dump" | grep set-sink

This will give a list of commands which pulseaudio has executed on your system. In my case the list looked like this:

set-sink-volume alsa_output.pci-0000_00_07.0.analog-stereo 0x3068
set-sink-mute alsa_output.pci-0000_00_07.0.analog-stereo no


That means that my audio "sink" (the part which plays the sound on my PC) is named alsa_output.pci-0000_00_07.0.analog-stereo and it was unmuted with:

set-sink-mute alsa_output.pci-0000_00_07.0.analog-stereo no

(Your sink will likely have a different name.)
So now this command just needs to be added to /etc/pulse/default.pa which pulseaudio executes automatically on startup.

The file can be edited like this:

sudo kate /etc/pulse/default.pa
(kate is just a texteditor, use vi if you are able or any other editor which is available on your system.)

At the end of the file just add this:

### disable MUTE
set-sink-mute alsa_output.pci-0000_00_07.0.analog-stereo 0


(Of course here you need the name of the sound sink on your system, I put mine there only as an example.)

And that's it, after the next reboot the sound is automatically on.