#define GLIB_COMPAT_H
#include <glib.h>
+#include <glib-object.h>
#if !GLIB_CHECK_VERSION(2,27,2)
static inline void
}
#endif
+#if !GLIB_CHECK_VERSION(2,28,0)
+static inline void
+g_clear_object_inline(volatile GObject **object_ptr)
+{
+ gpointer * const ptr = (gpointer)object_ptr;
+ gpointer old;
+
+ do {
+ old = g_atomic_pointer_get(ptr);
+ } while G_UNLIKELY(!g_atomic_pointer_compare_and_exchange(ptr, old, NULL));
+
+ if (old)
+ g_object_unref(old);
+}
+#undef g_clear_object
+#define g_clear_object(obj) g_clear_object_inline((volatile GObject **)(obj))
+#endif
+
#if GLIB_CHECK_VERSION(2,31,2)
#define GStaticMutex GMutex
#undef g_static_mutex_init
priv->surfaces = NULL;
}
- if (priv->surfaces_pool) {
- g_object_unref(priv->surfaces_pool);
- priv->surfaces_pool = NULL;
- }
+ g_clear_object(&priv->surfaces_pool);
}
static void
klass->close_display(display);
}
- if (priv->parent) {
- g_object_unref(priv->parent);
- priv->parent = NULL;
- }
+ g_clear_object(&priv->parent);
if (g_display_cache) {
gst_vaapi_display_cache_remove(get_display_cache(), display);
info.va_display
);
if (cached_info) {
- if (priv->parent)
- g_object_unref(priv->parent);
+ g_clear_object(&priv->parent);
priv->parent = g_object_ref(cached_info->display);
}
priv->id = GST_VAAPI_ID_NONE;
- if (priv->display) {
- g_object_unref(priv->display);
- priv->display = NULL;
- }
+ g_clear_object(&priv->display);
G_OBJECT_CLASS(gst_vaapi_object_parent_class)->finalize(object);
}
GST_VAAPI_OBJECT_ID(subpicture) = VA_INVALID_ID;
}
- if (priv->image) {
- g_object_unref(priv->image);
- priv->image = NULL;
- }
+ g_clear_object(&priv->image);
}
static gboolean
priv = surface->priv;
- if (priv->parent_context) {
- g_object_unref(priv->parent_context);
- priv->parent_context = NULL;
- }
+ g_clear_object(&priv->parent_context);
if (context)
priv->parent_context = g_object_ref(context);
priv = proxy->priv;
- if (priv->context) {
- g_object_unref(priv->context);
- priv->context = NULL;
- }
+ g_clear_object(&priv->context);
if (context)
priv->context = g_object_ref(context);
{
GstVaapiVideoBufferPrivate * const priv = buffer->priv;
- if (priv->display) {
- g_object_unref(priv->display);
- priv->display = NULL;
- }
+ g_clear_object(&priv->display);
if (display)
priv->display = g_object_ref(display);
priv->image = NULL;
}
- if (priv->image_pool) {
- g_object_unref(priv->image_pool);
- priv->image_pool = NULL;
- }
+ g_clear_object(&priv->image_pool);
}
static void
{
GstVaapiVideoBufferPrivate * const priv = buffer->priv;
- if (priv->proxy) {
- g_object_unref(priv->proxy);
- priv->proxy = NULL;
- }
+ g_clear_object(&priv->proxy);
if (priv->surface) {
if (priv->surface_pool)
priv->surface = NULL;
}
- if (priv->surface_pool) {
- g_object_unref(priv->surface_pool);
- priv->surface_pool = NULL;
- }
+ g_clear_object(&priv->surface_pool);
if (priv->buffer) {
gst_buffer_unref(priv->buffer);
GstVaapiVideoConverterGLXPrivate *priv =
GST_VAAPI_VIDEO_CONVERTER_GLX (object)->priv;
- if (priv->texture)
- g_object_unref (priv->texture);
-
- priv->texture = NULL;
+ g_clear_object(&priv->texture);
G_OBJECT_CLASS (gst_vaapi_video_converter_glx_parent_class)->dispose (object);
}
priv->caps = NULL;
}
- if (priv->display) {
- g_object_unref(priv->display);
- priv->display = NULL;
- }
+ g_clear_object(&priv->display);
}
static void