SHA256
1
0
forked from pool/wireplumber

Accepting request 948465 from home:alarrosa:branches:multimedia:libs

- So far it passed openQA, so let's try adding two more patches:
  * 0009-default-nodes-check-if-default-node-has-available-ro.patch
  * 0010-added-support-for-disabling-nodes-and-devices-throug.patch

OBS-URL: https://build.opensuse.org/request/show/948465
OBS-URL: https://build.opensuse.org/package/show/multimedia:libs/wireplumber?expand=0&rev=25
This commit is contained in:
Antonio Larrosa 2022-01-24 18:42:52 +00:00 committed by Git OBS Bridge
parent 23c5d9eadf
commit 0026b12345
4 changed files with 195 additions and 0 deletions

View File

@ -0,0 +1,124 @@
From 75281d86817a090147a15711266709114b15aefa Mon Sep 17 00:00:00 2001
From: Julian Bouzas <julian.bouzas@collabora.com>
Date: Tue, 11 Jan 2022 13:59:58 -0500
Subject: [PATCH 09/14] default-nodes: check if default node has available
route
Fixes #145
---
modules/module-default-nodes.c | 85 ++++++++++++++++++++++++++++++++++
1 file changed, 85 insertions(+)
diff --git a/modules/module-default-nodes.c b/modules/module-default-nodes.c
index c45be2d..354c474 100644
--- a/modules/module-default-nodes.c
+++ b/modules/module-default-nodes.c
@@ -8,6 +8,7 @@
#include <wp/wp.h>
#include <errno.h>
+#include <pipewire/pipewire.h>
#include <pipewire/keys.h>
#define COMPILING_MODULE_DEFAULT_NODES 1
@@ -97,6 +98,87 @@ timer_start (WpDefaultNodes *self)
}
}
+static gboolean
+node_has_available_routes (WpDefaultNodes * self, WpNode *node)
+{
+ const gchar *dev_id_str = wp_pipewire_object_get_property (
+ WP_PIPEWIRE_OBJECT (node), PW_KEY_DEVICE_ID);
+ const gchar *cpd_str = wp_pipewire_object_get_property (
+ WP_PIPEWIRE_OBJECT (node), "card.profile.device");
+ gint dev_id = dev_id_str ? atoi (dev_id_str) : -1;
+ gint cpd = cpd_str ? atoi (cpd_str) : -1;
+ g_autoptr (WpDevice) device = NULL;
+
+ if (dev_id == -1 || cpd == -1)
+ return TRUE;
+
+ /* Get the device */
+ device = wp_object_manager_lookup (self->rescan_om, WP_TYPE_DEVICE,
+ WP_CONSTRAINT_TYPE_G_PROPERTY, "bound-id", "=i", dev_id, NULL);
+ if (!device)
+ return TRUE;
+
+ /* Check if the current device route supports the node card device profile */
+ {
+ g_autoptr (WpIterator) routes = NULL;
+ g_auto (GValue) val = G_VALUE_INIT;
+ routes = wp_pipewire_object_enum_params_sync (WP_PIPEWIRE_OBJECT (device),
+ "Route", NULL);
+ for (; wp_iterator_next (routes, &val); g_value_unset (&val)) {
+ WpSpaPod *route = g_value_get_boxed (&val);
+ gint route_device = -1;
+ guint32 route_avail = SPA_PARAM_AVAILABILITY_unknown;
+
+ if (!wp_spa_pod_get_object (route, NULL,
+ "device", "i", &route_device,
+ "available", "?I", &route_avail,
+ NULL))
+ continue;
+
+ if (route_device != cpd)
+ continue;
+
+ if (route_avail == SPA_PARAM_AVAILABILITY_no)
+ return FALSE;
+
+ return TRUE;
+ }
+ }
+
+ /* Check if available routes support the node card device profile */
+ {
+ g_autoptr (WpIterator) routes = NULL;
+ g_auto (GValue) val = G_VALUE_INIT;
+ routes = wp_pipewire_object_enum_params_sync (WP_PIPEWIRE_OBJECT (device),
+ "EnumRoute", NULL);
+ for (; wp_iterator_next (routes, &val); g_value_unset (&val)) {
+ WpSpaPod *route = g_value_get_boxed (&val);
+ guint32 route_avail = SPA_PARAM_AVAILABILITY_unknown;
+ g_autoptr (WpSpaPod) route_devices = NULL;
+
+ if (!wp_spa_pod_get_object (route, NULL,
+ "available", "?I", &route_avail,
+ "devices", "?P", &route_devices,
+ NULL))
+ continue;
+
+ {
+ g_autoptr (WpIterator) it = wp_spa_pod_new_iterator (route_devices);
+ g_auto (GValue) v = G_VALUE_INIT;
+ for (; wp_iterator_next (it, &v); g_value_unset (&v)) {
+ gint32 *d = (gint32 *)g_value_get_pointer (&v);
+ if (d && *d == cpd) {
+ if (route_avail != SPA_PARAM_AVAILABILITY_no)
+ return TRUE;
+ }
+ }
+ }
+ }
+ }
+
+ return FALSE;
+}
+
static WpNode *
find_best_media_class_node (WpDefaultNodes * self, const gchar *media_class,
const gchar *node_name, WpDirection direction, gint *priority)
@@ -124,6 +206,9 @@ find_best_media_class_node (WpDefaultNodes * self, const gchar *media_class,
WP_PIPEWIRE_OBJECT (node), PW_KEY_PRIORITY_SESSION);
gint prio = prio_str ? atoi (prio_str) : -1;
+ if (!node_has_available_routes (self, node))
+ continue;
+
if (name && node_name && g_strcmp0 (name, node_name) == 0)
prio += 10000;
--
2.34.1

View File

@ -0,0 +1,62 @@
From bbd23fa3e3a4e13c86bf37b36e7d19d8dcaff771 Mon Sep 17 00:00:00 2001
From: mazunki <rolferen@gmail.com>
Date: Wed, 12 Jan 2022 12:13:08 +0100
Subject: [PATCH 10/14] added support for disabling nodes and devices through
conf
---
src/config/main.lua.d/50-alsa-config.lua | 13 +++++++++++++
src/scripts/monitors/alsa.lua | 6 ++++++
2 files changed, 19 insertions(+)
diff --git a/src/config/main.lua.d/50-alsa-config.lua b/src/config/main.lua.d/50-alsa-config.lua
index 9259cf5..23f8ca1 100644
--- a/src/config/main.lua.d/50-alsa-config.lua
+++ b/src/config/main.lua.d/50-alsa-config.lua
@@ -17,6 +17,19 @@ alsa_monitor.properties = {
alsa_monitor.rules = {
-- An array of matches/actions to evaluate.
+ --
+ -- If you want to disable some devices or nodes, you can apply properties per device as the following example.
+ -- The name can be found by running pw-cli ls Device, or pw-cli dump Device
+ --{
+ -- matches = {
+ -- {
+ -- { "device.name", "matches", "name_of_some_disabled_card" },
+ -- },
+ -- },
+ -- apply_properties = {
+ -- ["device.disabled"] = true,
+ -- },
+ --}
{
-- Rules for matching a device or node. It is an array of
-- properties that all need to match the regexp. If any of the
diff --git a/src/scripts/monitors/alsa.lua b/src/scripts/monitors/alsa.lua
index 8d297c1..c917a5c 100644
--- a/src/scripts/monitors/alsa.lua
+++ b/src/scripts/monitors/alsa.lua
@@ -168,6 +168,9 @@ function createNode(parent, id, type, factory, properties)
-- apply properties from config.rules
rulesApplyProperties(properties)
+ if properties["node.disabled"] then
+ return
+ end
-- create the node
local node = Node("adapter", properties)
@@ -254,6 +257,9 @@ function prepareDevice(parent, id, type, factory, properties)
-- apply properties from config.rules
rulesApplyProperties(properties)
+ if properties["device.disabled"] then
+ return
+ end
-- override the device factory to use ACP
if properties["api.alsa.use-acp"] then
--
2.34.1

View File

@ -1,3 +1,10 @@
-------------------------------------------------------------------
Mon Jan 24 18:32:54 UTC 2022 - Antonio Larrosa <alarrosa@suse.com>
- So far it passed openQA, so let's try adding two more patches:
* 0009-default-nodes-check-if-default-node-has-available-ro.patch
* 0010-added-support-for-disabling-nodes-and-devices-throug.patch
-------------------------------------------------------------------
Mon Jan 24 15:40:22 UTC 2022 - alarrosa@suse.com

View File

@ -38,6 +38,8 @@ Patch5: 0005-config-update-the-endpoints-config.patch
Patch6: 0006-policy-endpoint-client.lua-fix-record-with-endpoints.patch
Patch7: 0007-default-nodes-check-if-the-ports-exist-in-rescan_om.patch
Patch8: 0008-scripts-monitors-log-warning-if-spa-devices-were-not.patch
Patch9: 0009-default-nodes-check-if-default-node-has-available-ro.patch
Patch10: 0010-added-support-for-disabling-nodes-and-devices-throug.patch
#0009-default-nodes-check-if-default-node-has-available-ro.patch
#0010-added-support-for-disabling-nodes-and-devices-throug.patch
#0011-default-nodes-add-more-logs.patch