Accepting request 1216777 from multimedia:libs

OBS-URL: https://build.opensuse.org/request/show/1216777
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/wireplumber?expand=0&rev=43
This commit is contained in:
Ana Guerrero 2024-10-22 12:50:39 +00:00 committed by Git OBS Bridge
commit 1da9900317
6 changed files with 279 additions and 0 deletions

View File

@ -0,0 +1,67 @@
From b68a6794cd5c3702a2144be60c41a9ca982c416b Mon Sep 17 00:00:00 2001
From: Pauli Virtanen <pav@iki.fi>
Date: Sun, 8 Sep 2024 20:22:41 +0300
Subject: [PATCH] autoswitch-bluetooth-profile: switch only Bluetooth devices
Handle only devices associated with Bluetooth loopback nodes.
Make sure the node.link-group iteration cannot get stuck if there is a
loop in the link graph.
---
.../device/autoswitch-bluetooth-profile.lua | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/src/scripts/device/autoswitch-bluetooth-profile.lua b/src/scripts/device/autoswitch-bluetooth-profile.lua
index d4f3529f..70e27601 100644
--- a/src/scripts/device/autoswitch-bluetooth-profile.lua
+++ b/src/scripts/device/autoswitch-bluetooth-profile.lua
@@ -301,13 +301,14 @@ end
-- We consider a Stream of interest if it is linked to a bluetooth loopback
-- source filter
-local function checkStreamStatus (stream, node_om)
+local function checkStreamStatus (stream, node_om, visited_link_groups)
-- check if the stream is linked to a bluetooth loopback source
local stream_id = tonumber(stream["bound-id"])
local peer_id = lutils.getNodePeerId (stream_id)
if peer_id ~= nil then
local bt_node = node_om:lookup {
- Constraint { "bound-id", "=", peer_id, type = "gobject" }
+ Constraint { "bound-id", "=", peer_id, type = "gobject" },
+ Constraint { "bluez5.loopback", "=", "true", type = "pw" }
}
if bt_node ~= nil then
local dev_id = bt_node.properties["device.id"]
@@ -325,18 +326,27 @@ local function checkStreamStatus (stream, node_om)
else
-- Check if it is linked to a filter main node, and recursively advance if so
local filter_main_node = node_om:lookup {
- Constraint { "bound-id", "=", peer_id, type = "gobject" }
+ Constraint { "bound-id", "=", peer_id, type = "gobject" },
+ Constraint { "node.link-group", "+", type = "pw" }
}
if filter_main_node ~= nil then
-- Now check all stream nodes for this filter
local filter_link_group = filter_main_node.properties ["node.link-group"]
+ if visited_link_groups == nil then
+ visited_link_groups = {}
+ end
+ if visited_link_groups [filter_link_group] then
+ return nil
+ else
+ visited_link_groups [filter_link_group] = true
+ end
for filter_stream_node in node_om:iterate {
Constraint { "media.class", "matches", "Stream/Input/Audio", type = "pw-global" },
Constraint { "stream.monitor", "!", "true", type = "pw" },
Constraint { "bluez5.loopback", "!", "true", type = "pw" },
Constraint { "node.link-group", "=", filter_link_group, type = "pw" }
} do
- local dev_id = checkStreamStatus (filter_stream_node, node_om)
+ local dev_id = checkStreamStatus (filter_stream_node, node_om, visited_link_groups)
if dev_id ~= nil then
return dev_id
end
--
GitLab

View File

@ -0,0 +1,94 @@
From 76985fff5b4f771714ea1814d85a69298dd83897 Mon Sep 17 00:00:00 2001
From: Julian Bouzas <julian.bouzas@collabora.com>
Date: Fri, 12 Jul 2024 10:49:16 -0400
Subject: [PATCH] autoswitch-bluetooth-profile: Switch to HSP/HFP on timeout
This patch adds a 500ms timeout callback to switch to HSP/HFP when a stream
starts capturing BT audio. This avoids quickly switching from A2DP to HSP/HFP
back and forth if an application just wants to probe the BT source for a short
period of time.
See #634
---
.../device/autoswitch-bluetooth-profile.lua | 34 ++++++++++++++-----
1 file changed, 26 insertions(+), 8 deletions(-)
diff --git a/src/scripts/device/autoswitch-bluetooth-profile.lua b/src/scripts/device/autoswitch-bluetooth-profile.lua
index 70e27601..bd9def55 100644
--- a/src/scripts/device/autoswitch-bluetooth-profile.lua
+++ b/src/scripts/device/autoswitch-bluetooth-profile.lua
@@ -32,9 +32,11 @@ state = nil
headset_profiles = nil
local profile_restore_timeout_msec = 2000
+local profile_switch_timeout_msec = 500
local INVALID = -1
local restore_timeout_source = {}
+local switch_timeout_source = {}
local last_profiles = {}
@@ -174,12 +176,6 @@ local function switchDeviceToHeadsetProfile (dev_id, device_om)
return
end
- -- clear restore callback, if any
- if restore_timeout_source[dev_id] ~= nil then
- restore_timeout_source[dev_id]:destroy ()
- restore_timeout_source[dev_id] = nil
- end
-
local cur_profile_name = getCurrentProfile (device)
local priority, index, name = findProfile (device, nil, cur_profile_name)
if hasProfileInputRoute (device, index) then
@@ -278,6 +274,24 @@ local function restoreProfile (dev_id, device_om)
end
end
+local function triggerSwitchDeviceToHeadsetProfile (dev_id, device_om)
+ -- Always clear any pending restore/switch callbacks when triggering a new switch
+ if restore_timeout_source[dev_id] ~= nil then
+ restore_timeout_source[dev_id]:destroy ()
+ restore_timeout_source[dev_id] = nil
+ end
+ if switch_timeout_source[dev_id] ~= nil then
+ switch_timeout_source[dev_id]:destroy ()
+ switch_timeout_source[dev_id] = nil
+ end
+
+ -- create new switch callback
+ switch_timeout_source[dev_id] = Core.timeout_add (profile_switch_timeout_msec, function ()
+ switch_timeout_source[dev_id] = nil
+ switchDeviceToHeadsetProfile (dev_id, device_om)
+ end)
+end
+
local function triggerRestoreProfile (dev_id, device_om)
-- we never restore the device profiles if there are active streams
for _, v in pairs (active_streams) do
@@ -286,7 +300,11 @@ local function triggerRestoreProfile (dev_id, device_om)
end
end
- -- clear restore callback, if any
+ -- Always clear any pending restore/switch callbacks when triggering a new restore
+ if switch_timeout_source[dev_id] ~= nil then
+ switch_timeout_source[dev_id]:destroy ()
+ switch_timeout_source[dev_id] = nil
+ end
if restore_timeout_source[dev_id] ~= nil then
restore_timeout_source[dev_id]:destroy ()
restore_timeout_source[dev_id] = nil
@@ -367,7 +385,7 @@ local function handleStream (stream, node_om, device_om)
if dev_id ~= nil then
active_streams [stream.id] = dev_id
previous_streams [stream.id] = dev_id
- switchDeviceToHeadsetProfile (dev_id, device_om)
+ triggerSwitchDeviceToHeadsetProfile (dev_id, device_om)
else
dev_id = active_streams [stream.id]
active_streams [stream.id] = nil
--
GitLab

View File

@ -0,0 +1,36 @@
From 255b65d18204f7cf5c0706308196ffbcf8f1a697 Mon Sep 17 00:00:00 2001
From: Torkel Niklasson <torkel@axis.com>
Date: Thu, 26 Sep 2024 12:01:18 +0200
Subject: [PATCH] m-mixer-api: Fix memory in leak wp_mixer_api_set_volume
Declare result from wp_object_manager_lookup as g_autoptr, to prevent
leaking memory.
---
modules/module-mixer-api.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/modules/module-mixer-api.c b/modules/module-mixer-api.c
index e9dccbab0..502640c68 100644
--- a/modules/module-mixer-api.c
+++ b/modules/module-mixer-api.c
@@ -501,7 +501,7 @@ wp_mixer_api_set_volume (WpMixerApi * self, guint32 id, GVariant * vvolume)
props = wp_spa_pod_builder_end (b);
if (info->device_id != SPA_ID_INVALID) {
- WpPipewireObject *device = wp_object_manager_lookup (self->om,
+ g_autoptr (WpPipewireObject) device = wp_object_manager_lookup (self->om,
WP_TYPE_DEVICE, WP_CONSTRAINT_TYPE_G_PROPERTY,
"bound-id", "=u", info->device_id, NULL);
g_return_val_if_fail (device != NULL, FALSE);
@@ -514,7 +514,7 @@ wp_mixer_api_set_volume (WpMixerApi * self, guint32 id, GVariant * vvolume)
"save", "b", true,
NULL));
} else {
- WpPipewireObject *node = wp_object_manager_lookup (self->om,
+ g_autoptr (WpPipewireObject) node = wp_object_manager_lookup (self->om,
WP_TYPE_NODE, WP_CONSTRAINT_TYPE_G_PROPERTY,
"bound-id", "=u", id, NULL);
g_return_val_if_fail (node != NULL, FALSE);
--
GitLab

View File

@ -0,0 +1,64 @@
From ed80938b8c6a08aeb22ec4cefdee6f98c2f8e646 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= <pobrn@protonmail.com>
Date: Thu, 26 Sep 2024 14:49:12 +0200
Subject: [PATCH] module-dbus-connection: fix GCancellable leak
`wp_dbus_connection_disable()` creates a new GCancellable
object at the end, which is never freed if the GObject
is then destroyed. To fix this, override `finalize()` and
clear everything there as well.
Direct leak of 64 byte(s) in 1 object(s) allocated from:
0 0x70e688efd1aa in calloc /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_malloc_linux.cpp:77
1 0x70e6874b3e62 in g_malloc0 (/usr/lib/libglib-2.0.so.0+0x63e62) (BuildId: 7b781c8d1a6e2161838c5d8f3bd797797c132753)
2 0x70e6875dea75 in g_type_create_instance (/usr/lib/libgobject-2.0.so.0+0x3ea75) (BuildId: 5af5e0f7d0a900ecb6083fbd71e22e5522d872e2)
3 0x70e6875c3804 (/usr/lib/libgobject-2.0.so.0+0x23804) (BuildId: 5af5e0f7d0a900ecb6083fbd71e22e5522d872e2)
4 0x70e6875c4e7e in g_object_new_with_properties (/usr/lib/libgobject-2.0.so.0+0x24e7e) (BuildId: 5af5e0f7d0a900ecb6083fbd71e22e5522d872e2)
5 0x70e6875c5ed1 in g_object_new (/usr/lib/libgobject-2.0.so.0+0x25ed1) (BuildId: 5af5e0f7d0a900ecb6083fbd71e22e5522d872e2)
6 0x70e684d2a8a6 in wp_dbus_connection_disable ../subprojects/wireplumber/modules/module-dbus-connection.c:173
7 0x70e688a833cc in wp_plugin_deactivate ../subprojects/wireplumber/lib/wp/plugin.c:144
8 0x70e688a7126c in wp_object_deactivate ../subprojects/wireplumber/lib/wp/object.c:542
9 0x70e688a6e74e in wp_object_dispose ../subprojects/wireplumber/lib/wp/object.c:191
10 0x70e6875c0f6c in g_object_unref (/usr/lib/libgobject-2.0.so.0+0x20f6c) (BuildId: 5af5e0f7d0a900ecb6083fbd71e22e5522d872e2)
11 0x70e6841f7d6d in wp_portal_permissionstore_plugin_disable ../subprojects/wireplumber/modules/module-portal-permissionstore.c:207
12 0x70e688a833cc in wp_plugin_deactivate ../subprojects/wireplumber/lib/wp/plugin.c:144
[...]
---
modules/module-dbus-connection.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/modules/module-dbus-connection.c b/modules/module-dbus-connection.c
index 21ba95a20..b337be5e1 100644
--- a/modules/module-dbus-connection.c
+++ b/modules/module-dbus-connection.c
@@ -211,6 +211,19 @@ wp_dbus_connection_set_property (GObject * object, guint property_id,
}
}
+static void
+wp_dbus_connection_finalize (GObject * object)
+{
+ WpDBusConnection *self = WP_DBUS_CONNECTION (object);
+
+ g_cancellable_cancel (self->cancellable);
+
+ g_clear_object (&self->connection);
+ g_clear_object (&self->cancellable);
+
+ G_OBJECT_CLASS (wp_dbus_connection_parent_class)->finalize (object);
+}
+
static void
wp_dbus_connection_class_init (WpDBusConnectionClass * klass)
{
@@ -219,6 +232,7 @@ wp_dbus_connection_class_init (WpDBusConnectionClass * klass)
object_class->get_property = wp_dbus_connection_get_property;
object_class->set_property = wp_dbus_connection_set_property;
+ object_class->finalize = wp_dbus_connection_finalize;
plugin_class->enable = wp_dbus_connection_enable;
plugin_class->disable = wp_dbus_connection_disable;
--
GitLab

View File

@ -1,3 +1,17 @@
-------------------------------------------------------------------
Mon Oct 21 15:52:33 UTC 2024 - Antonio Larrosa <alarrosa@suse.com>
- Add patch from upstream to fix switching automatically the
profile of non-bluetooth devices (boo#1231815):
* 0001-autoswitch-bluetooth-profile-switch-only-Bluetooth-devices.patch
- Add patch from upstream to fix switching automatically the
profile when starting some apps and then switching to the
previous profile:
* 0002-autoswitch-bluetooth-profile-Switch-to-HSP_HFP-on-timeout.patch
- Add patches from upstream to fix a couple of memory leaks:
* 0003-m-mixer-api-Fix-memory-in-leak-wp_mixer_api_set_volume.patch
* 0004-module-dbus-connection-fix-GCancellable-leak.patch
-------------------------------------------------------------------
Mon Sep 9 12:12:28 UTC 2024 - Frederic Crozat <fcrozat@suse.com>

View File

@ -30,6 +30,10 @@ Group: Development/Libraries/C and C++
URL: https://gitlab.freedesktop.org/pipewire/wireplumber
Source0: wireplumber-%{version}.tar.xz
Source1: split-config-file.py
Patch0: 0001-autoswitch-bluetooth-profile-switch-only-Bluetooth-devices.patch
Patch1: 0002-autoswitch-bluetooth-profile-Switch-to-HSP_HFP-on-timeout.patch
Patch2: 0003-m-mixer-api-Fix-memory-in-leak-wp_mixer_api_set_volume.patch
Patch3: 0004-module-dbus-connection-fix-GCancellable-leak.patch
# docs
BuildRequires: doxygen
BuildRequires: graphviz