From 4ea8fa81808f7087a68afb8e96f420232df0f126 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 29 Sep 2021 14:02:49 +1000 Subject: [PATCH] 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 --- src/daemon/systemd/system/pipewire-media-session.service.in | 1 + src/daemon/systemd/user/pipewire-media-session.service.in | 1 + src/daemon/systemd/user/pipewire-pulse.service.in | 4 ++-- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/daemon/systemd/system/pipewire-media-session.service.in b/src/daemon/systemd/system/pipewire-media-session.service.in index 1832f2b67..910d80b7c 100644 --- a/src/daemon/systemd/system/pipewire-media-session.service.in +++ b/src/daemon/systemd/system/pipewire-media-session.service.in @@ -18,3 +18,4 @@ Environment=PIPEWIRE_RUNTIME_DIR=%t/pipewire [Install] WantedBy=pipewire.service +Alias=pipewire-session-manager.service diff --git a/src/daemon/systemd/user/pipewire-media-session.service.in b/src/daemon/systemd/user/pipewire-media-session.service.in index a986e074f..4174d134f 100644 --- a/src/daemon/systemd/user/pipewire-media-session.service.in +++ b/src/daemon/systemd/user/pipewire-media-session.service.in @@ -17,3 +17,4 @@ Slice=session.slice [Install] WantedBy=pipewire.service +Alias=pipewire-session-manager.service diff --git a/src/daemon/systemd/user/pipewire-pulse.service.in b/src/daemon/systemd/user/pipewire-pulse.service.in index 56b8a64fb..73d22e532 100644 --- a/src/daemon/systemd/user/pipewire-pulse.service.in +++ b/src/daemon/systemd/user/pipewire-pulse.service.in @@ -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]