[pulseaudio-discuss] starting multiple pulseaudio instances for the same user

Colin Guthrie gmane at colin.guthr.ie
Wed Apr 13 09:50:54 PDT 2011

'Twas brillig, and Antoine Martin at 08/04/11 22:20 did gyre and gimble:
> Hi,
> How can I start multiple copies of pulseaudio for the same $USER, but in
> different contexts?
> This was working a while back (last year or so - not sure about version
> numbers).. but doesn't any more?
> My software starts a virtual X server (xpra, vnc..), dbus and a
> dedicated pulseaudio server for each "session application" it launches.
> This allows it to redirect the sound (in and out) to/from remote
> machines (potentially multiple at once too, some directly, some via
> gstreamer+vorbis over ssh) - all this together with the display. see (1)
> Each "application session" gets its own environment and starts
> pulseaudio with:
> /usr/bin/pulseaudio --start -vvvv --disable-shm=true --daemonize=false
> --use-pid-file=false --system=false --exit-idle-time=-1 -n
> --load=module-suspend-on-idle --load=module-null-sink
> "--load=module-native-protocol-unix socket=/tmp/pulse-$DISPLAY/native"
> A single $USER may start dozens of those sessions, each with a different
> (virtual) $DISPLAY.
> Now, when I start the second instance I can see that it somehow finds
> the previous copy (not the one used by my local X11 session)
> [pid  3044]
> open("/home/antoine/.pulse/70a1ab2a8c9d6cb7625f17060000000d-runtime/autospawn.lock",
> [pid  3044] fcntl(5, F_SETLKW, {type=F_WRLCK, whence=SEEK_SET, start=0,
> len=0}
> From that point onwards, nothing happens.
> Can you please advise on how to restore this functionality?

This is something that is not supported.

PA is, plain and simple, a per-user daemon.

If you want to direct sound from different DISPLAYs to different PA
servers/sinks you can use the PULSE_SERVER and/or PULSE_SINK property on
the X11 root window.

This functionality will get even more difficult to hack round in the
future when XDG_SESSION_DIR is supported (i.e. when it's rolled out via
systemd and supported by PA) so I'd recommend trying to find a way that
works where just one PA daemon per-user is started but appropriate
hacking of the X11 root window properties is done instead to acheive the
same result.

There will ultimately likely always be ways to get the end result you
need tho' :)



Colin Guthrie

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mageia Contributor [http://www.mageia.org/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]

More information about the pulseaudio-discuss mailing list