commit:     e4a4227c737503f7145ad76dea878f96f25688ca
Author:     Niklāvs Koļesņikovs <89q1r14hd <AT> relay <DOT> firefox <DOT> com>
AuthorDate: Mon Oct 18 20:16:19 2021 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Oct 24 01:57:49 2021 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e4a4227c

media-video/pipewire: adds WirePlumber support for OpenRC

As an added bonus the launcher script now starts all the daemons
itself, which means we no longer need to carry and conditionally
apply a patch, which has proven to require recurrent updates.

The instructions for disabling PulseAudio compatibility are pretty
narly and the approach is best reworked (or given up on entirely),
since those instructions have never been the whole story.

Thanks-to: Sam James <sam <AT> gentoo.org> (reviewing & eprefix hint)
Signed-off-by: Niklāvs Koļesņikovs <89q1r14hd <AT> relay.firefox.com>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../pipewire/files/gentoo-pipewire-launcher.in     | 26 +++++++++++
 media-video/pipewire/pipewire-9999.ebuild          | 52 ++++++++++++----------
 2 files changed, 55 insertions(+), 23 deletions(-)

diff --git a/media-video/pipewire/files/gentoo-pipewire-launcher.in 
b/media-video/pipewire/files/gentoo-pipewire-launcher.in
new file mode 100644
index 00000000000..4e66e2fe317
--- /dev/null
+++ b/media-video/pipewire/files/gentoo-pipewire-launcher.in
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+# PipeWire launcher script for XDG compliant desktops on OpenRC.
+#
+# systemd users are very _STRONGLY_ advised to use the much
+# more reliable and predictable user units instead.
+
+# WARNING: This script assumes being run inside XDG compliant session,
+# which means D-Bus session instance is expected to be correctly set up
+# prior to this script starting. If that is not true, things may break!
+
+# Best to reap any existing daemons and only then try to start a new set.
+pkill -u "${USER}" -x pipewire\|wireplumber 1>/dev/null 2>&1
+
+# The core daemon which by itself does probably nothing.
+@GENTOO_PORTAGE_EPREFIX@/usr/bin/pipewire &
+
+# The so called pipewire-pulse daemon used for PulseAudio compatibility.
+# Commenting this out will stop the PA proxying daemon from starting,
+# however ALSA (with pipewire-alsa), JACK (with jack-sdk) and PW API using
+# clients will still have access to audio and may end up clashing with
+# non-PW apps over HW control (most notably, /usr/bin/pulseaudio daemon).
+@GENTOO_PORTAGE_EPREFIX@/usr/bin/pipewire -c pipewire-pulse.conf &
+
+# Finally a session manager is required for PipeWire to do anything.
+exec @GENTOO_PORTAGE_EPREFIX@/usr/bin/wireplumber

diff --git a/media-video/pipewire/pipewire-9999.ebuild 
b/media-video/pipewire/pipewire-9999.ebuild
index eaa51173cfc..360882c6ea6 100644
--- a/media-video/pipewire/pipewire-9999.ebuild
+++ b/media-video/pipewire/pipewire-9999.ebuild
@@ -5,7 +5,7 @@ EAPI="7"
 
 PYTHON_COMPAT=( python3_{8..10} )
 
-inherit meson-multilib optfeature python-any-r1 systemd udev
+inherit meson-multilib optfeature prefix python-any-r1 systemd udev
 
 if [[ ${PV} == 9999 ]]; then
        EGIT_REPO_URI="https://gitlab.freedesktop.org/${PN}/${PN}.git";
@@ -113,12 +113,6 @@ python_check_deps() {
 src_prepare() {
        default
 
-       if ! use systemd; then
-               # This can be applied non-conditionally but would make for a
-               # significantly worse user experience on systemd then.
-               eapply "${FILESDIR}"/${PN}-0.3.36-non-systemd-integration.patch
-       fi
-
        einfo "Generating ${limitsdfile}"
        cat > ${limitsdfile} <<- EOF || die
                # Start of ${limitsdfile} from ${P}
@@ -206,8 +200,9 @@ multilib_src_install_all() {
                insinto /etc/xdg/autostart
                newins "${FILESDIR}"/pipewire.desktop pipewire.desktop
 
-               exeinto /usr/libexec
-               newexe "${FILESDIR}"/pipewire-launcher.sh pipewire-launcher
+               exeinto /usr/bin
+               newexe "${FILESDIR}"/gentoo-pipewire-launcher.in 
gentoo-pipewire-launcher
+               eprefixify "${ED}"/usr/bin/gentoo-pipewire-launcher
        fi
 }
 
@@ -247,20 +242,31 @@ pkg_postinst() {
                elog "  systemctl --user enable --now wireplumber.service"
                elog
        else
-               elog "This ebuild auto-enables PulseAudio replacement. Because 
of that, users"
-               elog "are recommended to edit: ${EROOT}/etc/pulse/client.conf 
and disable"
-               elog "autospawning of the original daemon by setting:"
-               elog
-               elog "  autospawn = no"
-               elog
-               elog "Please note that the semicolon (;) must _NOT_ be at the 
beginning of the line!"
-               elog
-               elog "Alternatively, if replacing PulseAudio daemon is not 
desired, edit"
-               elog "${EROOT}/etc/pipewire/pipewire.conf by commenting out the 
relevant"
-               elog "command near the end of the file:"
-               elog
-               elog "#\"/usr/bin/pipewire\" = { args = \"-c 
pipewire-pulse.conf\" }"
-               elog
+               ewarn "PipeWire daemon startup has been moved to a launcher 
script!"
+               ewarn "Make sure that ${EROOT}/etc/pipewire/pipewire.conf 
either does not exist or no"
+               ewarn "longer is set to start a session manager or PulseAudio 
compatibility daemon (all"
+               ewarn "lines similar to `{ path = \"/usr/bin/pipewire*` should 
be commented out)"
+               ewarn
+               ewarn "Those manually starting /usr/bin/pipewire via .xinitrc 
or similar _must_ from"
+               ewarn "now on start ${EROOT}/usr/bin/gentoo-pipewire-launcher 
instead! It is highly"
+               ewarn "advised that a D-Bus user session is set up before 
starting the script."
+               ewarn
+               if has_version 'media-sound/pulseaudio[daemon]' || has_version 
'media-sound/pulseaudio-daemon'; then
+                       elog "This ebuild auto-enables PulseAudio replacement. 
Because of that, users"
+                       elog "are recommended to edit: 
${EROOT}/etc/pulse/client.conf and disable"
+                       elog "autospawning of the original daemon by setting:"
+                       elog
+                       elog "  autospawn = no"
+                       elog
+                       elog "Please note that the semicolon (;) must _NOT_ be 
at the beginning of the line!"
+                       elog
+                       elog "Alternatively, if replacing PulseAudio daemon is 
not desired, edit"
+                       elog "${EROOT}/usr/bin/gentoo-pipewire-launcher  by 
commenting out the relevant"
+                       elog "command:"
+                       elog
+                       elog "#${EROOT}/usr/bin/pipewire -c pipewire-pulse.conf 
&"
+                       elog
+               fi
                elog "NOTE:"
                elog "Starting with PipeWire-0.3.30, this package is no longer 
installing its config"
                elog "into ${EROOT}/etc/pipewire by default. In case you need 
to change"

Reply via email to