systemd: make pipewire-pulse require one of the session managers

Where pipewire and friends are started via socket activation,
a PA client connection to the pulse socket triggers
pipewire-pulse.service. That in turn triggers pipewire.service through
Wants/After and once that is started up, pipewire-pulse actually
starts up.

At the same time, pipewire-media-session or wireplumber are started
through WantedBy/after in the respective service files.

Depending on which leg the race condition got out of bed with today,
pipewire-pulse may be finished before the session manager has set up the
graph and the PA client doesn't see any devices.

Fix this by adding a dependency on the session manager in
pipewire-pulse, installed via an Alias so media-session and wireplumber
can install the same alias. Wants is a light dependency, so for the case
where it doesn't exist we fall back to the current behavior anyway.

This doesn't remove the race condition since systemd may deem the
session manager to have started before the graph is set up, but it
should reduce the occurances.

The disadvantage here: only one Alias will be installed by systemd, so
first-come, first-serve in the case of both media-session and
wireplumber being installed.

See #1553
This commit is contained in:
Peter Hutterer 2021-09-29 14:02:49 +10:00 committed by Wim Taymans
parent 90cbcb6c05
commit 4ea8fa8180
3 changed files with 4 additions and 2 deletions

View file

@ -18,3 +18,4 @@ Environment=PIPEWIRE_RUNTIME_DIR=%t/pipewire
[Install]
WantedBy=pipewire.service
Alias=pipewire-session-manager.service

View file

@ -17,3 +17,4 @@ Slice=session.slice
[Install]
WantedBy=pipewire.service
Alias=pipewire-session-manager.service

View file

@ -15,8 +15,8 @@ Description=PipeWire PulseAudio
# socket-service relationship, see systemd.socket(5).
Requires=pipewire-pulse.socket
ConditionUser=!root
Wants=pipewire.service
After=pipewire.service
Wants=pipewire.service pipewire-session-manager.service
After=pipewire.service pipewire-session-manager.service
Conflicts=pulseaudio.service
[Service]