sharing the sound device with mpd

I was doing some hardware shuffling and as part of that I swapped out the laptop which I use as an extra terminal and also doubles as print spooler and music streamer. The Ubuntu install was easy as usual and I managed to sync my usual stuff across. The other part that was missing was to set up mpd.

Install wasn't hard since I only had to bring across the old config file. Then I had some issues with getting it to play. I tracked this down to the fact that I was logged in as myself already and mpd was attempting to access the sound device as the mpd user.

To work around that I dug through some of the alsa docs and set up a software mixer device. I simply put the following into /etc/asound.conf


pcm.dmix0 {
type dmix
ipc_key 673138
ipc_key_add_uid false # let multiple users share
ipc_perm 0666 # IPC permissions for multi-user sharing (octal, default 0600)
slave {
pcm "hw:0,0"
rate 48000
period_time 80000
buffer_time 320000
period_size 4096
buffer_size 16384
}
bindings {
0 0
1 1
}
}
# 'dsp0' is espected by OSS emulation etc.
pcm.dsp0 {
type plug
slave.pcm "dmix0"
}
ctl.dsp0 {
type hw
card 0
}
pcm.!default {
type plug
slave.pcm "dmix0"
}
ctl.!default {
type hw
card 0
}

That made it possible for the mpd daemon to start playing music again.

\@matthias