d3d11: Initialize debug categories of non-GstElement implementation in plugin init
authorSeungha Yang <seungha.yang@navercorp.com>
Wed, 4 Dec 2019 15:53:40 +0000 (00:53 +0900)
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Thu, 5 Dec 2019 02:29:18 +0000 (02:29 +0000)
That's the way to expose debug category to --gst-debug-help

sys/d3d11/gstd3d11device.c
sys/d3d11/gstd3d11format.c
sys/d3d11/gstd3d11utils.c
sys/d3d11/plugin.c

index 3f054c5..de6c9f0 100644 (file)
@@ -29,7 +29,7 @@
 #endif
 
 GST_DEBUG_CATEGORY_STATIC (GST_CAT_CONTEXT);
-GST_DEBUG_CATEGORY_STATIC (gst_d3d11_device_debug);
+GST_DEBUG_CATEGORY_EXTERN (gst_d3d11_device_debug);
 #define GST_CAT_DEFAULT gst_d3d11_device_debug
 
 #ifdef HAVE_D3D11SDKLAYER_H
@@ -178,8 +178,6 @@ gst_d3d11_device_class_init (GstD3D11DeviceClass * klass)
           "Human readable device description", NULL,
           G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
 
-  GST_DEBUG_CATEGORY_INIT (gst_d3d11_device_debug,
-      "d3d11device", 0, "d3d11 device");
   GST_DEBUG_CATEGORY_GET (GST_CAT_CONTEXT, "GST_CONTEXT");
 }
 
@@ -542,13 +540,6 @@ gst_d3d11_device_new (guint adapter)
 {
   GstD3D11Device *device = NULL;
   GstD3D11DevicePrivate *priv;
-  static volatile gsize _init = 0;
-
-  if (g_once_init_enter (&_init)) {
-    GST_DEBUG_CATEGORY_INIT (gst_d3d11_device_debug, "d3d11device", 0,
-        "d3d11 device");
-    g_once_init_leave (&_init, 1);
-  }
 
   device = g_object_new (GST_TYPE_D3D11_DEVICE, "adapter", adapter, NULL);
 
index 5823376..8c0fd2d 100644 (file)
 #include "gstd3d11device.h"
 #include "gstd3d11memory.h"
 
-#ifndef GST_DISABLE_GST_DEBUG
-#define GST_CAT_DEFAULT ensure_debug_category()
-static GstDebugCategory *
-ensure_debug_category (void)
-{
-  static gsize cat_gonce = 0;
-
-  if (g_once_init_enter (&cat_gonce)) {
-    gsize cat_done;
-
-    cat_done = (gsize) _gst_debug_category_new ("d3d11format", 0,
-        "Direct3D11 Format");
-
-    g_once_init_leave (&cat_gonce, cat_done);
-  }
-
-  return (GstDebugCategory *) cat_gonce;
-}
-#else
-#define ensure_debug_category() /* NOOP */
-#endif /* GST_DISABLE_GST_DEBUG */
+GST_DEBUG_CATEGORY_EXTERN (gst_d3d11_format_debug);
+#define GST_CAT_DEFAULT gst_d3d11_format_debug
 
 /* Following formats were introduced since Windows 8
  * DXGI_FORMAT_AYUV
index 096943c..4c9a9a8 100644 (file)
 #include <windows.h>
 #include <versionhelpers.h>
 
-GST_DEBUG_CATEGORY_STATIC (gst_d3d11_utils_debug);
 GST_DEBUG_CATEGORY_STATIC (GST_CAT_CONTEXT);
-
-static GstDebugCategory *
-_init_d3d11_utils_debug (void)
-{
-  static volatile gsize _init = 0;
-
-  if (g_once_init_enter (&_init)) {
-    GST_DEBUG_CATEGORY_INIT (gst_d3d11_utils_debug, "d3d11utils", 0,
-        "Direct3D11 Utilities");
-    g_once_init_leave (&_init, 1);
-  }
-
-  return gst_d3d11_utils_debug;
-}
+GST_DEBUG_CATEGORY_EXTERN (gst_d3d11_utils_debug);
+#define GST_CAT_DEFAULT gst_d3d11_utils_debug
 
 static void
 _init_context_debug (void)
@@ -55,8 +42,6 @@ _init_context_debug (void)
   }
 }
 
-#define GST_CAT_DEFAULT _init_d3d11_utils_debug()
-
 /**
  * gst_d3d11_handle_set_context:
  * @element: a #GstElement
@@ -79,7 +64,6 @@ gst_d3d11_handle_set_context (GstElement * element, GstContext * context,
   g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);
   g_return_val_if_fail (device != NULL, FALSE);
 
-  _init_d3d11_utils_debug ();
   _init_context_debug ();
 
   if (!context)
@@ -153,7 +137,6 @@ gst_d3d11_handle_context_query (GstElement * element, GstQuery * query,
   g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);
   g_return_val_if_fail (GST_IS_QUERY (query), FALSE);
 
-  _init_d3d11_utils_debug ();
   _init_context_debug ();
 
   GST_LOG_OBJECT (element, "handle context query %" GST_PTR_FORMAT, query);
@@ -298,7 +281,6 @@ gst_d3d11_ensure_element_data (GstElement * element, gint adapter,
   g_return_val_if_fail (element != NULL, FALSE);
   g_return_val_if_fail (device != NULL, FALSE);
 
-  _init_d3d11_utils_debug ();
   _init_context_debug ();
 
   if (*device) {
index 5af8926..102e53e 100644 (file)
@@ -30,6 +30,9 @@
 
 GST_DEBUG_CATEGORY (gst_d3d11_shader_debug);
 GST_DEBUG_CATEGORY (gst_d3d11_colorconverter_debug);
+GST_DEBUG_CATEGORY (gst_d3d11_utils_debug);
+GST_DEBUG_CATEGORY (gst_d3d11_format_debug);
+GST_DEBUG_CATEGORY (gst_d3d11_device_debug);
 
 static gboolean
 plugin_init (GstPlugin * plugin)
@@ -38,6 +41,12 @@ plugin_init (GstPlugin * plugin)
       "d3d11shader", 0, "d3d11shader");
   GST_DEBUG_CATEGORY_INIT (gst_d3d11_colorconverter_debug,
       "d3d11colorconverter", 0, "d3d11colorconverter");
+  GST_DEBUG_CATEGORY_INIT (gst_d3d11_utils_debug,
+      "d3d11utils", 0, "d3d11 utility functions");
+  GST_DEBUG_CATEGORY_INIT (gst_d3d11_format_debug,
+      "d3d11format", 0, "d3d11 specific formats");
+  GST_DEBUG_CATEGORY_INIT (gst_d3d11_device_debug,
+      "d3d11device", 0, "d3d11 device object");
 
   gst_element_register (plugin,
       "d3d11upload", GST_RANK_NONE, GST_TYPE_D3D11_UPLOAD);