From 199caccc419f92cc333662ea5ad72369e68f4317 Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Thu, 5 Dec 2019 00:53:40 +0900 Subject: [PATCH] d3d11: Initialize debug categories of non-GstElement implementation in plugin init That's the way to expose debug category to --gst-debug-help --- sys/d3d11/gstd3d11device.c | 11 +---------- sys/d3d11/gstd3d11format.c | 23 ++--------------------- sys/d3d11/gstd3d11utils.c | 22 ++-------------------- sys/d3d11/plugin.c | 9 +++++++++ 4 files changed, 14 insertions(+), 51 deletions(-) diff --git a/sys/d3d11/gstd3d11device.c b/sys/d3d11/gstd3d11device.c index 3f054c5..de6c9f0 100644 --- a/sys/d3d11/gstd3d11device.c +++ b/sys/d3d11/gstd3d11device.c @@ -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); diff --git a/sys/d3d11/gstd3d11format.c b/sys/d3d11/gstd3d11format.c index 5823376..8c0fd2d 100644 --- a/sys/d3d11/gstd3d11format.c +++ b/sys/d3d11/gstd3d11format.c @@ -26,27 +26,8 @@ #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 diff --git a/sys/d3d11/gstd3d11utils.c b/sys/d3d11/gstd3d11utils.c index 096943c..4c9a9a8 100644 --- a/sys/d3d11/gstd3d11utils.c +++ b/sys/d3d11/gstd3d11utils.c @@ -27,22 +27,9 @@ #include #include -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) { diff --git a/sys/d3d11/plugin.c b/sys/d3d11/plugin.c index 5af8926..102e53e 100644 --- a/sys/d3d11/plugin.c +++ b/sys/d3d11/plugin.c @@ -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); -- 2.7.4