1 |
commit: 916a0b55068c037e5871ab411da6c3a2e5444349 |
2 |
Author: Sam James <sam <AT> gentoo <DOT> org> |
3 |
AuthorDate: Fri Aug 26 10:51:07 2022 +0000 |
4 |
Commit: Sam James <sam <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Aug 26 10:51:07 2022 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=916a0b55 |
7 |
|
8 |
media-video/wireplumber: backport 100% CPU loop fixes |
9 |
|
10 |
Closes: https://bugs.gentoo.org/866551 |
11 |
Signed-off-by: Sam James <sam <AT> gentoo.org> |
12 |
|
13 |
.../files/wireplumber-0.4.11-loop.patch | 147 +++++++++++++++++++++ |
14 |
.../wireplumber/wireplumber-0.4.11-r3.ebuild | 131 ++++++++++++++++++ |
15 |
2 files changed, 278 insertions(+) |
16 |
|
17 |
diff --git a/media-video/wireplumber/files/wireplumber-0.4.11-loop.patch b/media-video/wireplumber/files/wireplumber-0.4.11-loop.patch |
18 |
new file mode 100644 |
19 |
index 000000000000..75e2bafcaddc |
20 |
--- /dev/null |
21 |
+++ b/media-video/wireplumber/files/wireplumber-0.4.11-loop.patch |
22 |
@@ -0,0 +1,147 @@ |
23 |
+https://bugs.gentoo.org/866551 |
24 |
+https://gitlab.freedesktop.org/pipewire/wireplumber/-/commit/37c839b9308cd3d6580bf01077db8cb29ec2aa2f |
25 |
+https://gitlab.freedesktop.org/pipewire/wireplumber/-/commit/370b692933634675213110048fcda6dff52eb52b |
26 |
+ |
27 |
+From: Pauli Virtanen <pav@×××.fi> |
28 |
+Date: Tue, 19 Jul 2022 20:39:06 +0300 |
29 |
+Subject: [PATCH] policy-node: fix potential rescan loop |
30 |
+ |
31 |
+SiLink activation might be delayed indefinitely under some error |
32 |
+conditions. Currently, policy-node schedules a rescan when it sees a |
33 |
+non-activated link on a stream to be moved, which produces busy loop if |
34 |
+the si-link doesn't activate. |
35 |
+ |
36 |
+Instead of rescheduling on non-active si-links, just remove and emit a |
37 |
+warning. The si-link then gets removed once it gets activated. |
38 |
+ |
39 |
+Reproducer: |
40 |
+ |
41 |
+1. Play audio from Rhythmbox and pause. |
42 |
+2. Switch default output with pactl between two different outputs |
43 |
+3. Links from the paused stream stay at "init" |
44 |
+--- a/src/scripts/policy-node.lua |
45 |
++++ b/src/scripts/policy-node.lua |
46 |
+@@ -694,16 +694,15 @@ function handleLinkable (si) |
47 |
+ local link = lookupLink (si_id, si_flags[si_id].peer_id) |
48 |
+ if reconnect then |
49 |
+ if link ~= nil then |
50 |
+- -- remove old link if active, otherwise schedule rescan |
51 |
+- if ((link:get_active_features() & Feature.SessionItem.ACTIVE) ~= 0) then |
52 |
+- si_flags[si_id].peer_id = nil |
53 |
+- link:remove () |
54 |
+- Log.info (si, "... moving to new target") |
55 |
+- else |
56 |
+- scheduleRescan() |
57 |
+- Log.info (si, "... scheduled rescan") |
58 |
+- return |
59 |
++ -- remove old link |
60 |
++ if ((link:get_active_features() & Feature.SessionItem.ACTIVE) == 0) then |
61 |
++ -- remove also not yet activated links: they might never become active, |
62 |
++ -- and we should not loop waiting for them |
63 |
++ Log.warning (link, "Link was not activated before removing") |
64 |
+ end |
65 |
++ si_flags[si_id].peer_id = nil |
66 |
++ link:remove () |
67 |
++ Log.info (si, "... moving to new target") |
68 |
+ end |
69 |
+ else |
70 |
+ if link ~= nil then |
71 |
+GitLab |
72 |
+ |
73 |
+From: Pauli Virtanen <pav@×××.fi> |
74 |
+Date: Tue, 19 Jul 2022 20:01:10 +0300 |
75 |
+Subject: [PATCH] m-si-link: don't wait for establish before activation + |
76 |
+ cleanup links |
77 |
+ |
78 |
+SiLink should not wait for WpLinks becoming ESTABLISHED, before |
79 |
+activation. That flag shows whether a link has moved away from the |
80 |
+"init" state, however, links to e.g. Pulseaudio corked streams can stay |
81 |
+in "init" state until uncorking. This causes trouble for policies, |
82 |
+which needlessly wait for such links to establish. |
83 |
+ |
84 |
+The WpLink objects may also be kept alive by other referents, and |
85 |
+just unrefing them does not necessarily destroy the PW objects. |
86 |
+ |
87 |
+Activate SiLink even if the WpLink is still in "init" state. It's enough |
88 |
+that the link otherwise successfully establishes. |
89 |
+ |
90 |
+At dispose time, explicitly request destroying the WpLinks that were |
91 |
+created by the SiLink, to ensure they are removed even if there's |
92 |
+something else referring to them. |
93 |
+--- a/modules/module-si-standard-link.c |
94 |
++++ b/modules/module-si-standard-link.c |
95 |
+@@ -132,6 +132,27 @@ si_standard_link_get_associated_proxy (WpSessionItem * item, GType proxy_type) |
96 |
+ return NULL; |
97 |
+ } |
98 |
+ |
99 |
++static void |
100 |
++request_destroy_link (gpointer data, gpointer user_data) |
101 |
++{ |
102 |
++ WpLink *link = WP_LINK (data); |
103 |
++ |
104 |
++ wp_global_proxy_request_destroy (WP_GLOBAL_PROXY (link)); |
105 |
++} |
106 |
++ |
107 |
++static void |
108 |
++clear_node_links (GPtrArray **node_links_p) |
109 |
++{ |
110 |
++ /* |
111 |
++ * Something else (eg. object managers) may be keeping the WpLink |
112 |
++ * objects alive. Deactive the links now, to destroy the PW objects. |
113 |
++ */ |
114 |
++ if (*node_links_p) |
115 |
++ g_ptr_array_foreach (*node_links_p, request_destroy_link, NULL); |
116 |
++ |
117 |
++ g_clear_pointer (node_links_p, g_ptr_array_unref); |
118 |
++} |
119 |
++ |
120 |
+ static void |
121 |
+ si_standard_link_disable_active (WpSessionItem *si) |
122 |
+ { |
123 |
+@@ -154,7 +175,8 @@ si_standard_link_disable_active (WpSessionItem *si) |
124 |
+ WP_SI_LINKABLE (si_in)); |
125 |
+ } |
126 |
+ |
127 |
+- g_clear_pointer (&self->node_links, g_ptr_array_unref); |
128 |
++ clear_node_links (&self->node_links); |
129 |
++ |
130 |
+ self->n_active_links = 0; |
131 |
+ self->n_failed_links = 0; |
132 |
+ self->n_async_ops_wait = 0; |
133 |
+@@ -168,7 +190,7 @@ on_link_activated (WpObject * proxy, GAsyncResult * res, |
134 |
+ WpTransition * transition) |
135 |
+ { |
136 |
+ WpSiStandardLink *self = wp_transition_get_source_object (transition); |
137 |
+- guint len = self->node_links->len; |
138 |
++ guint len = self->node_links ? self->node_links->len : 0; |
139 |
+ |
140 |
+ /* Count the number of failed and active links */ |
141 |
+ if (wp_object_activate_finish (proxy, res, NULL)) |
142 |
+@@ -182,7 +204,7 @@ on_link_activated (WpObject * proxy, GAsyncResult * res, |
143 |
+ |
144 |
+ /* We only active feature if all links activated successfully */ |
145 |
+ if (self->n_failed_links > 0) { |
146 |
+- g_clear_pointer (&self->node_links, g_ptr_array_unref); |
147 |
++ clear_node_links (&self->node_links); |
148 |
+ wp_transition_return_error (transition, g_error_new ( |
149 |
+ WP_DOMAIN_LIBRARY, WP_LIBRARY_ERROR_OPERATION_FAILED, |
150 |
+ "%d of %d PipeWire links failed to activate", |
151 |
+@@ -251,7 +273,7 @@ create_links (WpSiStandardLink * self, WpTransition * transition, |
152 |
+ /* Clear old links if any */ |
153 |
+ self->n_active_links = 0; |
154 |
+ self->n_failed_links = 0; |
155 |
+- g_clear_pointer (&self->node_links, g_ptr_array_unref); |
156 |
++ clear_node_links (&self->node_links); |
157 |
+ |
158 |
+ /* tuple format: |
159 |
+ uint32 node_id; |
160 |
+@@ -327,7 +349,7 @@ create_links (WpSiStandardLink * self, WpTransition * transition, |
161 |
+ |
162 |
+ /* activate to ensure it is created without errors */ |
163 |
+ wp_object_activate_closure (WP_OBJECT (link), |
164 |
+- WP_OBJECT_FEATURES_ALL, NULL, |
165 |
++ WP_OBJECT_FEATURES_ALL & ~WP_LINK_FEATURE_ESTABLISHED, NULL, |
166 |
+ g_cclosure_new_object ( |
167 |
+ (GCallback) on_link_activated, G_OBJECT (transition))); |
168 |
+ } |
169 |
+GitLab |
170 |
|
171 |
diff --git a/media-video/wireplumber/wireplumber-0.4.11-r3.ebuild b/media-video/wireplumber/wireplumber-0.4.11-r3.ebuild |
172 |
new file mode 100644 |
173 |
index 000000000000..99ca2c5c7956 |
174 |
--- /dev/null |
175 |
+++ b/media-video/wireplumber/wireplumber-0.4.11-r3.ebuild |
176 |
@@ -0,0 +1,131 @@ |
177 |
+# Copyright 1999-2022 Gentoo Authors |
178 |
+# Distributed under the terms of the GNU General Public License v2 |
179 |
+ |
180 |
+EAPI=8 |
181 |
+ |
182 |
+# 1. Please regularly check (even at the point of bumping) Fedora's packaging |
183 |
+# for needed backports at https://src.fedoraproject.org/rpms/wireplumber/tree/rawhide |
184 |
+# |
185 |
+# 2. Keep an eye on git master (for both PipeWire and WirePlumber) as things |
186 |
+# continue to move quickly. It's not uncommon for fixes to be made shortly |
187 |
+# after releases. |
188 |
+ |
189 |
+LUA_COMPAT=( lua5-{3,4} ) |
190 |
+ |
191 |
+inherit lua-single meson systemd |
192 |
+ |
193 |
+if [[ ${PV} == 9999 ]]; then |
194 |
+ EGIT_REPO_URI="https://gitlab.freedesktop.org/pipewire/${PN}.git" |
195 |
+ EGIT_BRANCH="master" |
196 |
+ inherit git-r3 |
197 |
+else |
198 |
+ SRC_URI="https://gitlab.freedesktop.org/pipewire/${PN}/-/archive/${PV}/${P}.tar.gz" |
199 |
+ KEYWORDS="~amd64 ~arm ~arm64 ~loong ~ppc ~ppc64 ~riscv ~sparc ~x86" |
200 |
+fi |
201 |
+ |
202 |
+DESCRIPTION="Replacement for pipewire-media-session" |
203 |
+HOMEPAGE="https://gitlab.freedesktop.org/pipewire/wireplumber" |
204 |
+ |
205 |
+LICENSE="MIT" |
206 |
+SLOT="0/0.4" |
207 |
+IUSE="elogind system-service systemd test" |
208 |
+ |
209 |
+REQUIRED_USE=" |
210 |
+ ${LUA_REQUIRED_USE} |
211 |
+ ?? ( elogind systemd ) |
212 |
+ system-service? ( systemd ) |
213 |
+" |
214 |
+ |
215 |
+RESTRICT="!test? ( test )" |
216 |
+ |
217 |
+# introspection? ( dev-libs/gobject-introspection ) is valid but likely only used for doc building |
218 |
+BDEPEND=" |
219 |
+ dev-libs/glib |
220 |
+ dev-util/gdbus-codegen |
221 |
+ dev-util/glib-utils |
222 |
+ sys-devel/gettext |
223 |
+" |
224 |
+ |
225 |
+DEPEND=" |
226 |
+ ${LUA_DEPS} |
227 |
+ >=dev-libs/glib-2.62 |
228 |
+ >=media-video/pipewire-0.3.53-r1:= |
229 |
+ virtual/libintl |
230 |
+ elogind? ( sys-auth/elogind ) |
231 |
+ systemd? ( sys-apps/systemd ) |
232 |
+" |
233 |
+ |
234 |
+# Any dev-lua/* deps get declared like this inside RDEPEND: |
235 |
+# $(lua_gen_cond_dep ' |
236 |
+# dev-lua/<NAME>[${LUA_USEDEP}] |
237 |
+# ') |
238 |
+RDEPEND="${DEPEND} |
239 |
+ system-service? ( |
240 |
+ acct-user/pipewire |
241 |
+ acct-group/pipewire |
242 |
+ ) |
243 |
+" |
244 |
+ |
245 |
+DOCS=( {NEWS,README}.rst ) |
246 |
+ |
247 |
+PATCHES=( |
248 |
+ "${FILESDIR}"/${PN}-0.4.10-config-disable-sound-server-parts.patch # defer enabling sound server parts to media-video/pipewire |
249 |
+ "${FILESDIR}"/${P}-alsa-lua-crash.patch |
250 |
+ "${FILESDIR}"/${P}-dbus-reconnect-crash.patch |
251 |
+ "${FILESDIR}"/${P}-loop.patch |
252 |
+) |
253 |
+ |
254 |
+src_configure() { |
255 |
+ local emesonargs=( |
256 |
+ -Ddoc=disabled # Ebuild not wired up yet (Sphinx, Doxygen?) |
257 |
+ -Dintrospection=disabled # Only used for Sphinx doc generation |
258 |
+ -Dsystem-lua=true # We always unbundle everything we can |
259 |
+ -Dsystem-lua-version=$(ver_cut 1-2 $(lua_get_version)) |
260 |
+ $(meson_feature elogind) |
261 |
+ $(meson_feature systemd) |
262 |
+ $(meson_use system-service systemd-system-service) |
263 |
+ $(meson_use systemd systemd-user-service) |
264 |
+ -Dsystemd-system-unit-dir=$(systemd_get_systemunitdir) |
265 |
+ -Dsystemd-user-unit-dir=$(systemd_get_userunitdir) |
266 |
+ $(meson_use test tests) |
267 |
+ ) |
268 |
+ |
269 |
+ meson_src_configure |
270 |
+} |
271 |
+ |
272 |
+src_install() { |
273 |
+ meson_src_install |
274 |
+ |
275 |
+ # We copy the default config, so that Gentoo tools can pick up on any |
276 |
+ # updates and /etc does not end up with stale overrides. |
277 |
+ # If a reflinking CoW filesystem is used (e.g. Btrfs), then the files |
278 |
+ # will not actually get stored twice until modified. |
279 |
+ insinto /etc |
280 |
+ doins -r "${ED}"/usr/share/wireplumber |
281 |
+} |
282 |
+ |
283 |
+pkg_postinst() { |
284 |
+ if systemd_is_booted ; then |
285 |
+ ewarn "pipewire-media-session.service is no longer installed. You must switch" |
286 |
+ ewarn "to wireplumber.service user unit before your next logout/reboot:" |
287 |
+ ewarn "systemctl --user disable pipewire-media-session.service" |
288 |
+ ewarn "systemctl --user --force enable wireplumber.service" |
289 |
+ else |
290 |
+ ewarn "Switch to WirePlumber will happen the next time gentoo-pipewire-launcher" |
291 |
+ ewarn "is started (a replacement for directly calling pipewire binary)." |
292 |
+ ewarn |
293 |
+ ewarn "Please ensure that ${EROOT}/etc/pipewire/pipewire.conf either does not exist" |
294 |
+ ewarn "or, if it does exist, that any reference to" |
295 |
+ ewarn "${EROOT}/usr/bin/pipewire-media-session is commented out (begins with a #)." |
296 |
+ fi |
297 |
+ if use system-service; then |
298 |
+ ewarn |
299 |
+ ewarn "WARNING: you have enabled the system-service USE flag, which installs" |
300 |
+ ewarn "the system-wide systemd units that enable WirePlumber to run as a system" |
301 |
+ ewarn "service. This is more than likely NOT what you want. You are strongly" |
302 |
+ ewarn "advised not to enable this mode and instead stick with systemd user" |
303 |
+ ewarn "units. The default configuration files will likely not work out of" |
304 |
+ ewarn "box, and you are on your own with configuration." |
305 |
+ ewarn |
306 |
+ fi |
307 |
+} |