wpctl: Make sure default node Id is updated when printing filters

This will properly show '*' for default sink filters in the status output.
This commit is contained in:
Julian Bouzas 2024-06-27 10:01:22 -04:00 committed by George Kiagiadakis
parent 11f10b4f45
commit c60475b293

View file

@ -299,6 +299,7 @@ static void
print_filter_node (const GValue *item, gpointer data)
{
struct print_context *context = data;
g_autoptr (WpPlugin) def_nodes_api = NULL;
WpPipewireObject *obj = g_value_get_object (item);
g_autoptr (WpIterator) it = NULL;
g_auto (GValue) val = G_VALUE_INIT;
@ -309,6 +310,8 @@ print_filter_node (const GValue *item, gpointer data)
if (g_hash_table_contains (context->printed_filters, link_group))
return;
def_nodes_api = wp_plugin_find (context->self->core, "default-nodes-api");
/* Print all nodes for this link_group */
printf (TREE_INDENT_LINE " - %-60s\n", link_group);
it = wp_object_manager_new_filtered_iterator (context->self->om,
@ -329,6 +332,11 @@ print_filter_node (const GValue *item, gpointer data)
name = wp_pipewire_object_get_property (node, PW_KEY_NODE_DESCRIPTION);
media_class = wp_pipewire_object_get_property (node, PW_KEY_MEDIA_CLASS);
context->default_node = -1;
if (def_nodes_api)
g_signal_emit_by_name (def_nodes_api, "get-default-node", media_class,
&context->default_node);
printf (TREE_INDENT_LINE "%c %4u. %-60s [%s]\n",
context->default_node == id ? '*' : ' ', id, name, media_class);
}