Purpose: For those of you who have used audio/sound in your Debian/Ubuntu desktop environment you might have encountered certain issues while trying to enable GNOME sound events and media player output together. You might have noticed that many times you can either play sounds from GNOME events (like clicking, start, shutdown, errors) or you can play music from your media player like MPlayer, XMMS, XMMS2, etc.
Step 1: Enable sound output
The first step in getting sound output from your Linux system is to check if your mixer is not on mute. Go to “Applications->Sound & Video->Volume Control” and make sure the “Master”, “Headphone” and “PCM” are not set to Mute as shown below:
Step 2: Play any MP3 music
# apt-get install mplayer
# mplayer test.mp3
MPlayer 1.0rc2-4.3.2-DFSG-free (C) 2000-2007 MPlayer Team
CPU: Intel(R) Pentium(R) M processor 1.80GHz (Family: 6, Model: 13, Stepping: 8)
CPUflags: MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 1 SSE2: 1
Compiled with runtime CPU detection.
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.
Audio file file format detected.
Opening audio decoder: [mp3lib] MPEG layer-2, layer-3
AUDIO: 44100 Hz, 2 ch, s16le, 128.0 kbit/9.07% (ratio: 16000->176400)
Selected audio codec: [mp3] afm: mp3lib (mp3lib MPEG layer-2, layer-3)
AO: [alsa] 48000Hz 2ch s16le (2 bytes per sample)
Video: no video
A: 83.8 (01:27.3) of 243.0 (04:04.0) 2.7%
Now you should be able to hear mp3 music from out audio output jack. Note that at this point of time you are not able to hear any GNOME event sounds because it is not yet enabled. This is assuming that you have just installed GNOME and haven’t made any changes to the sound system yet.
Step 3: Enable GNOME sound events
First let’s see how to enable GNOME sound events. Give the following commands:
apt-get install esound
apt-get install gnome-audio
This will download the esound daemon which is responsible for mixing audio streams from several sources together. When you download the above program your sound card is basically taken over by “esd” which is the part of the “esound” package. Now you need to enable the GNOME sound events by going to “System->Preferences->Sounds” and then click on “Sounds” tab and check the box “Enable Software sound mixing (ESD)”.
If you simply enable the GNOME sound events without installing “esound” then you simply won’t hear any GNOME related sounds. Also note that we need the package “gnome-audio” to install the *.wav files as seen above.
Now try clicking on the any of the sound above by hitting the “Play” button and you should be able to hear GNOME sounds. If you are still not able to hear the GNOME sounds then give the following command:
# modprobe snd_pcm_oss
Step 4: Now try playing Mp3 again
# mplayer test.mp3
[AO_ALSA] alsa-lib: pcm_hw.c:1132:(snd_pcm_hw_open) open /dev/snd/pcmC0D0p failed: Device or resource busy
[AO_ALSA] alsa-lib: pcm_dmix.c:996:(snd_pcm_dmix_open) unable to open slave
[AO_ALSA] Playback open error: Device or resource busy
[AO OSS] audio_setup: Can't open audio device /dev/dsp: Device or resource busy
Could not open/initialize audio device -> no sound.
Audio: no sound
Video: no video
Surprised??? That your prefectly working sound suddenly stopped working. As noted above when we install esound, it takes over the owner ship of your sound card.
Step 5: Fix the audio issue
apt-get install libesd-alsa0
The above package is required to mix sound together if you are using ALSA sound drivers in your kernel. Most likely you are using the ALSA sound drivers in your kernel. You can check this by:
debian:~# cat /boot/config-2.6.26-1-686 | grep CONFIG_SND
Now RESTART your system.
Step 6: Check GNOME sound and MP3 output
After restarting your system try playing the GNOME sounds (Step 3) and the MP3 file (Step 2) and your system should happily play both the sounds without any error message. Note that you might need to un-mute the mixer components (Step 1) again once you restart the system. Every time you restart your system, the sound output will be set to “Mute” for some reasons.
Step 7: Make your system to remember the mixer settings
To get rid of annoying mixer mute problem on every restart you can install the following package:
apt-get install aumix
and now you can adjust the mixer levels to your desired level as shown below and next time when you restart the system it will remember those volume levels:
Note that the “aumix” package creates a file called .aumixrc in your home directory in which it stores the settings.
# less .aumixrc
Step 8: More mixer settings packages (Optional)
I understand that “aumix” is a pretty basic package and does not have a very pretty looking interface. Here are some alternatives for “aumix”:
# apt-get install alsa-utils
# apt-get install gnome-alsamixer
Note that until Step 7 we have not installed any ALSA utils like:
and we still got the audio/sound working from multiple streams. There is a lot of confusion among people with regards to ALSA utilities. Many people think that we need those to get sound working which is not 100% true. Just because you are using ALSA sound drivers in your Linux kernel does not mean you need the above utilities to make them work.