4

Pi 3 running on a unmodified updated raspbian jessie.
Problem: The pulseaudio server does not run OR not properly run at startup.

With defaults, where nothing was modified:

ps aux  | grep pulse
pi         851  0.0  0.0   1912    92 ?        S    09:11   0:00 /bin/sh /usr/bin/start-pulseaudio-x11

As can be seen something is running, but pactl is not able to connect to the server...

$ pactl stat
Connection failure: Connection refused
pa_context_connect() failed: Connection refused

However if /etc/xdg/autostart/pulseaudio.desktop is modified or removed And pulseaudio started after logging in via ssh, pactl connects to the pulseaudio-server !

$pactl stat
Currently in use: 1 blocks containing 64.0 KiB bytes total.
Allocated during whole lifetime: 59 blocks containing 1.8 MiB bytes total.
Sample cache size: 0 B
Server String: /run/user/1000/pulse/native
Library Protocol Version: 29
Server Protocol Version: 29
Is Local: yes
Client Index: 3
Tile Size: 65496
User Name: pi
Host Name: raspberrypi
Server Name: pulseaudio
Server Version: 5.0

Changing the autostart file to something like the following doesn't change anything:

[Desktop Entry]
Exec=pulseaudio -D
Type=Application

Syslog has only one repeated pulseaudio related message

Successfully made thread 910 of process 910 (/usr/bin/pulseaudio) owned by '1000' high priority at nice level -11.

Tried running pulseaudio in rc.local - didn't help .

So why isn't pulseaudio not running at startup, and is there a fix ?

3

Pulseaudio is incredibly tedious. I think this has something to do with dbus.

I've been sitting here for hours just to get it working somehow. Tried systemd units system-wide, systemd units in --user mode, … nothing worked.

The only way I got this to work was:

  • move away the provided autostart:

    mv /etc/xdg/autostart/pulseaudio.desktop
    /etc/xdg/autostart/pulseaudio.desktop.deac
    
  • create a file .config/autostart/pulseaudio.desktop:

    [Desktop Entry]
    Version=1.0
    Name=PulseAudio Sound System
    Exec=/bin/sh -c "sleep 10; pulseaudio --start"
    Terminal=false
    Type=Application
    X-GNOME-Autostart-Phase=Initialization
    NotShowIn=KDE;
    

Sleeping for a few seconds seems to be important!

Maybe this post, Is an X DISPLAY variable really necessary for dbus? could provide a more elegant solution?

  • Thanks that worked! I haven't tested thoroughly, but pactl stat shows that it is connecting to the server. – gyaani_guy Jun 25 '16 at 16:41
1

So I've just come across this thread and found it useful. Flittermice's answer was nearly there for me but I may a slight amendment which seems to have worked well.

In the /etc/xdg/autostart/pulseaudio.desktop file the config says to Exec=start-pulseaudio-x11 and if you trace this file it's actually a shell script located in /usr/bin/. This script itself will actually start pulseaudio as well as the X11 components but this is obviously failing, and I've no reason to disagree with flittermice's assertion this is an issue with dbus or his approach to hacking around it.

So rather than replace the entire /etc/xdg/autostart/pulseaudio.desktop I just applied flittermice's sleep command here changing the Exec line to read...

Exec=/bin/sh -c "sleep 5; start-pulseaudio-x11"

I prefer this approach as it retains the checks and service start/stops that the referenced start-pulseaudio-x11 script carries out.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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