13

I want to run Pulseaudio system wide, on a headless CentOS 7 server. Pulseaudio works great if I startx but in text mode (runlevel 3 equivalent) pulse audio clients fail.

So I created a systemd service file:

[Unit] Description=PulseAudio Daemon [Install] WantedBy=multi-user.target [Service] Type=simple PrivateTmp=true ExecStart=/usr/bin/pulseaudio --system --realtime --disallow-exit --no-cpu-limit 

which starts, but I see the following in journalctl:

Jan 19 13:31:47 lserver.mydomain pulseaudio[2523]: W: [pulseaudio] main.c: Running in system mode, but --disallow-module-loading not set! Jan 19 13:31:47 lserver.mydomain pulseaudio[2523]: N: [pulseaudio] main.c: Running in system mode, forcibly disabling SHM mode! Jan 19 13:31:47 lserver.mydomain pulseaudio[2523]: N: [pulseaudio] main.c: Running in system mode, forcibly disabling exit idle time! Jan 19 13:31:47 lserver.mydomain pulseaudio[2523]: W: [pulseaudio] main.c: OK, so you are running PA in system mode. Please note that you most likely shouldn't be doing that. Jan 19 13:31:47 lserver.mydomain pulseaudio[2523]: W: [pulseaudio] main.c: If you do it nonetheless then it's your own fault if things don't work as expected. Jan 19 13:31:47 lserver.mydomain pulseaudio[2523]: W: [pulseaudio] main.c: Please read http://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/WhatIsWrongWithSystemWide/ for an explanation why system mode is usually a bad idea. Jan 19 13:31:48 lserver.mydomain pulseaudio[2523]: N: [pulseaudio] alsa-util.c: Disabling timer-based scheduling because running inside a VM. Jan 19 13:31:48 lserver.mydomain pulseaudio[2523]: N: [pulseaudio] alsa-util.c: Disabling timer-based scheduling because running inside a VM. Jan 19 13:31:48 lserver.mydomain pulseaudio[2523]: W: [pulseaudio] authkey.c: Failed to open cookie file '/var/run/pulse/.config/pulse/cookie': No such file or directory Jan 19 13:31:48 lserver.mydomain pulseaudio[2523]: W: [pulseaudio] authkey.c: Failed to load authentication key '/var/run/pulse/.config/pulse/cookie': No such file or directory Jan 19 13:31:48 lserver.mydomain pulseaudio[2523]: W: [pulseaudio] authkey.c: Failed to open cookie file '/var/run/pulse/.pulse-cookie': No such file or directory Jan 19 13:31:48 lserver.mydomain pulseaudio[2523]: W: [pulseaudio] authkey.c: Failed to load authentication key '/var/run/pulse/.pulse-cookie': No such file or directory Jan 19 13:31:48 lserver.mydomain systemd[1]: Got message type=signal sender=org.freedesktop.DBus destination=n/a object=/org/freedesktop/DBus interface=org.freedesktop.DBus member=NameOwnerChanged cookie=56 reply_cookie=0 error=n/a Jan 19 13:31:48 lserver.mydomain systemd-logind[575]: Got message type=signal sender=org.freedesktop.DBus destination=n/a object=/org/freedesktop/DBus interface=org.freedesktop.DBus member=NameOwnerChanged cookie=56 reply_cookie=0 error=n/a Jan 19 13:31:48 lserver.mydomain systemd-logind[575]: Got message type=signal sender=org.freedesktop.DBus destination=n/a object=/org/freedesktop/DBus interface=org.freedesktop.DBus member=NameOwnerChanged cookie=57 reply_cookie=0 error=n/a Jan 19 13:31:48 lserver.mydomain systemd[1]: Got message type=signal sender=org.freedesktop.DBus destination=n/a object=/org/freedesktop/DBus interface=org.freedesktop.DBus member=NameOwnerChanged cookie=57 reply_cookie=0 error=n/a 

and attempts to access audio fail:

speaker-test 1.1.1 Playback device is default Stream parameters are 48000Hz, S16_LE, 1 channels Using 16 octaves of pink noise ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Access denied Playback open error: -111,Connection refused 

And after speaker-test the log shows:

Jan 19 14:06:39 lserver.ocg.ca pulseaudio[2795]: W: [pulseaudio] protocol-native.c: Denied access to client with invalid authentication data. 

User root is added to the 'audio' group. And speaker-test is being run as root. Can someone suggest how to fix this?

2
  • 2
    That posting is how to run under user - not the same as this question: Pulse has to run as system Commented Jan 19, 2017 at 19:12
  • I changed permissions on /var/run/pulse/.config/pulse/cookie to 550 and now on service start the cookie file/authentication error is gone. But still the denied message exists on running speaker-test Commented Jan 19, 2017 at 19:38

2 Answers 2

15

After some experimentation I found that modifying /etc/pulse/system.pa to permit anonymous:

load-module module-native-protocol-unix auth-anonymous=1 

The audio now plays fine. Hope this helps others needing system mode pulse

2
  • Valid hack (+1). That will run /usr/bin/pactl load-module (...) which is what the default xinitrc (or gnome/kde equivalent) seems to be doing. It should work, but asking the user to run this instead with /usr/bin/pactl load-module module-native-protocol-unix (without annonymous-auth) should be better since it prevents remote access (that may be possible if you use a network socket instead of a unix socket for commonication). On the other hand you could also install X11 libs and load module-x11-publish, it does not need Xorg running. Disclaimer didn't test it though. Commented Jan 20, 2017 at 0:01
  • thank you so so much for this answer.. nearly wasted 3 hours on this and it wouldn't work until I did this! Commented Apr 13, 2021 at 1:52
0

Included in your output is this feedback about running PulseAudio as a system user:

Please read http://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/WhatIsWrongWithSystemWide/ for an explanation why system mode is usually a bad idea.

The alternative is run PulseAudio as the user you login as. How to do that is a question that has already been answered.

1
  • 6
    This is running headless on a server, no user login. Multiple processes may output sound simultaneously. Already saw that link, and it indicates this situation is appropriate to run under system. So question is ok Commented Jan 19, 2017 at 19:14

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.