mpd no access to soundcard using pulseaudio

Bug #192735 reported by Rune Evjen
42
This bug affects 5 people
Affects Status Importance Assigned to Milestone
mpd (Ubuntu)
Fix Released
Medium
Unassigned
Nominated for Hardy by Duncan Hawthorne
pulseaudio (Ubuntu)
Invalid
Wishlist
Unassigned
Nominated for Hardy by Duncan Hawthorne

Bug Description

Binary package hint: pulseaudio

Version info:

uname -r: 2.6.24-8-generic
pulseaudio Version: 0.9.9-1ubuntu2
mpd : Version: 0.13.1-3ubuntu1

After changing from esound to pulseaudio, MPD is not able to access the sound card.

MPD logs the following errors in /var/log/mpd/errors.log:

No protocol specified
E: client-conf-x11.c: XOpenDisplay() failed
*** PULSEAUDIO: Unable to connect: Access denied

By giving "xhost +" and restarting mpd the XOpenDisplay() error disappears, but the error regarding PULSEAUDIO still persists.

This happend using the latest ubuntu gutsy as of 16.02.2008, as well as the current Hardy.

Pulseaudio was installed using https://wiki.ubuntu.com/PulseAudio on gutsy, and the system was upgraded to hardy using update-manager.

I have added mpd and root to all pulseaudio groups (pulse, pulse-access, pulse-rt), but this did not solve the problem.

Xine works using native pulse output and mythtv works using "ALSA:default" output device.

Regards,

Rune

Revision history for this message
Rune Evjen (rune-evjen) wrote :

I forgot to add the audio_output section of /etc/mpd.conf

audio_output {
        type "pulse"
        name "My MPD PulseAudio"
# server "localhost" # optional
# sink "alsa_output" # optional
}

Rune

Revision history for this message
Luke Yelavich (themuso) wrote :

I'm assuming from where mpd is logging, that you are running mpd as root, orfrom /etc/init.d/mpd. Have you tried running it as a user? By default, PulseAudio runs as the user, which is why mpd cannot find it.

Changed in pulseaudio:
status: New → Incomplete
Revision history for this message
Rune Evjen (rune-evjen) wrote : Re: [Bug 192735] Re: mpd no access to soundcard using pulseaudio

MPD is running as the user "mpd".

I manually added mpd to the pulseaudio groups.

This is default in the mpd ubuntu package as far as I can remebember from
when I installed it.

Rune

On 17/02/2008, Luke Yelavich <email address hidden> wrote:
>
> I'm assuming from where mpd is logging, that you are running mpd as
> root, orfrom /etc/init.d/mpd. Have you tried running it as a user? By
> default, PulseAudio runs as the user, which is why mpd cannot find it.
>
> ** Changed in: pulseaudio (Ubuntu)
> Status: New => Incomplete
>
> --
> mpd no access to soundcard using pulseaudio
> https://bugs.launchpad.net/bugs/192735
> You received this bug notification because you are a direct subscriber
> of the bug.
>

--
hilsen Rune Evjen
mailto:<email address hidden>

Revision history for this message
Daniel T Chen (crimsun) wrote :

Does "paplay /usr/share/sounds/*up.wav" result in audible audio?

Revision history for this message
Rune Evjen (rune-evjen) wrote :

"paplay /usr/share/sounds/alsa/Front_Center.wav" results in audioble audio.

Regards,

Rune

Revision history for this message
Daniel T Chen (crimsun) wrote :

If paplay works, then it's not a PulseAudio issue. Please see mpd.

Revision history for this message
Duncan Hawthorne (duncan.hawthorne) wrote :

problem still exist on hardy alpha 6 live cd by default.

if you run mpd as a user, with settings:

user "ubuntu"

audio_output {
type "pulse"
driver "esd"
options "host=localhost"
name "esd"
}

then you can succesfully get sound to play through mpd whilst another app is using the soundcard. putting the user mpd into the same groups or whatever may fix the problem I guess. This is the best solution i know as of now. mpd properly uses pulse and other apps can use pulse too, in any order

in my current set up mpd needs to start after pulse otherwise it wont play any sound. It will instantly skip through the entire playlist playing nothing. So i guess this is a problem for running mpd as a daemon (I'm unable to test right now) as then it would start far before pulse.

note: if pulseaudio isnt playing anything, the default settings do play sound, but this isnt good enough, and it doesnt appear in pulseaudio volume control

note: if you use the default settings (except change user to ubuntu), and nothing else is using the soundcard, mpd will play but then no other app will be able to play sound. however if something else IS already using the sound card then it will follow along and use pulse too.

Revision history for this message
Qball Cow (qball-qballcow) wrote :

There seems to be nothing with mpd.

using this audio_output (I am not sure the previous one is correct.)

audio_output {
# use the pulse output
   type "pulse"
# name
   name "My Pulse Device"
}

running mpd as user mpd (what is default in ubuntu) you need to make pulse a bit more easy on permissions
Edit /etc/pulse/default.pa and add
load-module module-native-protocol-tcp auth-anonymous=1
this gives permission to everybody to use pulse.

Then start mpd

And you have music.

Revision history for this message
Rune Evjen (rune-evjen) wrote :

After adding "load-module module-native-protocol-tcp auth-anonymous=1" to
/etc/pulse/default.pa I cannot get pulseaudio to start.
The above ine was insertet at de end of the config file.

After rebooting the computer, pulseaudio (or ps aux | grep pulse) does not
show pulse running.

When starting it manually from my user account I get:

ALSA lib control.c:909:(snd_ctl_open_noupdate) Invalid CTL front:0
ALSA lib control.c:909:(snd_ctl_open_noupdate) Invalid CTL front:0
E: socket-server.c: bind(): Address already in use
E: socket-server.c: bind(): Address already in use
E: module.c: Failed to load module "module-native-protocol-tcp" (argument:
"aut
h-anonymous=1"): initialization failed.
E: main.c: Module load failed.
E: main.c: failed to initialize daemon.

"paplay /usr/share/sounds/alsa/Front_Center.wav" gives the error Connection
failure: Connection refused

Rune

Revision history for this message
Qball Cow (qball-qballcow) wrote :

Do you have the line: load-module module-native-protocol-tcp twice in your config now? atleast that is what the error is telling me.

Revision history for this message
Rune Evjen (rune-evjen) wrote :

No, I did only have this one line. There was a similar line without the "auth", but it was commented out.

But after doing a apt-get remove --purge on all pulseaudio packages, and installing them again using
"apt-get install pulseaudio pulseaudio-esound-compat pulseaudio-modules-gconf", and starting up pulseaudio from the command line, I got everything working.

I now autostart pulseaudio in XFCE, and both mythtv and mpd shares the sound card.

Mythtv is configured with ALSA:default,
 and mpd with
audio_output {
 # use the pulse output
    type "pulse"
 # name
    name "My Pulse Device"
 }

The only thing now is that I have to restart the mpd service, probably because pulseaudio is is not available when the mpd script is run.

Rune

Revision history for this message
Duncan Hawthorne (duncan.hawthorne) wrote :

i confirm that:
adding "load-module module-native-protocol-tcp auth-anonymous=1" to
/etc/pulse/default.pa

and having in /etc/mpd.conf:
audio_output {
 # use the pulse output
    type "pulse"
 # name
    name "My Pulse Device"
 }

this works.
like the above poster says mpd has to be started after pulseaudio, which is not the current set up. however, if i keep double clicking on files for mpd to play (or wait a minute) it does eventually reconnect to pulse. (i cant work out what the process is). then everything works perfectly, the same as if pulse had started first.

still needs some other fix, as we dont want to have to wait a while.

Changed in mpd:
status: Incomplete → Confirmed
Revision history for this message
Khashayar Naderehvandi (khashayar) wrote :

I'm glad I found this bug. The solution seems to work for me. So the fix needs to go to pulseaudio then?

Daniel T Chen (crimsun)
Changed in pulseaudio:
importance: Undecided → Wishlist
status: New → Confirmed
Revision history for this message
Thomas Drapier (contact-thomasdrapier) wrote :

Confirm that Josh Smith's fix works.

Revision history for this message
Duncan Hawthorne (duncan.hawthorne) wrote :

i should mention that:
installing paprefs and selecting "enable network access to local sound devices" and "don't require authentication" is the user specific equivalent to:
load-module module-native-protocol-tcp auth-anonymous=1
which is system wide
The user specific solution is probably a much better solution for users as it means you dont have to edit system config files

but the bug seems to really be with mpd. perhaps selecting a different output like esd is best at the moment.

Revision history for this message
Duncan Hawthorne (duncan.hawthorne) wrote :

more info:

mpd needs the following in /etc/mpd.conf otherwise i cant get anything to happen, so this should surely be added by default:

audio_output {
        type "pulse"
        name "My pulse output"
}

then (without having done the "load-module module-native-protocol-tcp auth-anonymous=1" or the equivalent paprefs fix):
running mpd as user mpd, mpd doesnt work, mpd skips straight through the playlist without appearing in pavucontrol, and without playing any sound producing errors:
Jun 14 10:29 : Cannot connect to server in PulseAudio output "my pulse output" (attempt 1): Connection refused
Jun 14 10:29 : problems opening audio device while playing "Bloody Tourists/03 - Take These Chains.mp3"
in the errors.log file
running mpd as the current user, mpd works, mpd stream appears in pavucontrol mixes properly with other applications
running mpd as root, mpd works, mpd stream appears in pavucontrol, mixes properly with other applications

then now doing the fix "load-module module-native-protocol-tcp auth-anonymous=1" or the equivalent paprefs
running mpd as user mpd works, mpd stream appears in pavucontrol, mixes properly with other applications
the others still work.

so root and the current user have some permission that the user mpd doesnt, and this permission should be added to the user mpd (i think)
note: running mpd as root is not advised

anyone confirm my findings? i dont know enough about manipulating groups to do much more...

Revision history for this message
intuited (intuited) wrote :

I initially got this working by using the paprefs applet. pulse-related changes to my mpd.conf file are the same as the de facto solution. this solution is noted as an alternate solution in http://mpd.wikia.com/wiki/PulseAudio#For_Distros_where_PulseAudio_output_is_broken
This solution works & is necessary (unless you use the loadmodule fix) because
a) the mpd daemon is run by the user mpd and is unable to connect to that user's instance of pulseaudio because it doesn't exist
b) I have told the instance of pulseaudio that's running under my username to allow connections via tcp from unauthenticated users
c) mpd is able to make connections via tcp, and will do so to the localhost by default.

the problem, as I understand it, with this workaround, is that it leaves my instance of pulseaudio open to other users on either my local machine or anywhere on the LAN. so there's the possibility of unexpected bursts of sound emitting from the machine when I'm at, say, the library. yeah yeah hosts.allow.

with help from the section http://mpd.wikia.com/wiki/PulseAudio#On_Windows i gathered that copying ~/.pulse-cookie to the mpd user's home directory (and chowning it to that user) will let mpd get authorization to the pulseaudio server for that user, even if the paprefs option to allow unauthenticated users is unchecked and the loadmodule command is not specified. this is working fine under hardy. i also did # usermod -d /home/mpd mpd; not sure if that was necessary. again you do have to check the box in paprefs to enable network access to local sound devices.

but since this will only let mpd connect to one user's instance of pulseaudio, it's not a very good solution for a music server. more appropriate for, for example, a system that supplies audio to a stereo system and has various users logging into it, is to invoke a system-wide instance of pulse as per http://pulseaudio.org/wiki/SystemWideInstance, and copy /var/run/pulse/.pulse-cookie to /home/mpd instead of the user's cookie. there are some security & other issues associated with using a system-wide pulse instance; read all about it at the pulseaudio wiki link.

Daniel T Chen (crimsun)
Changed in pulseaudio:
status: Confirmed → Invalid
Revision history for this message
Andreas Moog (ampelbein) wrote :

Thanks for reporting, does this work with version 0.14.2 from the official repositories? If not, could you please also try the version available in my ppa (https://edge.launchpad.net/~amoog/+archive/ppa)? Thanks.

Changed in mpd (Ubuntu):
importance: Undecided → Medium
status: Confirmed → Incomplete
Revision history for this message
intuited (intuited) wrote :

Hi Andreas,
  I've since upgraded to 13.2 and it still working okay. I am pretty busy
but I will try to find time in the next week to check with 14.2. I assume
you mean to check if it can be made to authenticate through the
pulse-cookie?
Cheers
-Ted

On Wed, Apr 22, 2009 at 9:51 AM, Andreas Moog <
<email address hidden>> wrote:

> Thanks for reporting, does this work with version 0.14.2 from the
> official repositories? If not, could you please also try the version
> available in my ppa (https://edge.launchpad.net/~amoog/+archive/ppa<https://edge.launchpad.net/%7Eamoog/+archive/ppa>
> )?
> Thanks.
>
> ** Changed in: mpd (Ubuntu)
> Importance: Undecided => Medium
>
> ** Changed in: mpd (Ubuntu)
> Status: Confirmed => Incomplete
>
> --
> mpd no access to soundcard using pulseaudio
> https://bugs.launchpad.net/bugs/192735
> You received this bug notification because you are a direct subscriber
> of the bug.
>
> Status in “mpd” source package in Ubuntu: Incomplete
> Status in “pulseaudio” source package in Ubuntu: Invalid
>
> Bug description:
> Binary package hint: pulseaudio
>
> Version info:
>
> uname -r: 2.6.24-8-generic
> pulseaudio Version: 0.9.9-1ubuntu2
> mpd : Version: 0.13.1-3ubuntu1
>
> After changing from esound to pulseaudio, MPD is not able to access the
> sound card.
>
> MPD logs the following errors in /var/log/mpd/errors.log:
>
> No protocol specified
> E: client-conf-x11.c: XOpenDisplay() failed
> *** PULSEAUDIO: Unable to connect: Access denied
>
> By giving "xhost +" and restarting mpd the XOpenDisplay() error disappears,
> but the error regarding PULSEAUDIO still persists.
>
> This happend using the latest ubuntu gutsy as of 16.02.2008, as well as the
> current Hardy.
>
> Pulseaudio was installed using https://wiki.ubuntu.com/PulseAudio on
> gutsy, and the system was upgraded to hardy using update-manager.
>
> I have added mpd and root to all pulseaudio groups (pulse, pulse-access,
> pulse-rt), but this did not solve the problem.
>
> Xine works using native pulse output and mythtv works using "ALSA:default"
> output device.
>
> Regards,
>
> Rune
>

Revision history for this message
Andreas Moog (ampelbein) wrote :

Yeah, so that we can find out if it works on a freshly installed system. I tried in Virtualbox with Jaunty and did not need a tweak to make it work.

Revision history for this message
dhenry (tfc-duke) wrote :

The problem is still present in Karmic.

Enabling pulse output in /etc/mpd.conf:

audio_output {
 type "pulse"
 name "My Pulse Output"
}

And tunning PulseAudio preferences with paprefs as said in #15 ("enable network access to local sound devices" and "don't require authentication") fixes it.

MPD is still not ready out-of-the-box for Ubuntu.

Revision history for this message
Daniel T Chen (crimsun) wrote :

On Thu, Nov 12, 2009 at 3:34 AM, dhenry <email address hidden> wrote:
> Enabling pulse output in /etc/mpd.conf:
...
> MPD is still not ready out-of-the-box for Ubuntu.

Kubuntu and Xubuntu users also use MPD, and neither distribution ships
PulseAudio. Until all Ubuntu derivatives use the same backend, this
class of problems can't be resolved.

Revision history for this message
dhenry (tfc-duke) wrote :

Ah I didn't know that. But at least, the PulseAudio output could be added (MPD accept multiple configured outputs), and then user just chose the appropriate audio output (or we could even detect at install time that pulseaudio is the used audio backend in order to enable it for MPD).

Revision history for this message
Daniel T Chen (crimsun) wrote :

On Thu, Nov 12, 2009 at 1:05 PM, dhenry <email address hidden> wrote:
> Ah I didn't know that. But at least, the PulseAudio output could be
> added (MPD accept multiple configured outputs), and then user just chose
> the appropriate audio output (or we could even detect at install time
> that pulseaudio is the used audio backend in order to enable it for
> MPD).

That proposal has been given before, but how do you ensure that the
user who runs Ubuntu with kubuntu-desktop installed will actually want
to use PA?

Revision history for this message
dhenry (tfc-duke) wrote :

Maybe we can also look if PulseAudio is installed and if a pulseaudio process is running? If yes, we select it as the default Audio Output for MPD, if not we keep ALSA.

But anyway, we should enable (i.e. uncomment in /etc/mpd.conf) both ALSA and PulseAudio outputs, so that in case the wrong one is selected by default, it's easy for the user to change (some clients like gmpc allow to chose it in config dialog).

Also, we need to setup PulseAudio properly (network access to local sound devices).

Just a suggestion.

Revision history for this message
Aaron Peromsik (aperomsik) wrote :

My first impression when reading #17 was that it shouldn't be necessary to use system mode for PulseAudio to get mpd to work right. In Jaunty I had it working as desired without changing /etc/default/pulseaudio. The mpd wiki page referenced above seems to say that mpd can launch pulseaudio itself as needed... however the suggestions there didn't help in Karmic.

In Karmic, running pulseaudio in system mode seems to be required to use mpd as a server that keeps running regardless of whether a desktop user is logged in. For mpd to work with pulse in system mode I had to add the tcp setting mentioned above in comment #8 to /etc/pulse/system.pa (not default.pa, which would be used for user mode).

Revision history for this message
mathew (meta23) wrote :

I just hit this problem after upgrading to Ubuntu 10.10. Volume slider wasn't working at all, even though sound output worked.

Turned out the 10.10 upgrade had installed pulseaudio. Purging it and rebooting fixed the problem.

Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for mpd (Ubuntu) because there has been no activity for 60 days.]

Changed in mpd (Ubuntu):
status: Incomplete → Expired
Revision history for this message
crazybyte (vlzoltan) wrote :

This problem reappeared in Maverick (for me at least). I tried the paprefs fix and adding the auth-anonymous=1 line into default.pa (after uncommented the proper line) without any success. MPD complains about being unable to connect to pulse audio instance due to authentication error (Access denied error is issued). Any advice on how to deal with this issue? Thank you!

Changed in mpd (Ubuntu):
status: Expired → New
Revision history for this message
crazybyte (vlzoltan) wrote :

I managed find a fix by applying the suggested fixes (paprefs fix and modifying the default.pa) and also by copying the pulse-cookie file from the user home directory over the pulse-cookie that can be found in /var/lib/mpd.
I find that this is an unsatisfying and pretty ugly hack.
Could somebody somehow finally fix this please because it is annoying, to say at least, that even after such an extended period of time that PulseAudio is used actively, such annoying inconsistencies raise their ugly had.
Thank you!

P.S. Please don't take this comment in a bad way. I know you guys how much effort and work you put into making things work and I'm thankful for that, only I would love no to stumble over such little annoyances, especially when I want to convince someone else to use Linux (in this particular case Ubuntu Linux).

Changed in mpd (Ubuntu):
status: New → Confirmed
Revision history for this message
Florian Schlichting (fschlich) wrote :

as pulseaudio is run as the logged-in user, the fix is to also run mpd as the logged-in user, which is what will happen automatically if you disable mpd as a system service and provide your own ~/.mpdconf - see README.Debian for details

Changed in mpd (Ubuntu):
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.