[pulseaudio-discuss] Proper way for a server to spawn Pulseaudio?

Tanu Kaskinen tanuk at iki.fi
Wed Aug 31 22:11:11 UTC 2016


On Thu, 2016-09-01 at 01:04 +0300, Tanu Kaskinen wrote:
> On Wed, 2016-08-31 at 23:03 +0200, Espen Jürgensen wrote:
> > 
> > Dear all, first of all thanks for your work on the Pulseaudio project!
> > 
> > I maintain a Linux music server, and I am working on adding a Pulseaudio
> > output for it. This is for local output. So far it has been simple and easy
> > working with Pulseaudio, but going ahead I am unsure about the best way of
> > spawning the Pulseaudio daemon. I hope someone here can give advice.
> > 
> > Most users of the music server will have it running as either root or a
> > dedicated user, and will run it on a headless server without any desktop
> > environment. Could be an RPi, for instance. So pretty much like mpd.
> > 
> > In such a setup the music server currently gets "Connection refused",
> > unless Pulseaudio has manually been started in system mode by the user (I
> > think...?). So, I have googled what to do in that situation, and that has
> > left me a little a confused. For instance, some of the mpd guides say that
> > Pulseaudio should autospawn - but that doesn't seem to happen for me, so
> > perhaps there is some condition that needs to be met? I have, of course,
> > set autospawn = yes (was already the default).
> 
> Autospawning works only in the per-user mode. In the system mode the
> expectation is to have an init script or a systemd service that starts
> pulseaudio at boot (with systemd, socket activation is possible too).
> 
> We don't provide init scripts or systemd service file for the system
> mode. Init scripts can't be provided, because they are not portable
> across distributions. Shipping a systemd service file would probably
> make sense, though.
> 
> > 
> > Other guides tell you to use TCP and add "auth-ip-acl=127.0.0.1" in
> > default.pa - but that seems a bit clumsy? Then there is also
> > recommendations on adding the server user to the Pulseaudio groups (pulse,
> > pulse-access), which I have tried, but which didn't seem to change much.
> 
> With the default settings, all users that want to use pulseaudio when
> it's running in the system mode have to be in the pulse-access group.
> The pulse group is only meant for the pulseaudio daemon - don't add
> users to that group.
> 
> > 
> > Of course, I would like to inconvenience the user as little as possible
> > with configuration activities, so with that in mind my question is: What is
> > the proper way to make a server spawn Pulseaudio, given that it is running
> > as root or dedicated user and that there is no desktop?
> 
> I think starting pulseaudio at boot in the system mode makes most
> sense for headless systems. I don't think another server-type
> application should spawn it.
> 
> When your server runs under a dedicated user, autospawning should work,
> but then you'll probably run into problems with not having access to
> the audio hardware, because typically the device permissions are
> handled dynamically so that only the currently-active login session has
> access. Trying to "fix" this by making the device permissions static
> will cause breakage, because your music server will then hog the
> hardware so that regular users can't access it anymore. It's probably
> best if you use the PA_CONTEXT_NOAUTOSPAWN flag in your application
> when connecting to pulseaudio, unless your application runs inside a
> regular user login session.

I forgot to mention - before telling users how to configure pulseaudio
to run in the system mode, make them read this first, so they know the
problems:
https://wiki.freedesktop.org/www/Software/PulseAudio/Documentation/User/WhatIsWrongWithSystemWide/

-- 
Tanu


More information about the pulseaudio-discuss mailing list