Getting MPD to work with Pulse audio in Debian Squeeze

Mar 1st, 2012 | By | Category: Linux / Freebsd

Well this was a long ass problem to solve today but it’s finally fixed and I’m a happy camper.  First of all some backstory:


Well obviously there’s been a shift in the way I listen to music.  For all of you that don’t know what MPD  is do some googling and some research. It stands for music player daemon which should make it pretty obvious what it does and how it works.

I was working today on a multiple monitor setup which allows me to up my virtual desktops from 6 to 10 but I noticed that the system performance was shit so I started to investigate procs that were taking up the most resources.  In doing so I watch Amarok take up 10-15% of the cpu as it happily played my favorite tunes in my ears.  Clearly this is atrocious and would not be tolerated, hell at 15% i’ll just plug in my mp3 player.  So I promptly closed it down and sat in silence as I looked for a lighter mp3 player.  This led me to something called gmpc however after installing it and trying to play something I found that I wouldn’t be able to do jack with it unless it was connected to an mpd server.  I’d run xmpp servers before so I was familiar with the concept and on the surface I had a sneaking suspicious that something like this, which is run at such a simple system level ought to be more efficient.  And I was right.  The problem of course was that mpd really didn’t want to play nice on my laptop (hw:1,0) with pulse audio.  When I started up mpd I was greeted with this error message in /var/log/mpd/mpd.log

output: Failed to open “My Pulse Output” [pulse]: Cannot connect to PulseAudio server: No such entity

Making them play nice

I’ve lost the damned link where I found these instructions so to whoever you were, thank you so much!

What I needed to do, after installing it and setting up the mdp.conf file as it should be was to go and edit the mdp.conf file and make an addition in the pulse audio_output section, change the sink value.  Change it to what you ask? Well to find that out you need to go and run the following command

pactl stat

and you should get something like this:

Server Name: pulseaudio
Server Version: 0.9.21
Default Sample Specification: s16le 2ch 44100Hz
Default Channel Map: front-left,front-right
Default Sink: ladspa_output.mbeq_1197.mbeq
Default Source: alsa_input.pci-0000_00_14.2.analog-stereo


Take the value for Default Source and put that into your .conf file in the pulse section

So mind looks something like this:

audio_output {
type “pulse”
name “Pulseaudio Motherbitches”
server “localhost”
#device “hw:1,0”
sink “alsa_output.pci-0000_00_14.2.analog-stereo”

And that’s that.. Fixed it for me immediately,  huzzah!

Was it worth it?

Oh hellz yes it was.  Keep in mind this is strictly a music servr, I would still play sounds and little clips with mplayer or vlc or whatever.. But for music that is running 24/7 smd is far far superior.  Instead of 10-15% cpu usage I am between 6-8% which is an insane improvement in efficiency.  Plus if I want to I can start streaming the audio online or set my debian webserver up with mpd and stream from there now that I know how to do it.  Also amarok is a KDE app I believe and using gnome that is probably another reason for it’s inefficiencies.

It’s been a couple of weeks since I made the switch and today I experienced some very high CPU and memory usage from mpd so I looked into it a bit and found a couple of tricks about minimizing resource consumption that I thought I would pass along.

The first thing would be to enable mmap to optimize CPU usage.  That is done by adding: use_mmap “yes” into your audio_output rule set.  Next is to turn off auto resample which is done by adding auto_resample “no” to that same ruleset.  Lastly I added period_time “50000” and I’m not entirely sure what that does but it was recommended.

So in the end my audio_output {} looks like

 audio_output {
type “alsa”
name “alsa”
device “hw:1,0” # optional
auto_resample “no”
use_mmap “yes”
format “44100:16:2” # optional
mixer_device “default” # optional
mixer_index “0” # optional
period_time “50000”


I also added the resample no rule to my pulse rule set.  For more tuning tips head over to:

Hope that helps anyone out there experiencing this.

Tags: , , , , ,

Leave a Comment