Red Hat Bugzilla – Bug 509451
PulseAudio doesn't work with mpd
Last modified: 2009-08-05 10:18:03 EDT
MPD (Music Player Daemon) is a network music server. There are a few dozen different client programs that can connect to the server to control what music is being played. Unfortunately, if a user is logged in, PulseAudio competes with MPD for resources.
Before PulseAudio, mpd could play music as long as the user was not using the sound device. With dmix, both could use the sound device simultaneously. However, PulseAudio seems to keep the sound device open whether or not it's actively using it, so MPD can't play music when a user is logged in. MPD can't connect to PulseAudio because the music server needs to work regardless of whether a user is logged in.
I might be missing an easy way to work around this, but a lot of other users seem to be confused, too. Here are a few links I could find (with inadequate workarounds):
The best workaround I have found is to disable PulseAudio entirely, but that's not ideal. Is there any way to make PulseAudio work with MPD instead of removing PulseAudio?
I've run into the same problem back when PulseAudio was first added to Fedora. After disabling PulseAudio completely for a while (and using ALSA with dmix just as you did), I figured out a way to run MPD with PulseAudio.
The key is the system wide PulseAudio daemon, which Fedora does not (want to) support out of the box. I've written down some quick instructions on how to get MPD running with PulseAudio as a system wide daemon. Perhaps they can help you or at least get you started.
I noticed this possibility, but the documentation basically says that kittens will die if you do a system-wide PulseAudio daemon. I appreciate the workaround, but it really sounds like killing PulseAudio is better than killing kittens. Hopefully, PulseAudio will be fixed so we don't have to kill either. :)
You can run PA as mpd user just fine. You just need to make sure that PA can access the audio device nodes. With newer udevs all you have to do is make mpd a member of the audio group.
I seeno problem here, closing.
PulseAudio needs to be usable by both the mpd user _and_ by whatever user is currently logged in. And all without killing kittens. The documentation explicitly says that this is impossible.
Hmm, why would you want this to be usable across user boundaries? that is a security hole.
Also, PA will close the audio devices on idle after 2s, so even if you have two fighting PA instances the worst that happens is that a device cannot be unsuspended from one of the two instances.
Also, I really see no regression here, dmix didn't allow usage of sound cards simulatenously by two users either, unless you reconfigured it and opened a security hole. Which is something you can do with PA too.
What exactly are you asking me for?
Hmm. I wasn't aware that PA closes the audio devices when idle--this seems like a really good solution.
This use case is probably the main reason that people want to run a system-wide daemon. Perhaps you could modify the page at http://pulseaudio.org/wiki/SystemWideInstance to explain that instead of having a system-wide daemon, you should usually instead have a separate instance for each user (with details on how to do this). Based on various frustrated blog entries I've seen, this would answer most people's concerns.
As far as this bug report is concerned, I'll switch this over to mpd. Since Fedora is using PulseAudio extensively, it seems that the mpd initscript should start a PulseAudio daemon owned by the mpd user. Lennart, does that sound good from your perspective?
I don't see a Fedora component called "mpd". What should I assign this to?
Actually, mpd is not in Fedora but available from rpmfusion.org, since it relies on libmad and other libraries that Fedora does not ship. You'd probably have to open a new ticket there (https://bugzilla.rpmfusion.org/) if you want to improve the mpd packet (and especially the initscript). The ticket here should be closed in that case, because there is nothing that can be done from the Fedora side.
If it is indeed possible to have two PA instances that do not run into problems fighting over audio resources in a first come, first served way it could be worth the effort. For some reason I'm rather sceptic... ;)
(In reply to comment #6)
> Hmm. I wasn't aware that PA closes the audio devices when idle--this seems
> like a really good solution.
> This use case is probably the main reason that people want to run a system-wide
> daemon. Perhaps you could modify the page at
> http://pulseaudio.org/wiki/SystemWideInstance to explain that instead of having
> a system-wide daemon, you should usually instead have a separate instance for
> each user (with details on how to do this). Based on various frustrated blog
> entries I've seen, this would answer most people's concerns.
It's a public wiki. You are welcome to add comments!
> As far as this bug report is concerned, I'll switch this over to mpd. Since
> Fedora is using PulseAudio extensively, it seems that the mpd initscript should
> start a PulseAudio daemon owned by the mpd user. Lennart, does that sound good
> from your perspective?
PA is auto-spawned. It's not strictly necessary to run it manually.
Hmm, since there is no mpd package in Fedora and I don't see much of a problem with PA here I will now close this.