From 62b8caa6ab2361582a02993df3e55f4716679126 Mon Sep 17 00:00:00 2001 From: Philippe Normand Date: Sat, 15 Jan 2022 10:06:23 +0000 Subject: [PATCH] pbutils: Define one debug category per module Follow-up of https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1505 Part-of: --- .../gst-libs/gst/pbutils/codec-utils.c | 22 +++++++++++++++++++-- .../gst-libs/gst/pbutils/encoding-profile.c | 22 +++++++++++++++++++-- .../gst-libs/gst/pbutils/encoding-target.c | 22 +++++++++++++++++++-- .../gst-libs/gst/pbutils/install-plugins.c | 21 ++++++++++++++++++++ .../gst-libs/gst/pbutils/missing-plugins.c | 21 ++++++++++++++++++++ .../gst-libs/gst/pbutils/pbutils.c | 23 ++++++++++++++++++---- 6 files changed, 121 insertions(+), 10 deletions(-) diff --git a/subprojects/gst-plugins-base/gst-libs/gst/pbutils/codec-utils.c b/subprojects/gst-plugins-base/gst-libs/gst/pbutils/codec-utils.c index 9b0d9eb..6991d74 100644 --- a/subprojects/gst-plugins-base/gst-libs/gst/pbutils/codec-utils.c +++ b/subprojects/gst-plugins-base/gst-libs/gst/pbutils/codec-utils.c @@ -43,8 +43,26 @@ #include -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)) diff --git a/subprojects/gst-plugins-base/gst-libs/gst/pbutils/encoding-profile.c b/subprojects/gst-plugins-base/gst-libs/gst/pbutils/encoding-profile.c index 02c3433..98123bb 100644 --- a/subprojects/gst-plugins-base/gst-libs/gst/pbutils/encoding-profile.c +++ b/subprojects/gst-plugins-base/gst-libs/gst/pbutils/encoding-profile.c @@ -299,8 +299,26 @@ #include -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)) diff --git a/subprojects/gst-plugins-base/gst-libs/gst/pbutils/encoding-target.c b/subprojects/gst-plugins-base/gst-libs/gst/pbutils/encoding-target.c index 9c4ff8c..5351c8a 100644 --- a/subprojects/gst-plugins-base/gst-libs/gst/pbutils/encoding-target.c +++ b/subprojects/gst-plugins-base/gst-libs/gst/pbutils/encoding-target.c @@ -88,8 +88,26 @@ /* 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" diff --git a/subprojects/gst-plugins-base/gst-libs/gst/pbutils/install-plugins.c b/subprojects/gst-plugins-base/gst-libs/gst/pbutils/install-plugins.c index 4853f32..2b81127 100644 --- a/subprojects/gst-plugins-base/gst-libs/gst/pbutils/install-plugins.c +++ b/subprojects/gst-plugins-base/gst-libs/gst/pbutils/install-plugins.c @@ -272,6 +272,27 @@ #include +#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) diff --git a/subprojects/gst-plugins-base/gst-libs/gst/pbutils/missing-plugins.c b/subprojects/gst-plugins-base/gst-libs/gst/pbutils/missing-plugins.c index a08803b..8c6f222 100644 --- a/subprojects/gst-plugins-base/gst-libs/gst/pbutils/missing-plugins.c +++ b/subprojects/gst-plugins-base/gst-libs/gst/pbutils/missing-plugins.c @@ -63,6 +63,27 @@ #include +#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 diff --git a/subprojects/gst-plugins-base/gst-libs/gst/pbutils/pbutils.c b/subprojects/gst-plugins-base/gst-libs/gst/pbutils/pbutils.c index 15b0dd1..3aee17e 100644 --- a/subprojects/gst-plugins-base/gst-libs/gst/pbutils/pbutils.c +++ b/subprojects/gst-plugins-base/gst-libs/gst/pbutils/pbutils.c @@ -61,8 +61,25 @@ #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; -- 2.7.4