Bug 509451

Summary: PulseAudio doesn't work with mpd
Product: [Fedora] Fedora Reporter: Andrew McNabb <amcnabb>
Component: pulseaudioAssignee: Lennart Poettering <lpoetter>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: 11CC: lkundrak, lpoetter, mithi, wtogami
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-08-05 14:18:03 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Andrew McNabb 2009-07-02 20:50:36 UTC
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):

http://ankurs.com/2009/02/howto-mpd-with-pulse-audio/
http://forums.fedoraforum.org/showthread.php?t=197126
http://www.ubuntugeek.com/howto-get-mpd-running-with-pulseaudio-in-ubuntu-804-hardy-heron.html
http://www.alanbriolat.co.uk/2009/03/mpd-pulseaudio-ubuntu-intrepid-810/

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?

Comment 1 Thomas Jansen 2009-07-29 10:04:08 UTC
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. 

http://mithi.net/?content=pulse

Comment 2 Andrew McNabb 2009-07-29 16:30:42 UTC
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. :)

Comment 3 Lennart Poettering 2009-07-29 17:16:51 UTC
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.

Comment 4 Andrew McNabb 2009-07-29 17:51:54 UTC
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.

Comment 5 Lennart Poettering 2009-07-30 01:11:08 UTC
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?

Comment 6 Andrew McNabb 2009-08-03 19:10:52 UTC
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?

Comment 7 Andrew McNabb 2009-08-03 19:13:09 UTC
I don't see a Fedora component called "mpd".  What should I assign this to?

Comment 8 Thomas Jansen 2009-08-03 23:39:42 UTC
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... ;)

Comment 9 Lennart Poettering 2009-08-04 14:22:05 UTC
(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.

Comment 10 Lennart Poettering 2009-08-05 14:18:03 UTC
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.