diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2016-05-16 12:52:50 +0200 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2016-05-20 09:07:44 +0300 |
commit | 37f05e32a931f47019be6f0d937e7172d6c90848 (patch) | |
tree | 37cf0ad5647069f72bd2830196604fc0716784e9 | |
parent | bb015bad32475849e6df16a2f588ec32a8bde270 (diff) | |
download | gstreamer-plugins-base-37f05e32a931f47019be6f0d937e7172d6c90848.tar.gz |
videosink: ensure the debug category is always initialized
gst_video_sink_center_rect() can be called without a GstVideoSink
having been instantiated so we can't relly on the video sink
class_init function to init the category.
Fix a warning when running:
GST_CHECKS=test_video_center_rect GST_DEBUG=6 G_DEBUG=fatal_warnings make libs/video.check-norepeat
https://bugzilla.gnome.org/show_bug.cgi?id=766510
-rw-r--r-- | gst-libs/gst/video/gstvideosink.c | 56 |
1 files changed, 21 insertions, 35 deletions
diff --git a/gst-libs/gst/video/gstvideosink.c b/gst-libs/gst/video/gstvideosink.c index 26b7df21c..1b22cb2d7 100644 --- a/gst-libs/gst/video/gstvideosink.c +++ b/gst-libs/gst/video/gstvideosink.c @@ -40,6 +40,8 @@ #include "gstvideosink.h" +G_DEFINE_TYPE (GstVideoSink, gst_video_sink, GST_TYPE_BASE_SINK); + enum { PROP_SHOW_PREROLL_FRAME = 1 @@ -52,8 +54,25 @@ struct _GstVideoSinkPrivate gboolean show_preroll_frame; /* ATOMIC */ }; -GST_DEBUG_CATEGORY_STATIC (video_sink_debug); -#define GST_CAT_DEFAULT video_sink_debug +#ifndef GST_DISABLE_GST_DEBUG +#define GST_CAT_DEFAULT gst_video_sink_ensure_debug_category() + +static GstDebugCategory * +gst_video_sink_ensure_debug_category (void) +{ + static gsize cat_gonce = 0; + + if (g_once_init_enter (&cat_gonce)) { + GstDebugCategory *cat = NULL; + + GST_DEBUG_CATEGORY_INIT (cat, "videosink", 0, "GstVideoSink"); + + g_once_init_leave (&cat_gonce, (gsize) cat); + } + + return (GstDebugCategory *) cat_gonce; +} +#endif /* GST_DISABLE_GST_DEBUG */ static GstBaseSinkClass *parent_class = NULL; @@ -163,12 +182,6 @@ gst_video_sink_class_init (GstVideoSinkClass * klass) g_type_class_add_private (klass, sizeof (GstVideoSinkPrivate)); } -static void -gst_video_sink_base_init (gpointer g_class) -{ - GST_DEBUG_CATEGORY_INIT (video_sink_debug, "videosink", 0, "GstVideoSink"); -} - static GstFlowReturn gst_video_sink_show_preroll_frame (GstBaseSink * bsink, GstBuffer * buf) { @@ -257,30 +270,3 @@ gst_video_sink_get_property (GObject * object, guint prop_id, break; } } - -/* Public methods */ - -GType -gst_video_sink_get_type (void) -{ - static GType videosink_type = 0; - - if (!videosink_type) { - static const GTypeInfo videosink_info = { - sizeof (GstVideoSinkClass), - gst_video_sink_base_init, - NULL, - (GClassInitFunc) gst_video_sink_class_init, - NULL, - NULL, - sizeof (GstVideoSink), - 0, - (GInstanceInitFunc) gst_video_sink_init, - }; - - videosink_type = g_type_register_static (GST_TYPE_BASE_SINK, - "GstVideoSink", &videosink_info, 0); - } - - return videosink_type; -} |