pbutils: Define one debug category per module
authorPhilippe Normand <philn@igalia.com>
Sat, 15 Jan 2022 10:06:23 +0000 (10:06 +0000)
committerPhilippe Normand <philn@igalia.com>
Tue, 18 Jan 2022 18:19:46 +0000 (18:19 +0000)
Follow-up of https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1505

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1526>

subprojects/gst-plugins-base/gst-libs/gst/pbutils/codec-utils.c
subprojects/gst-plugins-base/gst-libs/gst/pbutils/encoding-profile.c
subprojects/gst-plugins-base/gst-libs/gst/pbutils/encoding-target.c
subprojects/gst-plugins-base/gst-libs/gst/pbutils/install-plugins.c
subprojects/gst-plugins-base/gst-libs/gst/pbutils/missing-plugins.c
subprojects/gst-plugins-base/gst-libs/gst/pbutils/pbutils.c

index 9b0d9eb..6991d74 100644 (file)
 
 #include <string.h>
 
-GST_DEBUG_CATEGORY_EXTERN (pbutils_debug);
-#define GST_CAT_DEFAULT pbutils_debug
+#ifndef GST_DISABLE_GST_DEBUG
+#define GST_CAT_DEFAULT gst_pb_utils_codec_utils_ensure_debug_category()
+
+static GstDebugCategory *
+gst_pb_utils_codec_utils_ensure_debug_category (void)
+{
+  static gsize cat_gonce = 0;
+
+  if (g_once_init_enter (&cat_gonce)) {
+    GstDebugCategory *cat = NULL;
+
+    GST_DEBUG_CATEGORY_INIT (cat, "codec-utils", 0,
+        "GstPbUtils codec helper functions");
+
+    g_once_init_leave (&cat_gonce, (gsize) cat);
+  }
+
+  return (GstDebugCategory *) cat_gonce;
+}
+#endif /* GST_DISABLE_GST_DEBUG */
 
 #define GST_SIMPLE_CAPS_HAS_NAME(caps,name) \
     gst_structure_has_name(gst_caps_get_structure((caps),0),(name))
index 02c3433..98123bb 100644 (file)
 
 #include <string.h>
 
-GST_DEBUG_CATEGORY_EXTERN (pbutils_debug);
-#define GST_CAT_DEFAULT pbutils_debug
+#ifndef GST_DISABLE_GST_DEBUG
+#define GST_CAT_DEFAULT gst_pb_utils_encoding_profile_ensure_debug_category()
+
+static GstDebugCategory *
+gst_pb_utils_encoding_profile_ensure_debug_category (void)
+{
+  static gsize cat_gonce = 0;
+
+  if (g_once_init_enter (&cat_gonce)) {
+    GstDebugCategory *cat = NULL;
+
+    GST_DEBUG_CATEGORY_INIT (cat, "encoding-profile", 0,
+        "GstPbUtils encoding profile");
+
+    g_once_init_leave (&cat_gonce, (gsize) cat);
+  }
+
+  return (GstDebugCategory *) cat_gonce;
+}
+#endif /* GST_DISABLE_GST_DEBUG */
 
 /* GstEncodingProfile API */
 #define PROFILE_LOCK(profile) (g_mutex_lock(&((GstEncodingProfile*)profile)->lock))
index 9c4ff8c..5351c8a 100644 (file)
 
 /* Documented in encoding-profile.c */
 
-GST_DEBUG_CATEGORY_EXTERN (pbutils_debug);
-#define GST_CAT_DEFAULT pbutils_debug
+#ifndef GST_DISABLE_GST_DEBUG
+#define GST_CAT_DEFAULT gst_pb_utils_encoding_target_ensure_debug_category()
+
+static GstDebugCategory *
+gst_pb_utils_encoding_target_ensure_debug_category (void)
+{
+  static gsize cat_gonce = 0;
+
+  if (g_once_init_enter (&cat_gonce)) {
+    GstDebugCategory *cat = NULL;
+
+    GST_DEBUG_CATEGORY_INIT (cat, "encoding-target", 0,
+        "GstPbUtils encoding target");
+
+    g_once_init_leave (&cat_gonce, (gsize) cat);
+  }
+
+  return (GstDebugCategory *) cat_gonce;
+}
+#endif /* GST_DISABLE_GST_DEBUG */
 
 #define GST_ENCODING_TARGET_HEADER "GStreamer Encoding Target"
 #define GST_ENCODING_TARGET_DIRECTORY "encoding-profiles"
index 4853f32..2b81127 100644 (file)
 
 #include <string.h>
 
+#ifndef GST_DISABLE_GST_DEBUG
+#define GST_CAT_DEFAULT gst_pb_utils_install_plugins_ensure_debug_category()
+
+static GstDebugCategory *
+gst_pb_utils_install_plugins_ensure_debug_category (void)
+{
+  static gsize cat_gonce = 0;
+
+  if (g_once_init_enter (&cat_gonce)) {
+    GstDebugCategory *cat = NULL;
+
+    GST_DEBUG_CATEGORY_INIT (cat, "install-plugins", 0,
+        "GstPbUtils plugins installation helper");
+
+    g_once_init_leave (&cat_gonce, (gsize) cat);
+  }
+
+  return (GstDebugCategory *) cat_gonce;
+}
+#endif /* GST_DISABLE_GST_DEBUG */
+
 /* best effort to make things compile and possibly even work on win32 */
 #ifndef WEXITSTATUS
 # define WEXITSTATUS(status) ((((guint)(status)) & 0xff00) >> 8)
index a08803b..8c6f222 100644 (file)
 
 #include <string.h>
 
+#ifndef GST_DISABLE_GST_DEBUG
+#define GST_CAT_DEFAULT gst_pb_utils_missing_plugins_ensure_debug_category()
+
+static GstDebugCategory *
+gst_pb_utils_missing_plugins_ensure_debug_category (void)
+{
+  static gsize cat_gonce = 0;
+
+  if (g_once_init_enter (&cat_gonce)) {
+    GstDebugCategory *cat = NULL;
+
+    GST_DEBUG_CATEGORY_INIT (cat, "missing-plugins", 0,
+        "GstPbUtils missing plugins helper");
+
+    g_once_init_leave (&cat_gonce, (gsize) cat);
+  }
+
+  return (GstDebugCategory *) cat_gonce;
+}
+#endif /* GST_DISABLE_GST_DEBUG */
+
 #define GST_DETAIL_STRING_MARKER "gstreamer"
 
 typedef enum
index 15b0dd1..3aee17e 100644 (file)
 
 #include "gst/gst-i18n-plugin.h"
 
-GST_DEBUG_CATEGORY (pbutils_debug);
-#define GST_CAT_DEFAULT pbutils_debug
+#ifndef GST_DISABLE_GST_DEBUG
+#define GST_CAT_DEFAULT gst_pb_utils_ensure_debug_category()
+
+static GstDebugCategory *
+gst_pb_utils_ensure_debug_category (void)
+{
+  static gsize cat_gonce = 0;
+
+  if (g_once_init_enter (&cat_gonce)) {
+    GstDebugCategory *cat = NULL;
+
+    GST_DEBUG_CATEGORY_INIT (cat, "pbutils", 0, "GStreamer Plugins Base utils");
+
+    g_once_init_leave (&cat_gonce, (gsize) cat);
+  }
+
+  return (GstDebugCategory *) cat_gonce;
+}
+#endif /* GST_DISABLE_GST_DEBUG */
 
 static gpointer
 _init_locale_text_domain (gpointer data)
@@ -104,8 +121,6 @@ gst_pb_utils_init (void)
     GST_LOG ("already initialised");
     return;
   }
-  GST_DEBUG_CATEGORY_INIT (pbutils_debug, "pbutils", 0,
-      "GStreamer Plugins Base utils");
   gst_pb_utils_init_locale_text_domain ();
 
   inited = TRUE;