object-manager: sync object-changed with pipewire's core
This commit is contained in:
@@ -31,7 +31,7 @@ struct _WpObjectManager
|
|||||||
/* objects that we are interested in, with a strong ref */
|
/* objects that we are interested in, with a strong ref */
|
||||||
GPtrArray *objects;
|
GPtrArray *objects;
|
||||||
|
|
||||||
GSource *idle_objchanged_source;
|
gboolean pending_objchanged;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@@ -56,6 +56,7 @@ wp_object_manager_init (WpObjectManager * self)
|
|||||||
g_weak_ref_init (&self->core, NULL);
|
g_weak_ref_init (&self->core, NULL);
|
||||||
pw_array_init (&self->interests, sizeof (struct interest));
|
pw_array_init (&self->interests, sizeof (struct interest));
|
||||||
self->objects = g_ptr_array_new_with_free_func (g_object_unref);
|
self->objects = g_ptr_array_new_with_free_func (g_object_unref);
|
||||||
|
self->pending_objchanged = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -64,10 +65,6 @@ wp_object_manager_finalize (GObject * object)
|
|||||||
WpObjectManager *self = WP_OBJECT_MANAGER (object);
|
WpObjectManager *self = WP_OBJECT_MANAGER (object);
|
||||||
struct interest *i;
|
struct interest *i;
|
||||||
|
|
||||||
if (self->idle_objchanged_source)
|
|
||||||
g_source_destroy (self->idle_objchanged_source);
|
|
||||||
g_clear_pointer (&self->idle_objchanged_source, g_source_unref);
|
|
||||||
|
|
||||||
g_clear_pointer (&self->objects, g_ptr_array_unref);
|
g_clear_pointer (&self->objects, g_ptr_array_unref);
|
||||||
|
|
||||||
pw_array_for_each (i, &self->interests)
|
pw_array_for_each (i, &self->interests)
|
||||||
@@ -362,25 +359,26 @@ wp_object_manager_is_interested_in_global (WpObjectManager * self,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static void
|
||||||
idle_emit_objects_changed (gpointer data)
|
sync_emit_objects_changed (WpCore *core, GAsyncResult *res, gpointer data)
|
||||||
{
|
{
|
||||||
WpObjectManager *self = WP_OBJECT_MANAGER (data);
|
WpObjectManager *self = data;
|
||||||
|
|
||||||
g_signal_emit (self, signals[SIGNAL_OBJECTS_CHANGED], 0);
|
g_signal_emit (self, signals[SIGNAL_OBJECTS_CHANGED], 0);
|
||||||
g_clear_pointer (&self->idle_objchanged_source, g_source_unref);
|
self->pending_objchanged = FALSE;
|
||||||
|
|
||||||
return G_SOURCE_REMOVE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
schedule_emit_objects_changed (WpObjectManager * self)
|
schedule_emit_objects_changed (WpObjectManager * self)
|
||||||
{
|
{
|
||||||
if (!self->idle_objchanged_source) {
|
if (self->pending_objchanged)
|
||||||
g_autoptr (WpCore) core = g_weak_ref_get (&self->core);
|
return;
|
||||||
if (core)
|
|
||||||
self->idle_objchanged_source =
|
g_autoptr (WpCore) core = g_weak_ref_get (&self->core);
|
||||||
wp_core_idle_add (core, idle_emit_objects_changed, self);
|
if (core) {
|
||||||
|
wp_core_sync (core, NULL, (GAsyncReadyCallback)sync_emit_objects_changed,
|
||||||
|
self);
|
||||||
|
self->pending_objchanged = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user