module-default-nodes-api: sync with core before emitting changed signal

This makes sure pipewire is not doing anything while emitting changed signal.
This commit is contained in:
Julian Bouzas
2021-12-15 13:57:56 -05:00
committed by George Kiagiadakis
parent 8bbbba23ff
commit f7dfb90db6

View File

@@ -16,7 +16,6 @@ struct _WpDefaultNodesApi
gchar *defaults[N_DEFAULT_NODES];
WpObjectManager *om;
GSource *idle_source;
};
enum {
@@ -36,15 +35,18 @@ wp_default_nodes_api_init (WpDefaultNodesApi * self)
{
}
static gboolean
emit_changed_cb (gpointer data)
static void
sync_changed_notification (WpCore * core, GAsyncResult * res,
WpDefaultNodesApi * self)
{
WpDefaultNodesApi *self = data;
g_autoptr (GError) error = NULL;
if (!wp_core_sync_finish (core, res, &error)) {
wp_warning_object (self, "core sync error: %s", error->message);
return;
}
g_signal_emit (self, signals[SIGNAL_CHANGED], 0);
g_clear_pointer (&self->idle_source, g_source_unref);
return G_SOURCE_REMOVE;
return;
}
static void
@@ -52,7 +54,8 @@ schedule_changed_notification (WpDefaultNodesApi *self)
{
g_autoptr (WpCore) core = wp_object_get_core (WP_OBJECT (self));
g_return_if_fail (core);
wp_core_idle_add (core, &self->idle_source, emit_changed_cb, self, NULL);
wp_core_sync_closure (core, NULL, g_cclosure_new_object (
G_CALLBACK (sync_changed_notification), G_OBJECT (self)));
}
static void
@@ -141,10 +144,6 @@ wp_default_nodes_api_disable (WpPlugin * plugin)
{
WpDefaultNodesApi * self = WP_DEFAULT_NODES_API (plugin);
if (self->idle_source)
g_source_destroy (self->idle_source);
g_clear_pointer (&self->idle_source, g_source_unref);
for (guint i = 0; i < N_DEFAULT_NODES; i++)
g_clear_pointer (&self->defaults[i], g_free);
g_clear_object (&self->om);
@@ -161,6 +160,7 @@ wp_default_nodes_api_get_default_node (WpDefaultNodesApi * self,
break;
}
}
if (node_t != -1 && self->defaults[node_t]) {
g_autoptr (WpNode) node = wp_object_manager_lookup (self->om,
WP_TYPE_NODE,