Whenever I watched something on youtube, or any other Flash that required sound I first had to stop mpd from playing. But to listen to MPD again, I had to close down Firefox because it occupied my sound device. MPD would simply not play. I never got around to fixing this, until now. And the solution is very simple!

There is a built in mixer in ALSA. It should automatically allow different processes to share the same sound device by mixing the sound with the plugin dmix. But – this did not work out of the box for me.

First, I discovered, that I did not have any configuration file! Strange, so I created one:

# touch /etc/asound.conf
# nano /etc/asound.conf

pcm.!default {
 type plug
 slave.pcm "lyd"

pcm.lyd {
 type dmix
 ipc_key 1234
 slave {
 pcm "hw:0,0"
 period_time 0
 period_size 1024
 buffer_size 4096
 rate 44100

It should not matter much what you call the mixer – the important thing is to activate the “type dmix”. [translation lyd=sound (no=en)].

Now, I modified my mpd.conf to use this mixer.

audio_output {
 type              "alsa"
 name              "lyd"
 options           "dev=lyd"

I now am able to listen to the flash sound while mpd is still playing 🙂