commit:     f14cc9569d7591317f868b9359232a8ddafb76e5
Author:     Niklāvs Koļesņikovs <89q1r14hd <AT> relay <DOT> firefox <DOT> com>
AuthorDate: Fri Nov 19 08:07:46 2021 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Dec  1 19:49:41 2021 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f14cc956

media-video/wireplumber: apply multiple important looking fixes

Signed-off-by: Niklāvs Koļesņikovs <89q1r14hd <AT> relay.firefox.com>
Closes: https://github.com/gentoo/gentoo/pull/23001
Signed-off-by: Sam James <sam <AT> gentoo.org>

 ...-alsa-handle-the-release-requested-signal.patch | 33 ++++++++
 ...ead-hidden-files-from-the-config-director.patch | 27 ++++++
 ...evice-replace-the-hash-table-key-on-new-i.patch | 47 +++++++++++
 ...de-wait-for-nodes-when-we-become-unlinked.patch | 34 ++++++++
 .../wireplumber/wireplumber-0.4.5-r1.ebuild        | 96 ++++++++++++++++++++++
 5 files changed, 237 insertions(+)

diff --git 
a/media-video/wireplumber/files/wireplumber-0.4.5-alsa-handle-the-release-requested-signal.patch
 
b/media-video/wireplumber/files/wireplumber-0.4.5-alsa-handle-the-release-requested-signal.patch
new file mode 100644
index 000000000000..511dc6df377e
--- /dev/null
+++ 
b/media-video/wireplumber/files/wireplumber-0.4.5-alsa-handle-the-release-requested-signal.patch
@@ -0,0 +1,33 @@
+From efd24584182903bf5ee4660a3b3360cc47ad895b Mon Sep 17 00:00:00 2001
+From: Wim Taymans <[email protected]>
+Date: Tue, 23 Nov 2021 13:17:29 +0100
+Subject: [PATCH] alsa: handle the release-requested signal
+
+Handle the release-requested signal by destroying the device and
+then calling release.
+
+Fixes pipewire/pipewire#1846
+---
+ src/scripts/monitors/alsa.lua | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/src/scripts/monitors/alsa.lua b/src/scripts/monitors/alsa.lua
+index 68c39d8..be4648e 100644
+--- a/src/scripts/monitors/alsa.lua
++++ b/src/scripts/monitors/alsa.lua
+@@ -287,6 +287,12 @@ function prepareDevice(parent, id, type, factory, 
properties)
+       end
+     end)
+ 
++    rd:connect("release-requested", function (rd)
++        Log.info("release requested")
++        parent:store_managed_object(id, nil)
++        rd:call("release")
++    end)
++
+     if jack_device then
+       rd:connect("notify::owner-name-changed", function (rd, pspec)
+         if rd["state"] == "busy" and
+-- 
+2.34.1
+

diff --git 
a/media-video/wireplumber/files/wireplumber-0.4.5-lib-don-t-read-hidden-files-from-the-config-director.patch
 
b/media-video/wireplumber/files/wireplumber-0.4.5-lib-don-t-read-hidden-files-from-the-config-director.patch
new file mode 100644
index 000000000000..1554c65e27da
--- /dev/null
+++ 
b/media-video/wireplumber/files/wireplumber-0.4.5-lib-don-t-read-hidden-files-from-the-config-director.patch
@@ -0,0 +1,27 @@
+From ee5f3f2f195b01fd89ee148da5799b02f99ebb6e Mon Sep 17 00:00:00 2001
+From: Peter Hutterer <[email protected]>
+Date: Sun, 14 Nov 2021 19:44:30 +1000
+Subject: [PATCH 3/3] lib: don't read hidden files from the config directory
+
+Fixes #104
+---
+ lib/wp/wp.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/lib/wp/wp.c b/lib/wp/wp.c
+index ffdff1a..c356133 100644
+--- a/lib/wp/wp.c
++++ b/lib/wp/wp.c
+@@ -315,6 +315,9 @@ wp_new_files_iterator (WpLookupDirs dirs, const gchar 
*subdir,
+     if (dir) {
+       const gchar *filename;
+       while ((filename = g_dir_read_name (dir))) {
++        if (filename[0] == '.')
++          continue;
++
+         if (suffix && !g_str_has_suffix (filename, suffix))
+           continue;
+ 
+-- 
+2.34.0
+

diff --git 
a/media-video/wireplumber/files/wireplumber-0.4.5-m-reserve-device-replace-the-hash-table-key-on-new-i.patch
 
b/media-video/wireplumber/files/wireplumber-0.4.5-m-reserve-device-replace-the-hash-table-key-on-new-i.patch
new file mode 100644
index 000000000000..70d69093d082
--- /dev/null
+++ 
b/media-video/wireplumber/files/wireplumber-0.4.5-m-reserve-device-replace-the-hash-table-key-on-new-i.patch
@@ -0,0 +1,47 @@
+From f4546a18e871537be698916178b40091a4a0b377 Mon Sep 17 00:00:00 2001
+From: Peter Hutterer <[email protected]>
+Date: Fri, 12 Nov 2021 11:19:54 +1000
+Subject: [PATCH 3/3] m-reserve-device: replace the hash table key on new
+ insert
+
+We're using the WpReserveDevice's name as key in the hash table, so we
+must update the key as well when we replace an item in the hashtable -
+the old device (and its name) will be released.
+
+The side-effect of this is that the *third* device with an identical
+name will no longer replace the previous device. This results in the
+following sequence:
+
+- dev1 added: name Audio0
+  - dev1 requests name owner Audio0
+- dev2 added: name Audio0
+  - replace dev1 in the hashtable
+     - dev1 emits "release" signal
+     - dev1 unowns the Audio0 name
+  - dev2 requests name owner Audio0
+- dev3 added: name Audio0
+  - adds to the hashtable because the existing key is now undefined
+  - dev3 requests name owner Audio0
+     - error, you cannot request ownership for the same name twice
+
+Fixes #93
+---
+ modules/module-reserve-device/plugin.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/modules/module-reserve-device/plugin.c 
b/modules/module-reserve-device/plugin.c
+index d8e4e09..68df6ee 100644
+--- a/modules/module-reserve-device/plugin.c
++++ b/modules/module-reserve-device/plugin.c
+@@ -221,7 +221,7 @@ wp_reserve_device_plugin_create_reservation 
(WpReserveDevicePlugin *self,
+       NULL);
+ 
+   /* use rd->name to avoid copying @em name again */
+-  g_hash_table_insert (self->reserve_devices, rd->name, rd);
++  g_hash_table_replace (self->reserve_devices, rd->name, rd);
+ 
+   return g_object_ref (rd);
+ }
+-- 
+2.34.0
+

diff --git 
a/media-video/wireplumber/files/wireplumber-0.4.5-policy-node-wait-for-nodes-when-we-become-unlinked.patch
 
b/media-video/wireplumber/files/wireplumber-0.4.5-policy-node-wait-for-nodes-when-we-become-unlinked.patch
new file mode 100644
index 000000000000..0ce16a647697
--- /dev/null
+++ 
b/media-video/wireplumber/files/wireplumber-0.4.5-policy-node-wait-for-nodes-when-we-become-unlinked.patch
@@ -0,0 +1,34 @@
+From 83041b0ce277c95afaf1824f525ea0bec516f03f Mon Sep 17 00:00:00 2001
+From: Wim Taymans <[email protected]>
+Date: Thu, 18 Nov 2021 15:23:23 +0100
+Subject: [PATCH 2/3] policy-node: wait for nodes when we become unlinked
+
+If we were linked before but our node is removed, wait until a new node
+becomes available instead of failing.
+
+This fixes an issue where there is only 1 sink available and the card
+profile is toggeled between pro and stereo. After the profile is
+toggled, the sink is removed and the node would be killed with an error
+because there is no fallback sink. The fix is similar to the
+pipewire-media-session logic.
+---
+ src/scripts/policy-node.lua | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/src/scripts/policy-node.lua b/src/scripts/policy-node.lua
+index 5029d1b..445b1a7 100644
+--- a/src/scripts/policy-node.lua
++++ b/src/scripts/policy-node.lua
+@@ -493,6 +493,9 @@ function handleLinkable (si)
+     if not reconnect then
+       Log.info (si, "... destroy node")
+       node:request_destroy()
++    elseif si_flags[si.id].was_handled then
++      Log.info (si, "... waiting reconnect")
++      return
+     end
+ 
+     local client_id = node.properties["client.id"]
+-- 
+2.34.0
+

diff --git a/media-video/wireplumber/wireplumber-0.4.5-r1.ebuild 
b/media-video/wireplumber/wireplumber-0.4.5-r1.ebuild
new file mode 100644
index 000000000000..977f3e5b79a7
--- /dev/null
+++ b/media-video/wireplumber/wireplumber-0.4.5-r1.ebuild
@@ -0,0 +1,96 @@
+# Copyright 1999-2021 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+LUA_COMPAT=( lua5-{3,4} )
+
+inherit lua-single meson systemd
+
+if [[ ${PV} == 9999 ]]; then
+       EGIT_REPO_URI="https://gitlab.freedesktop.org/pipewire/${PN}.git";
+       EGIT_BRANCH="master"
+       inherit git-r3
+else
+       
SRC_URI="https://gitlab.freedesktop.org/pipewire/${PN}/-/archive/${PV}/${P}.tar.gz";
+       KEYWORDS="~amd64 ~arm ~arm64 ~ppc64 ~riscv ~x86"
+fi
+
+DESCRIPTION="Replacement for pipewire-media-session"
+HOMEPAGE="https://gitlab.freedesktop.org/pipewire/wireplumber";
+
+LICENSE="MIT"
+SLOT="0/0.4"
+IUSE="elogind systemd test"
+
+REQUIRED_USE="
+       ${LUA_REQUIRED_USE}
+       ?? ( elogind systemd )
+"
+
+RESTRICT="!test? ( test )"
+
+# introspection? ( dev-libs/gobject-introspection ) is valid but likely only 
used for doc building
+BDEPEND="
+       dev-libs/glib
+       dev-util/gdbus-codegen
+       dev-util/glib-utils
+"
+
+DEPEND="
+       ${LUA_DEPS}
+       >=dev-libs/glib-2.62
+       >=media-video/pipewire-0.3.39
+       virtual/libc
+       elogind? ( sys-auth/elogind )
+       systemd? ( sys-apps/systemd )
+"
+
+# Any dev-lua/* deps get declared like this inside RDEPEND:
+#      $(lua_gen_cond_dep '
+#              dev-lua/<NAME>[${LUA_USEDEP}]
+#      ')
+RDEPEND="${DEPEND}"
+
+DOCS=( {NEWS,README}.rst )
+
+PATCHES=(
+       
"${FILESDIR}"/${PN}-0.4.5-m-reserve-device-replace-the-hash-table-key-on-new-i.patch
+       
"${FILESDIR}"/${PN}-0.4.5-policy-node-wait-for-nodes-when-we-become-unlinked.patch
+       
"${FILESDIR}"/${PN}-0.4.5-lib-don-t-read-hidden-files-from-the-config-director.patch
+       "${FILESDIR}"/${PN}-0.4.5-alsa-handle-the-release-requested-signal.patch
+)
+
+src_configure() {
+       local emesonargs=(
+               -Dintrospection=disabled # Only used for Sphinx doc generation
+               -Dsystem-lua=true # We always unbundle everything we can
+               -Dsystem-lua-version=$(ver_cut 1-2 $(lua_get_version))
+               $(meson_feature elogind)
+               $(meson_feature systemd)
+               -Dsystemd-system-service=false # Matches upstream
+               $(meson_use systemd systemd-user-service)
+               -Dsystemd-system-unit-dir=$(systemd_get_systemunitdir)
+               -Dsystemd-user-unit-dir=$(systemd_get_userunitdir)
+               $(meson_use test tests)
+       )
+
+       meson_src_configure
+}
+
+pkg_postinst() {
+       if systemd_is_booted ; then
+               ewarn "pipewire-media-session.service is no longer installed. 
You must switch"
+               ewarn "to wireplumber.service user unit before your next 
logout/reboot:"
+               ewarn "systemctl --user disable pipewire-media-session.service"
+               ewarn "systemctl --user --force enable wireplumber.service"
+       else
+               ewarn "Switch to WirePlumber will happen the next time 
gentoo-pipewire-launcher"
+               ewarn "is started (a replacement for directly calling pipewire 
binary)."
+               ewarn
+               ewarn "Please ensure that ${EROOT}/etc/pipewire/pipewire.conf 
either does not exist"
+               ewarn "or, if it does exist, that any reference to"
+               ewarn "${EROOT}/usr/bin/pipewire-media-session is commented out 
(begins with a #)."
+       fi
+       ewarn
+}

Reply via email to