From 65ff618bb6754d7d8b4c1ad9cdf1371b155068db Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Wed, 17 Jul 2024 23:44:09 +0530 Subject: [PATCH] avfdeviceprovider: Fix debug category initialization The device monitor calls into avfvideosrc functions without initializing the debug category, which causes multiple criticals. Part-of: --- .../sys/applemedia/avfdeviceprovider.m | 2 ++ .../gst-plugins-bad/sys/applemedia/avfvideosrc.h | 1 + .../gst-plugins-bad/sys/applemedia/avfvideosrc.m | 15 +++++++++++++-- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/subprojects/gst-plugins-bad/sys/applemedia/avfdeviceprovider.m b/subprojects/gst-plugins-bad/sys/applemedia/avfdeviceprovider.m index 24b5aac0af..8b27e860c8 100644 --- a/subprojects/gst-plugins-bad/sys/applemedia/avfdeviceprovider.m +++ b/subprojects/gst-plugins-bad/sys/applemedia/avfdeviceprovider.m @@ -48,6 +48,8 @@ gst_avf_device_provider_class_init (GstAVFDeviceProviderClass * klass) // https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/886 dm_class->probe = gst_avf_device_provider_probe; + gst_avf_video_src_debug_init (); + gst_device_provider_class_set_static_metadata (dm_class, "AVF Device Provider", "Source/Video", "List and provide AVF source devices", diff --git a/subprojects/gst-plugins-bad/sys/applemedia/avfvideosrc.h b/subprojects/gst-plugins-bad/sys/applemedia/avfvideosrc.h index 15ebcec518..72f63f559e 100644 --- a/subprojects/gst-plugins-bad/sys/applemedia/avfvideosrc.h +++ b/subprojects/gst-plugins-bad/sys/applemedia/avfvideosrc.h @@ -83,6 +83,7 @@ struct _GstAVFVideoSrcClass GType gst_avf_video_src_get_type (void); +void gst_avf_video_src_debug_init (void); GstCaps *gst_av_capture_device_get_caps (AVCaptureDevice *device, AVCaptureVideoDataOutput *output, GstAVFVideoSourceOrientation orientation); G_END_DECLS diff --git a/subprojects/gst-plugins-bad/sys/applemedia/avfvideosrc.m b/subprojects/gst-plugins-bad/sys/applemedia/avfvideosrc.m index 19dbd68f3c..b356e78310 100644 --- a/subprojects/gst-plugins-bad/sys/applemedia/avfvideosrc.m +++ b/subprojects/gst-plugins-bad/sys/applemedia/avfvideosrc.m @@ -1181,6 +1181,18 @@ static gboolean gst_avf_video_src_decide_allocation (GstBaseSrc * bsrc, static void gst_avf_video_src_set_context (GstElement * element, GstContext * context); +void +gst_avf_video_src_debug_init (void) +{ + static gsize _init = 0; + + if (g_once_init_enter (&_init)) { + GST_DEBUG_CATEGORY_INIT (gst_avf_video_src_debug, "avfvideosrc", + 0, "iOS/MacOS AVFoundation video source"); + g_once_init_leave (&_init, 1); + } +} + static void gst_avf_video_src_class_init (GstAVFVideoSrcClass * klass) { @@ -1277,8 +1289,7 @@ gst_avf_video_src_class_init (GstAVFVideoSrcClass * klass) 0, G_MAXUINT, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); #endif - GST_DEBUG_CATEGORY_INIT (gst_avf_video_src_debug, "avfvideosrc", - 0, "iOS/MacOS AVFoundation video source"); + gst_avf_video_src_debug_init (); gst_type_mark_as_plugin_api (GST_TYPE_AVF_VIDEO_SOURCE_POSITION, 0); gst_type_mark_as_plugin_api (GST_TYPE_AVF_VIDEO_SOURCE_ORIENTATION, 0);