eglimage: Ensure that the debug category is always initalized
authorSebastian Dröge <sebastian@centricular.com>
Mon, 23 May 2016 17:11:17 +0000 (20:11 +0300)
committerSebastian Dröge <sebastian@centricular.com>
Wed, 25 May 2016 06:46:37 +0000 (09:46 +0300)
Before the initializer was only run if dmabuf support was used.

https://bugzilla.gnome.org/show_bug.cgi?id=766794

gst-libs/gst/gl/egl/gsteglimage.c

index 7e6dfd6..9904164 100644 (file)
 #define EGL_DMA_BUF_PLANE0_PITCH_EXT 0x3274
 #endif
 
-GST_DEBUG_CATEGORY_STATIC (GST_CAT_EGL_IMAGE);
-#define GST_CAT_DEFAULT GST_CAT_EGL_IMAGE
+#ifndef GST_DISABLE_GST_DEBUG
+#define GST_CAT_DEFAULT gst_egl_image_ensure_debug_category()
 
-GST_DEFINE_MINI_OBJECT_TYPE (GstEGLImage, gst_egl_image);
-
-static void
-_init_debug (void)
+static GstDebugCategory *
+gst_egl_image_ensure_debug_category (void)
 {
-  static volatile gsize _init = 0;
+  static gsize cat_gonce = 0;
+
+  if (g_once_init_enter (&cat_gonce)) {
+    GstDebugCategory *cat = NULL;
 
-  if (g_once_init_enter (&_init)) {
-    GST_DEBUG_CATEGORY_INIT (GST_CAT_EGL_IMAGE, "gleglimage", 0,
-        "EGLImage wrapper");
+    GST_DEBUG_CATEGORY_INIT (cat, "gleglimage", 0, "EGLImage wrapper");
 
-    g_once_init_leave (&_init, 1);
+    g_once_init_leave (&cat_gonce, (gsize) cat);
   }
+
+  return (GstDebugCategory *) cat_gonce;
 }
+#endif /* GST_DISABLE_GST_DEBUG */
 
 EGLImageKHR
 gst_egl_image_get_image (GstEGLImage * image)
@@ -174,8 +176,6 @@ _drm_fourcc_from_info (GstVideoInfo * info, int plane)
   const gint rg_fourcc = DRM_FORMAT_RG88;
 #endif
 
-  _init_debug ();
-
   GST_DEBUG ("Getting DRM fourcc for %s plane %i",
       gst_video_format_to_string (format), plane);