From 07a0a5b4043ab5982a82311e031ddfd6feb80da1 Mon Sep 17 00:00:00 2001 From: Julian Bouzas Date: Tue, 11 Jan 2022 07:50:15 -0500 Subject: [PATCH 07/14] default-nodes: check if the ports exist in rescan_om Ports might not be ready in the node's port object manager yet. Fixes #153 and #150 --- modules/module-default-nodes.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/modules/module-default-nodes.c b/modules/module-default-nodes.c index 31eafcf..c45be2d 100644 --- a/modules/module-default-nodes.c +++ b/modules/module-default-nodes.c @@ -307,7 +307,12 @@ nodes_ready (WpDefaultNodes * self) PW_KEY_DEVICE_ID, "=i", device_id, NULL); for (; wp_iterator_next (node_it, &node_val); g_value_unset (&node_val)) { WpPipewireObject *node = g_value_get_object (&node_val); - if (wp_node_get_n_ports (WP_NODE (node)) > 0) + g_autoptr (WpPort) port = + wp_object_manager_lookup (self->rescan_om, + WP_TYPE_PORT, WP_CONSTRAINT_TYPE_PW_PROPERTY, + PW_KEY_NODE_ID, "=u", wp_proxy_get_bound_id (WP_PROXY (node)), + NULL); + if (port) ready_nodes++; } @@ -327,7 +332,12 @@ nodes_ready (WpDefaultNodes * self) WpPipewireObject *node = g_value_get_object (&node_val); const gchar *media_class = wp_pipewire_object_get_property ( WP_PIPEWIRE_OBJECT (node), PW_KEY_MEDIA_CLASS); - if (wp_node_get_n_ports (WP_NODE (node)) == 0 && + g_autoptr (WpPort) port = + wp_object_manager_lookup (self->rescan_om, + WP_TYPE_PORT, WP_CONSTRAINT_TYPE_PW_PROPERTY, + PW_KEY_NODE_ID, "=u", wp_proxy_get_bound_id (WP_PROXY (node)), + NULL); + if (!port && (g_strcmp0 ("Audio/Source/Virtual", media_class) == 0 || g_strcmp0 ("Video/Source/Virtual", media_class) == 0)) return FALSE; -- 2.34.1