February 8, 2010 · General · Email This Post

Sponsored Link
This tutorial is meant for Ubuntu 9.10 Karmic Koala, but it might work in earlier or later versions as well.

Full Credit goes here

The goal is to get the MPD daemon working using PulseAudio, but without it being dependent on the X server or a session. To do that we must configure PulseAudio to run in system-wide daemon mode (which is not recommended by the developers, but in this case we do not have a choice). This means it will be using the /etc/pulse/system.pa config file instead of the usual /etc/pulse/default.pa. We must also make sure the appropriate user/group permissions are set, or PulseAudio will be rejecting the connections.

The result will be an interrupt-less music environment, not dependent on the X server. Meaning we can for example log out and log in without the music having to stop for even a second. Switching TTYs (Ctrl+Alt+Fx) will also keep the music playing (not possible by default). All that and PulseAudio will still be able to detect and configure all your devices automatically.

Procedure to follow
1.Make sure you add your username to the following system groups: pulse, pulse-access and audio.
Do that by going to System --> Administration --> Users and Groups.

Click the unlock button (the one with a picture of some keys), then click Manage Groups. In the list of groups that pops up, for each of the previously mentioned groups click "Properties" and select all the users that you want to have this functionality.

2.Press Alt+F2 and type:

gksudo gedit /etc/default/pulseaudio

Change PULSEAUDIO_SYSTEM_START from 0 to 1 and DISALLOW_MODULE_LOADING from 1 to 0.

Save the file and close the editor.
3.Press Alt+F2 and type:

gksudo gedit /etc/pulse/system.pa

Find this section:

### Automatically load driver modules depending on the hardware available
.ifexists module-hal-detect.so
load-module module-hal-detect
.else
### Alternatively use the static hardware detection module (for systems that
### lack HAL support)
load-module module-detect
.endif

Change it to:

### Automatically load driver modules depending on the hardware available
.ifexists module-udev-detect.so
load-module module-udev-detect
.else
### Alternatively use the static hardware detection module (for systems that
### lack HAL support)
load-module module-detect
.endif

Save the file and close the editor.

4.Install the MPD daemon and a MPD client of your choice.

Open Synaptic Package Manager (System --> Administration --> Synaptic Package Manager) and find the mpd package and the client of your choice (my recommendation is the Ario client). Mark the packages for installation and click Apply.

5.Press Alt+F2 and type:

gksudo gpasswd -a mpd pulse-access

6.Press Alt+F2 and type:

gksudo gedit /etc/mpd.conf

Find the following section:

audio_output {
type        "alsa"
name        "My ALSA Device"
device        "hw:0,0"    # optional
format        "44100:16:2"    # optional
mixer_device    "default"    # optional
mixer_control    "PCM"        # optional
mixer_index    "0"        # optional
}

Make sure it is all commented out, by putting a # symbol in front of each line, so that it looks like this:

#audio_output {
#    type        "alsa"
#    name        "My ALSA Device"
#    device        "hw:0,0"    # optional
#    format        "44100:16:2"    # optional
#    mixer_device    "default"    # optional
#    mixer_control    "PCM"        # optional
#    mixer_index    "0"        # optional
#}

Then in the same file, add the following:

audio_output {
type        "pulse"
name        "MPD PulseAudio Stream"
}

Save the file and close the editor.

7. Reboot your computer and you should be able to use MPD via PulseAudio without any interferences when switching TTYs or when killing the whole X server.

Sponsored Link

Incoming search terms:

Related posts

1 Comment to “How to setup MPD with PulseAudio independent on X”

  1. Christian says:

    great article !
    I was going crazy about not beeing able to use vnc without gui login over remote shell

    [Reply]

Leave a Reply