Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Simple explanation

If mpd is playing and sound attempts to play through another application, x, sound from x will not be output.

If sound from another application, x, is playing and mpd then attempts to play, no sound will be output from mpd whilst sound from x continues to play.

Details

I first noticed this problem with Flash, and this continues to be the most common scenario. I posted a question about this before realising it was not strictly Flash-related, but instead is something to do with mpd.

My biggest frustration comes from trying to get mpd working again, as I can't seem to pin down any method. Sometimes pulseaudio -k seems to help, other times sudo /etc/init.d/mpd restart, others killing Chromium (due to Flash) with SIGTERM. Most of the time it's a combination of the above.

I think this might be because I run mpd as another user and use pulseaudio. It is not run as root or current user. Also, mpd is compiled with pulse support.

I have tried numerous things, however I honestly couldn't recite what, as it has been some time since. I'd rather not go poking around without some direction, but I'd be really happy to fix this problem once and for all.

mpd.conf

Simplified by removing comments/blank lines.

music_directory     "/var/lib/mpd/music"
playlist_directory      "/var/lib/mpd/playlists"
db_file         "/var/lib/mpd/tag_cache"
log_file            "/var/log/mpd/mpd.log"
pid_file            "/var/run/mpd/pid"
state_file          "/var/lib/mpd/state"

user                "mpd"
bind_to_address     "wilson"

input {
        plugin "curl"
}

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

}

filesystem_charset      "UTF-8"
id3v1_encoding          "UTF-8"

Question

For the sake of keeping this a question: does anyone know what is causing this, or how to fix it without running mpd as the current user?

share|improve this question
1  
When playing something through mpd (and the sound from it is working) load up the sound properties window, hit the applications tab and this will tell you for certain if mpd is using PA or not. –  Oli Mar 4 '11 at 20:31
    
Running mpd as current user, as per Alibara Iduas' instructions, works around the issue. I am still interested in why this will not run correctly as the user "mpd", though. –  Jamie Schembri Mar 5 '11 at 15:30

2 Answers 2

I had this problem when I first started using mpd, but it was quite some time ago, so I can't exactly remember what I did to fix it!

Do you have PulseAudio preferences installed? I found this tip on a forum: sudo apt-get install paprefs

Then open PulseAudio prefrences from the menu: System->Preferences->PulseAudio Preferences Click the Network Server tab, then check the "Enable network access to local sound devices" box, and finally check the "Don't require authentication" box. After that, restart mpd: sudo /etc/init.d/mpd restart

However... I just realized that mpd works fine for me and I don't have "network access to local sound devices" enabled.

I think you might be right about needing to run mpd as the current user, which is what I'm doing. (I have no clue as to why this is though!)

A simple guide to setting up mpd to be run as a user can be found here: http://gmpc.wikia.com/wiki/MPD_INSTALL_USER_SERVICE_UBUNTU

To sum things up, since you already have mpd installed:

1.) Stop it: sudo update-rc.d mpd disable

2.) Copy your mpdconf to your home directiory (as .mpdconf), and change the following entries to places where your user can access and write to:

music_directory
playlist_directory
db_file
log_file
error_file
pid_file
state_file 

The page I'm taking this from suggests just creating a .mpd folder in your home directory for this stuff, save for your actual music directory.

3.) Comment out the user line in .mpdconf: #user "mpd"

4.) Now you can run mpd and update the database.

5.) To make mpd start up automatically as a user when logging in, go to Startup Applications and add an entry for mpd, then create an autostart file in ~/.config/autostart/.

[Desktop Entry]
Type=Application
Exec=mpd
Hidden=false
NoDisplay=false
Terminal=false
X-GNOME-Autostart-enabled=true
Name[en_US]=Music Player Daemon
Name=Music Player Daemon
Comment[en_US]=plays the music
Comment=plays the music

There are probably downsides to running as a user, so maybe this won't suit your needs.

share|improve this answer
    
Before reading this, I purged pulseaudio and mpd. Pulseaudio worked pretty much after installing, but I could not get sound back on mpd for some reason. Anyway, I ended up following the guide and now I'm running mpd as current user and it works fine. I'd have preferred to run it as user "mpd", and since this is more of a workaround than an answer, I won't accept it as an answer. I'm still interested in why mpd won't run as user "mpd" in the way that I'd like it to (maybe pulseaudio should run under root?). Regardless, I hope you understand and you have my thanks! –  Jamie Schembri Mar 5 '11 at 15:29
1  
No problem, glad it at least works now. The only other thing I could think of would be to make sure, when running it as user mpd, that "mpd" is listed as a group member in the pulse-access (and maybe also pulse) group. But I would imagine that would only be an issue if you had no sound at all, not this odd conflict. Hm, also, see the sections "MPD & Alsa" and "MPD & PulseAudio" in this Archlinux wiki page: wiki.archlinux.org/index.php/Music_Player_Daemon –  Aibara Iduas Mar 5 '11 at 20:37
    
Thanks again, Aibara. I had previously ensured that mpd was in the correct groups for pulse, so that wasn't the issue in this case. The link you posted is very interesting, particularly in that it describes my exact problem in the "MPD & Alsa" section mentioned! Would this be adaptable to Pulse? –  Jamie Schembri Mar 8 '11 at 0:03
    
It is odd that the same problem has an easy solution with Alsa, but I'm really not sure if the Alsa solution could be applied to Pulse - that's really beyond me. Everything I've read on people having this problem with Pulse either end up running MPD as a user, or the PulseAudio preferences change. Sorry! –  Aibara Iduas Mar 8 '11 at 19:58

Not sure if it's exactly the same problem, but with my old default-ish mpd setup, I think mpd was trying to start its own pulse audio as a different user (the mpd user). I found setting my pulse output in /etc/mpd.conf to using a socket to connect is simpler to avoid this kind of problem.

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

Then you might want to check paprefs that you accept local connections

share|improve this answer
    
On Gentoo, I also need to copy my users .pulse-cookie to /var/lib/mpd to get this to work, or the pulseaudio failed with failed to connect: Access denied, though I'm not sure is that the right way. –  rebus Dec 13 '12 at 10:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.