wayland: add synchronized object destruction function

Introduces a new generic destruction function
gst_wl_display_object_destroy that ensures all
destruction operations are protected by
sync_mutex.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8242>
This commit is contained in:
Qian Hu (胡骞) 2025-02-24 09:43:12 +08:00 committed by GStreamer Marge Bot
parent 722c088ab3
commit 308540c2fe
2 changed files with 25 additions and 0 deletions

View file

@ -558,6 +558,28 @@ gst_wl_display_sync (GstWlDisplay * self,
return callback;
}
/* gst_wl_display_object_destroy
*
* A syncronized version of `xxx_destroy` that ensures that the
* once this function returns, the destroy_func will either have already completed,
* or will never be called.
*/
void
gst_wl_display_object_destroy (GstWlDisplay * self,
gpointer * object, GDestroyNotify destroy_func)
{
GstWlDisplayPrivate *priv = gst_wl_display_get_instance_private (self);
g_rec_mutex_lock (&priv->sync_mutex);
if (*object) {
destroy_func (*object);
*object = NULL;
}
g_rec_mutex_unlock (&priv->sync_mutex);
}
/* gst_wl_display_callback_destroy
*
* A syncronized version of `wl_callback_destroy` that ensures that the

View file

@ -56,6 +56,9 @@ GST_WL_API
struct wl_callback * gst_wl_display_sync(GstWlDisplay * self, const struct wl_callback_listener *listener,
gpointer data);
GST_WL_API
void gst_wl_display_object_destroy (GstWlDisplay * self, gpointer *object, GDestroyNotify destroy_func);
GST_WL_API
void gst_wl_display_callback_destroy(GstWlDisplay * self, struct wl_callback ** callback);