Foreword
The following howto has been posted by ploum on the French Ubuntu forums.
I have been answering sound questions "many" times on the Ubuntu forum, after having myself asked why sound did not work any more after upgrading from Warty to Hoary.
I have found this howto interesting, and thought it might also be interesting for everyone here, that's why I translated and adapted it. Please forgive any translation that sounds "Frenchy" ! This howto is partly redundant with other threads related to sound issues, such as for example http://www.ubuntuforums.org/showthread.php?t=8882.
However, it is original in the sense that it also describes sound features in Linux in general.
Introduction
Many questions are related to sound. In many cases, there is no hardware problem, but simply a lack of understanding how the system works.
Here are some technical explanations. It's a bit complicated, so if you really do not get the point, please go straight to the next topic.
Technical Explanations
OSS: Open Sound System
The Linux kernel is sending the sound to the sound card, by using the appropriate sound driver. A long time ago, the system which allowed to do that was OSS. Many drivers have been developed for OSS. Applications thus use the OSS interface to send sound to the driver.
ALSA: Advanced Linux Sound Architecture
OSS is not technically perfect, so a better system has been developed, namely ALSA. As a consequence, programs making use of sound have to be rewritten in order to be able to use ALSA instead of OSS. That's why, for example, xmms has an OSS plugin and an ALSA plugin. (The output plugin can be chosen in xmms, in options -> preferences).
Nevertheless, for older applications to go on working, a compatibility layer exists in ALSA. It ensures OSS applications believe they do use OSS while they actually use ALSA (as for example the flash plugin).
ESD: Enlightened Sound Daemon
In theory, only one sound can be played, since there is only one loud speaker. In order to play many sounds, one uses a sound mixer. That's the role of ESD. Applications send their sounds to ESD, the latter mixes these sounds, sends the result to OSS, which transmits it to ALSA.
In case you have a problem, read this before you post on the forum
One must be aware that only one application can use the sound card. In the default configuration, ESD (which is itself an application) is launched on startup and has access to the sound card.
In most cases, you cannot get sound simply because ESD blocks the access to the sound card.
The first thing to do is thus to kill ESD (use the command: killall esd), and then to have a look at what applications use the sound card:
tells you which programs use OSS
tells you which program use ALSA
Before you post, please check that all this is empty, and tell it in your post.
Howto properly configure the sound
A good thing to do is to tell ESD not to run when one does not need it. Do (assuming gedit is your prefered editor):
Code:
sudo gedit /etc/esound/esd.conf
and edit it so that it looks like
Code:
[esd]
auto_spawn=1
spawn_options=-terminate -nobeeps -as 2 -d default
spawn_wait_ms=100
# default options are used in spawned and non-spawned mode
default_options=
Restart your session, and normally you should not have problems with games such as frozen-bubble. You just have to stop the music two seconds before you start the game.
You still have some problems !
Please follow these steps:
1) Check your loud speakers, if they are properly plugged in, etc...
2) Check the sound volume ! In alsamixer, MASTER, PCM must be at some high value value, and without MM above or under.
3) If the music seems to play properly but you hear nothing, check the above two points. If Linux does not detect the sound card, it NEVER plays any sound ! and LWAYS gives an error ! Check that your computer does not have two sound cards, and plug your loud speakers on the other one (using a particular sound card is another problem).
4) If you get an error message of the type: "Not found or busy", check with "lsof" (see above)
5) In any other desperate situation, post on the forum and give:
- the precise error type
- the precise model of your sound card
- the result of "lsmod|grep snd"
Howto go further: listening many sounds at the same time, without ESD !
Now it becomes more technical and so also facultative. But it can be of interest for more than one person.
!!! BE CAREFUL !!! You should try the following only if you already managed to get proper ALSA sound (for example xmms manages to play with the ALSA plugin).
It is not clear that the following will work for any sound card.
The first thing to be done is to tell ESD to use ALSA instead of OSS:
Code:
sudo apt-get install libesd-alsa0
One now creates the asound file:
Code:
sudo gedit /etc/asound.conf
which should look like
Code:
pcm.card0 {
type hw
card 0
}
pcm.!default {
type plug
slave.pcm "dmixer"
}
pcm.dmixer {
type dmix
ipc_key 1025
slave {
pcm "hw:0,0"
period_time 0
period_size 1024
buffer_size 4096
periods 128
rate 44100
}
bindings {
0 0
1 1
}
}
Then one restarts ALSA:
Code:
sudo /etc/init.d/alsa restart
Restart your session (that's for ESD), and there you are, you should in principle be able to hear all the "click click" of the interface, to listen to music with xmms, and to play a video with totem, everything at the same time (applications must use ESD or ALSA, ALSA being a better choice).
The only dark point: OSS applications can still only have access to the sound card one after the other, which is the case of the flash plugin. Thus it is necessary to switch off all sound before launching a flash animation. Sometimes one even has to restart the navigator.
If someone knows a trick to make flash use ALSA or ESD, please tell us ! About this, you can go and see the post by wrochal in this thread
For people having two sound cards: You should have a look at the posts by MonoLT in this thread, and at his thread called 'HOWTO Set sound if you have 2 soundcards', http://www.ubuntuforums.org/showthread.php?t=27186
Bookmarks