Pipewire as system service with PA tunnel needs clear documentation
- PipeWire version (
pipewire --version
):
pipewire
Compiled with libpipewire 0.3.48
Linked with libpipewire 0.3.48
- Distribution and distribution version (
PRETTY_NAME
from/etc/os-release
):Ubuntu Jammy Jellyfish (development branch)
- Desktop Environment:
kodi
- Kernel version (
uname -r
):5.15.0-18-generic
Description of Problem:
I have not been able to successfully configure Pipewire in a system mode similar to that of Pulseaudio. There are hints that this should be possible, but nothing I have tried succeeds.
I am happy to update the documentation and wiki with support received here and otherwise.
What I am trying to achieve
I have a server running Kodi, a Bluetooth receiver, and I wish to stream audio from laptops on the local network using the Pulseaudio Tunnel. Ideally I would like to do this in a Pipewire native manner so I can use the patchbays etc so I can add delays and eq.
How Reproducible:
I have had no success playing audio using Pipewire from fresh install.
Steps to Reproduce:
- Install Ubuntu Jammy with minimal packages
- Ensure Pipewire is installed
sudo apt install pipewire pipewire-pulse wireplumber
- Add the
pipewire
group and user:
sudo addgroup --gid 901 pipewire
sudo adduser --system --uid 091 --gid 901 pipewire
- Create
pipewire
directory in/etc
:
sudo mkdir /etc/pipewire
- Copy the system wide profiles from into
/etc/systemd/system
and
# clone pipewire somewhere
sudo cp -a ~/src/pipewire/src/daemon/systemd/system/pipewire.service.in /etc/systemd/system/pipewire.service
sudo cp -a ~/src/pipewire/src/daemon/systemd/system/pipewire.socket /etc/systemd/system/
- Edit to be:
[Unit]
Description=PipeWire Multimedia Service
# We require pipewire.socket to be active before starting the daemon, because
# while it is possible to use the service without the socket, it is not clear
# why it would be desirable.
#
# Installing pipewire and doing `systemctl start pipewire` will not get the
# socket started, which might be confusing and problematic if the server is to
# be restarted later on, as the client autospawn feature might kick in. Also, a
# start of the socket unit will fail, adding to the confusion.
#
# After=pipewire.socket is not needed, as it is already implicit in the
# socket-service relationship, see systemd.socket(5).
Requires=pipewire.socket
[Service]
LockPersonality=yes
MemoryDenyWriteExecute=yes
NoNewPrivileges=yes
RestrictNamespaces=yes
SystemCallArchitectures=native
SystemCallFilter=@system-service
Type=simple
AmbientCapabilities=CAP_SYS_NICE
#ExecStart=@PW_BINARY@
ExecStart=/usr/bin/pipewire
Restart=on-failure
RuntimeDirectory=pipewire
RuntimeDirectoryPreserve=yes
User=pipewire
Environment=PIPEWIRE_RUNTIME_DIR=%t/pipewire
# Added for debugging
Environment=PIPEWIRE_DEBUG=4
[Install]
Also=pipewire.socket
WantedBy=default.target
- Disable user services and enable system services:
sudo systemctl daemon-reload
systemctl --user disable --now pipewire-pulse.socket pipewire-pulse.service pipewire.service wireplumber.service
sudo systemctl enable pipewire.socket pipewire.service # wireplumber?
sudo systemctl start pipewire.socket pipewire.service
sudo systemctl status pipewire.socket
● pipewire.socket - PipeWire Multimedia System Socket
Loaded: loaded (/etc/systemd/system/pipewire.socket; disabled; vendor preset: enabled)
Active: active (running) since Tue 2022-03-08 19:52:13 NZDT; 2min 11s ago
Triggers: ● pipewire.service
Listen: /run/pipewire/pipewire-0 (Stream)
Tasks: 0 (limit: 9350)
Memory: 0B
CPU: 1ms
CGroup: /system.slice/pipewire.socket
Mar 08 19:52:13 nuliayuk systemd[1]: Starting PipeWire Multimedia System Socket...
Mar 08 19:52:13 nuliayuk systemd[1]: Listening on PipeWire Multimedia System Socket.
systemctl status pipewire.service
● pipewire.service - PipeWire Multimedia Service
Loaded: loaded (/etc/systemd/system/pipewire.service; disabled; vendor preset: enabled)
Active: active (running) since Tue 2022-03-08 19:54:58 NZDT; 19s ago
TriggeredBy: ● pipewire.socket
Main PID: 2928 (pipewire)
Tasks: 2 (limit: 9350)
Memory: 1.1M
CPU: 13ms
CGroup: /system.slice/pipewire.service
└─2928 /usr/bin/pipewire
Mar 08 19:54:58 nuliayuk pipewire[2867]: spa.system: 0x5610450d2368: close fd:8
Mar 08 19:54:58 nuliayuk pipewire[2867]: spa.system: 0x5610450d2368: close fd:6
Mar 08 19:54:58 nuliayuk pipewire[2867]: spa.system: 0x5610450d2368: close fd:7
Mar 08 19:54:58 nuliayuk pipewire[2867]: spa.system: 0x5610450d2368: close fd:5
Mar 08 19:54:58 nuliayuk pipewire[2867]: pw.context: clear handle 'support.system'
Mar 08 19:54:58 nuliayuk systemd[1]: pipewire.service: Deactivated successfully.
Mar 08 19:54:58 nuliayuk systemd[1]: Stopped PipeWire Multimedia Service.
Mar 08 19:54:58 nuliayuk systemd[1]: Started PipeWire Multimedia Service.
Mar 08 19:54:58 nuliayuk pipewire[2928]: spa.dbus: Failed to connect to session bus: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
Mar 08 19:54:58 nuliayuk pipewire[2928]: mod.portal: Failed to connect to session bus: Input/output error
- Try to add TCP tunnel etc and see if anything improves:
sudo cp -a /usr/share/pipewire/pipewire.conf /etc/pipewire/
sudo vim /etc/pipewire/pipewire.conf
add
context.modules = [
...
{ name = libpipewire-module-protocol-pulse
args = {
# the addresses this server listens on
server.address = [
"unix:native"
#"unix:/tmp/something" # absolute paths may be used
"tcp:4713" # IPv4 and IPv6 on all addresses
#"tcp:[::]:9999" # IPv6 on all addresses
#"tcp:127.0.0.1:8888" # IPv4 on a single address
#
#{ address = "tcp:4713" # address
# max-clients = 64 # maximum number of clients
# listen-backlog = 32 # backlog in the server listen queue
# client.access = "restricted" # permissions for clients
#}
]
#pulse.min.req = 256/48000 # 5ms
#pulse.default.req = 960/48000 # 20 milliseconds
#pulse.min.frag = 256/48000 # 5ms
#pulse.default.frag = 96000/48000 # 2 seconds
#pulse.default.tlength = 96000/48000 # 2 seconds
#pulse.min.quantum = 256/48000 # 5ms
#pulse.default.format = F32
#pulse.default.position = [ FL FR ]
# These overrides are only applied when running in a vm.
vm.overrides = {
pulse.min.quantum = 1024/48000 # 22ms
}
}
}
{ name = libpipewire-module-zeroconf-discover }
restart pipewire
sudo systemctl restart pipewire.service
systemctl status pipewire.service
● pipewire.service - PipeWire Multimedia Service
Loaded: loaded (/etc/systemd/system/pipewire.service; disabled; vendor preset: enabled)
Active: active (running) since Tue 2022-03-08 20:05:52 NZDT; 17s ago
TriggeredBy: ● pipewire.socket
Main PID: 3122 (pipewire)
Tasks: 3 (limit: 9350)
Memory: 2.6M
CPU: 27ms
CGroup: /system.slice/pipewire.service
└─3122 /usr/bin/pipewire
Mar 08 20:05:52 nuliayuk systemd[1]: Started PipeWire Multimedia Service.
Mar 08 20:05:52 nuliayuk pipewire[3122]: spa.dbus: Failed to connect to session bus: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
Mar 08 20:05:52 nuliayuk pipewire[3122]: mod.portal: Failed to connect to session bus: Input/output error
Mar 08 20:05:52 nuliayuk pipewire[3122]: mod.protocol-pulse: could not find a suitable runtime directory in$PULSE_RUNTIME_PATH and $XDG_RUNTIME_DIR
Mar 08 20:05:52 nuliayuk pipewire[3122]: mod.protocol-pulse: pulse-server 0x5570c66cf500: failed to parse address 'unix:native': No such file or directory
Mar 08 20:05:52 nuliayuk pipewire[3122]: mod.protocol-pulse: could not find a suitable runtime directory in$PULSE_RUNTIME_PATH and $XDG_RUNTIME_DIR
Mar 08 20:05:52 nuliayuk pipewire[3122]: mod.protocol-pulse: 0x5570c66cf500: can't create pid file: No such file or directory
Mar 08 20:05:52 nuliayuk pipewire[3122]: spa.dbus: Failed to connect to session bus: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
Mar 08 20:05:52 nuliayuk pipewire[3122]: mod.pulse-tunnel: failed to connect: Access denied
Mar 08 20:05:52 nuliayuk pipewire[3122]: mod.zeroconf-discover: Can't load module: Operation not permitted
Actual Results:
pactl info | grep '^Server Name'
Connection failure: Connection refused
pa_context_connect() failed: Connection refused
Expected Results:
I would expect that everything just works.
Additional Info (as attachments):
-
[pw-dump.log](/uploads/f33b3a424ef158e1a23bcbee45b38b93/pw-dump.log)
: note: that despite being disabled, the user socket and service start anyway. My bad for not understanding systemd properly 8(