site  contact  subhomenews

Initial setup of pipewire

November 01, 2021 — BarryK

This morning I posted about compiling 'pipewire' in a running EasyOS:

I have configured it so that it basically works. But, there is going to be a lot of work to get it functioning correctly under all situations. Here is a brief introduction to pipewire:

This looks like a useful page on PulseAudio:

Going back a bit, I did try pulseaudio, somewhat half-heartedly, then went back to a pure ALSA system. Here are some blog posts from that experiment:

Ha ha, now back using pulseaudio!

Pipewire does not replace pulseaudio, it uses the pulseaudio libraries. However, pipewire does completely replace 'jack'.

Pipewire has /usr/bin/pipewire-pulse, which is a daemon that replaces the /usr/bin/pulseaudio daemon in the the pulseaudio package. I found that pipewire and pulseaudio must be configured to create a socket in the same path. So, if pipewire-pulse is running instead of pulseaudio daemon, applications such as 'pavucontrol' will recognise it.

In woofQ, packages-templates/pulseaudio/etc/profile.d/pulseaudio:

#need this so pavucontrol can find pulseaudio daemon socket...
export PULSE_RUNTIME_PATH=/run/pulse

#pipewire-pulse daemon will create /run/pulse/pulse
# and pavucontrol won't know where socket is...
mkdir -p /run/pulse
ln -snf . /run/pulse/pulse is a weirdness I discovered, 'pipewire-pulse' also reads $PULSE_RUNTIME_PATH, but appends an extra "pulse" on the end. Hence the hack shown above with the symlink.

There is also packages-templates/pulseaudio/etc/pulse/ and packages-templates/pulseaudio/etc/pulse/client.conf.d/50-sato.conf. The latter:

# 20201006 BK from oe pulseaudio-client-conf pkg.
# We rely on PulseAudio's autospawn feature to automatically start the daemon
# in Sato. The graphical session in Sato runs under root, however, and
# PulseAudio disables autospawning for root by default. In a normal setup it's
# not desirable to autospawn for root, because it can easily interfere with
# other users' PulseAudio instances, but in Sato there are no other users, so
# it's OK to enable this in Sato.
allow-autospawn-for-root = yes



which pulseaudio >/dev/null
[ $? -ne 0 ] && exit

#run start-pulseaudio-x11 in blueman_tray...
[ -x /root/Startup/blueman_tray ] && exit

#wait for bluetoothd...
if [ -x /etc/init.d/bluetooth ];then
for CNT in 1 2 3 4 5 6 7 8 9 10 11 12 13 14
[ $CNT -eq 14 ] && exit
echo "/root/Startup/pulseaudio: wait seconds: ${CNT}"
pidof bluetoothd >/dev/null
[ $? -eq 0 ] && break
sleep 1

echo "/root/Startup/pulseaudio: executing start-pulseaudio-x11"
exec start-pulseaudio-x11

/usr/bin/start-pulseaudio-x11 loads some modules. What I found very disconcerting, is that the 'pulseaudio' daemon starts and stops as required. It starts when 'start-pulseaudio-x11' is running, then terminates about half a minute later. It starts again automatically when an application such as 'pavucontrol' or 'audacious' are running, and terminates about half a minute after they terminate.

I prefer a daemon to be running all of the time. Fortunately, the replacement, 'pipewire-pulse', does.

I have not yet created packages-templates/pipewire in woofQ, as so far just have a 'pipewire' PET, that I have manually setup. Notes about the PET:

It has /etc/pipewire, copied from /usr/share/pipewire
It has /etc/profile.d/pipewire:

mkdir -p /run/pipewire
export PIPEWIRE_RUNTIME_DIR=/run/pipewire

...and see that PULSE_RUNTIME_PATH is set in the pulseaudio package.

The PET also has /etc/pulse/client.conf.d/client.conf:

# ref:

#pulseaudio has this default to yes, but we don't want the pulseaudio
# daemon to start (using pipewire-pulse instead)...
autospawn = no
#pulseaudio pkg had /etc/pulse/client.conf.d/50-sato.conf with this set to yes,
# however, pipewire pkg deleted it. set it to no...
allow-autospawn-for-root = no

The PET post-install script


#remove some things in pulseaudio pkg:
rm -f etc/pulse/client.conf.d/50-sato.conf
rm -f root/Startup/pulseaudio

And /root/Startup/pipewire:

# -f run client n foreground. -r respawn client if it terminates.
# -B ? -P --pidefiles= override standard pidfile location.
# -n --name= guarantee a single named instance.
#however, i will use busybox start-stop-daemon

#daemon -frB --pidfiles=/run --name=pipewire /usr/bin/pipewire
start-stop-daemon --background --exec=/usr/bin/pipewire --start

#daemon -frB --pidfiles=/run --name=pipewire-media-session /usr/bin/pipewire-media-session
start-stop-daemon --background --exec=/usr/bin/pipewire-media-session --start

#daemon -frB --pidfiles=/run --name=pipewire-pulse /usr/bin/pipewire-pulse
start-stop-daemon --background --exec=/usr/bin/pipewire-pulse --start

...thanks to Slackware guys for figuring that out. The pipewire developers work for Red Hat, and all documentations assumes the distribution has systemd. The above script is the startup without systemd.

I think that covers it. I get sound, and pulseaudio is working with the 'pipewire-pulse' server.

There is one more change to the pipewire PET that I didn't mention above: symlinks to the jack libraries.

The jack package was compiled in OE, and some apps such as mhwaveedit (audio editor) and audacious (audio player) were linked to ''.

However, in pipewire, the jack libraries are in /usr/lib/pipewire-0.3/jack. So, I created symlinks to them from /usr/lib. Ditto for the pipewire_DEV PET.    

Tags: easy