8

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?

2
  • 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, 2011 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. Mar 5, 2011 at 15:30

3 Answers 3

5

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.

5
  • 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! Mar 5, 2011 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
    – Fern Moss
    Mar 5, 2011 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? Mar 8, 2011 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!
    – Fern Moss
    Mar 8, 2011 at 19:58
  • This problem caused me some trouble too, until I isolated it to MPD. By the way the first solution involving paprefs did not work for me but the second did.
    – Laurence
    Jul 9, 2016 at 16:00
2

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

1
  • 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, 2012 at 10:55
0

When run as its own user as per the wiki instructions, mpd will be unable to send sound to another user's pulseaudio server. Rather than setting up pulseaudio as a system-wide daemon, a practice strongly discouraged by upstream, you can instead configure mpd to use pulseaudio's tcp module to send sound to localhost:

First, uncomment the tcp module in /etc/pulse/default.pa or $XDG_CONFIG_HOME/pulse/default.pa (typically ~/.config/pulse/default.pa) and set 127.0.0.1 as an allowed IP address; the home directory takes precedence:

### Network access (may be configured with paprefs, so leave this commented
### here if you plan to use paprefs)
#load-module module-esound-protocol-tcp
load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1
#load-module module-zeroconf-publish

Additional IP ranges in cidr notation may be added using ; as the separator. Once this is complete, restart pulseaudio:

$ pulseaudio --kill
$ pulseaudio --start -or- start-pulseaudio-x11/kde

Next, edit /etc/mpd.conf and add a new pulse output pointing to 127.0.0.1 as a "remote" server:

audio_output {
       type     "pulse"
       name     "Local Music Player Daemon"
       server       "127.0.0.1"
}

from https://wiki.archlinux.org/index.php/Music_Player_Daemon/Tips_and_tricks

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .