Commit 0eba9a93 authored by P V's avatar P V
Browse files

m-default-nodes: wait properly for nodes and ports

Device nodes and their ports may appear some time after devices.
Deviceless nodes may also appear.

If m-default-nodes skipped re-evaluations because some node ports were
not ready, it must retry when ports appear, because everything might be
ready then.

Rescan also when potential sink/source candidate nodes are changed.

Fixes default nodes sometimes pointing to non-existent nodes.
parent b95da339
Pipeline #524548 passed with stages
in 2 minutes and 10 seconds
......@@ -46,6 +46,8 @@ struct _WpDefaultNodes
WpObjectManager *rescan_om;
GSource *timeout_source;
gboolean wait_node_ports;
/* properties */
guint save_interval_ms;
gboolean use_persistent_storage;
......@@ -492,8 +494,12 @@ sync_rescan (WpCore * core, GAsyncResult * res, WpDefaultNodes * self)
/* Make sure nodes are ready for current profile */
if (!nodes_ready (self))
if (!nodes_ready (self)) {
self->wait_node_ports = TRUE;
} else {
self->wait_node_ports = FALSE;
wp_trace_object (self, "re-evaluating defaults");
reevaluate_default_node (self, metadata, AUDIO_SINK);
......@@ -507,6 +513,8 @@ schedule_rescan (WpDefaultNodes * self)
g_autoptr (WpCore) core = wp_object_get_core (WP_OBJECT (self));
g_return_if_fail (core);
self->wait_node_ports = FALSE;
wp_debug_object (self, "scheduling default nodes rescan");
wp_core_sync_closure (core, NULL, g_cclosure_new_object (
G_CALLBACK (sync_rescan), G_OBJECT (self)));
......@@ -557,6 +565,23 @@ on_object_added (WpObjectManager *om, WpPipewireObject *proxy, gpointer d)
if (WP_IS_DEVICE (proxy)) {
g_signal_connect_object (proxy, "params-changed",
G_CALLBACK (schedule_rescan), self, G_CONNECT_SWAPPED);
} else if (WP_IS_NODE (proxy)) {
const gchar *media_class = wp_pipewire_object_get_property (
if (media_class) {
const gchar *parts[] = {"/Sink", "/Source", "/Duplex", NULL};
const gchar **p;
for (p = parts; *p; ++p) {
if (strstr(media_class, *p) != NULL) {
g_signal_connect_object (proxy, "params-changed",
G_CALLBACK (schedule_rescan), self, G_CONNECT_SWAPPED);
} else if (WP_IS_PORT (proxy) && self->wait_node_ports) {
wp_trace_object (self, "ports appeared: wait finished, rescan");
schedule_rescan (self);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment