From bd940327ef9a5d7809c61c6ec138ed12fd5c5863 Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Mon, 27 Apr 2015 15:20:56 +1000 Subject: [PATCH] gl: unref display/other-context in the correct place Otherwise state changes from PLAYING->READY->PAUSED will cause there to to be no display configured on the element. https://bugzilla.gnome.org/show_bug.cgi?id=748405 --- ext/gl/gstglbasemixer.c | 33 +++++++++++-------------------- ext/gl/gstglimagesink.c | 10 +++++----- ext/gl/gstgltestsrc.c | 30 +++++++++++----------------- gst-libs/gst/gl/gstglbasefilter.c | 20 +++++-------------- 4 files changed, 32 insertions(+), 61 deletions(-) diff --git a/ext/gl/gstglbasemixer.c b/ext/gl/gstglbasemixer.c index 448c6a6b7f..0e670e044d 100644 --- a/ext/gl/gstglbasemixer.c +++ b/ext/gl/gstglbasemixer.c @@ -247,8 +247,6 @@ static gboolean gst_gl_base_mixer_set_allocation (GstGLBaseMixer * mix, GstBufferPool * pool, GstAllocator * allocator, GstAllocationParams * params, GstQuery * query); -static void gst_gl_base_mixer_finalize (GObject * object); - static void gst_gl_base_mixer_class_init (GstGLBaseMixerClass * klass) { @@ -266,8 +264,6 @@ gst_gl_base_mixer_class_init (GstGLBaseMixerClass * klass) g_type_class_add_private (klass, sizeof (GstGLBaseMixerPrivate)); - gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_gl_base_mixer_finalize); - gobject_class->get_property = gst_gl_base_mixer_get_property; gobject_class->set_property = gst_gl_base_mixer_set_property; @@ -313,19 +309,6 @@ gst_gl_base_mixer_init (GstGLBaseMixer * mix) gst_gl_base_mixer_reset (mix); } -static void -gst_gl_base_mixer_finalize (GObject * object) -{ - GstGLBaseMixer *mix = GST_GL_BASE_MIXER (object); - - if (mix->priv->other_context) { - gst_object_unref (mix->priv->other_context); - mix->priv->other_context = NULL; - } - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - static void gst_gl_base_mixer_set_context (GstElement * element, GstContext * context) { @@ -674,11 +657,6 @@ gst_gl_base_mixer_stop (GstAggregator * agg) mix->priv->pool = NULL; } - if (mix->display) { - gst_object_unref (mix->display); - mix->display = NULL; - } - if (mix->context) { gst_object_unref (mix->context); mix->context = NULL; @@ -717,6 +695,17 @@ gst_gl_base_mixer_change_state (GstElement * element, GstStateChange transition) return ret; switch (transition) { + case GST_STATE_CHANGE_READY_TO_NULL: + if (mix->priv->other_context) { + gst_object_unref (mix->priv->other_context); + mix->priv->other_context = NULL; + } + + if (mix->display) { + gst_object_unref (mix->display); + mix->display = NULL; + } + break; default: break; } diff --git a/ext/gl/gstglimagesink.c b/ext/gl/gstglimagesink.c index 796392d31e..d23cc83dac 100644 --- a/ext/gl/gstglimagesink.c +++ b/ext/gl/gstglimagesink.c @@ -624,11 +624,6 @@ gst_glimage_sink_finalize (GObject * object) g_mutex_clear (&glimage_sink->drawing_lock); - if (glimage_sink->other_context) { - gst_object_unref (glimage_sink->other_context); - glimage_sink->other_context = NULL; - } - g_free (glimage_sink->display_name); GST_DEBUG ("finalized"); @@ -971,6 +966,11 @@ gst_glimage_sink_change_state (GstElement * element, GstStateChange transition) break; } case GST_STATE_CHANGE_READY_TO_NULL: + if (glimage_sink->other_context) { + gst_object_unref (glimage_sink->other_context); + glimage_sink->other_context = NULL; + } + if (glimage_sink->display) { gst_object_unref (glimage_sink->display); glimage_sink->display = NULL; diff --git a/ext/gl/gstgltestsrc.c b/ext/gl/gstgltestsrc.c index 788fd86ff0..100ecaae23 100644 --- a/ext/gl/gstgltestsrc.c +++ b/ext/gl/gstgltestsrc.c @@ -80,7 +80,6 @@ static void gst_gl_test_src_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); static void gst_gl_test_src_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec); -static void gst_gl_test_src_dispose (GObject * object); static gboolean gst_gl_test_src_setcaps (GstBaseSrc * bsrc, GstCaps * caps); static GstCaps *gst_gl_test_src_getcaps (GstBaseSrc * bsrc, GstCaps * filter); @@ -156,7 +155,6 @@ gst_gl_test_src_class_init (GstGLTestSrcClass * klass) gobject_class->set_property = gst_gl_test_src_set_property; gobject_class->get_property = gst_gl_test_src_get_property; - gobject_class->dispose = gst_gl_test_src_dispose; g_object_class_install_property (gobject_class, PROP_PATTERN, g_param_spec_enum ("pattern", "Pattern", @@ -386,18 +384,6 @@ gst_gl_test_src_set_pattern (GstGLTestSrc * gltestsrc, gint pattern_type) } } -static void -gst_gl_test_src_dispose (GObject * object) -{ - GstGLTestSrc *src = GST_GL_TEST_SRC (object); - - if (src->other_context) - gst_object_unref (src->other_context); - src->other_context = NULL; - - G_OBJECT_CLASS (parent_class)->dispose (object); -} - static void gst_gl_test_src_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) @@ -749,11 +735,6 @@ gst_gl_test_src_stop (GstBaseSrc * basesrc) src->context = NULL; } - if (src->display) { - gst_object_unref (src->display); - src->display = NULL; - } - return TRUE; } @@ -934,6 +915,17 @@ gst_gl_test_src_change_state (GstElement * element, GstStateChange transition) return ret; switch (transition) { + case GST_STATE_CHANGE_READY_TO_NULL: + if (src->other_context) { + gst_object_unref (src->other_context); + src->other_context = NULL; + } + + if (src->display) { + gst_object_unref (src->display); + src->display = NULL; + } + break; default: break; } diff --git a/gst-libs/gst/gl/gstglbasefilter.c b/gst-libs/gst/gl/gstglbasefilter.c index 5bff1ea303..0b49e09ae4 100644 --- a/gst-libs/gst/gl/gstglbasefilter.c +++ b/gst-libs/gst/gl/gstglbasefilter.c @@ -56,7 +56,6 @@ static void gst_gl_base_filter_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); static void gst_gl_base_filter_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec); -static void gst_gl_base_filter_finalize (GObject * object); static void gst_gl_base_filter_set_context (GstElement * element, GstContext * context); @@ -89,7 +88,6 @@ gst_gl_base_filter_class_init (GstGLBaseFilterClass * klass) gobject_class->set_property = gst_gl_base_filter_set_property; gobject_class->get_property = gst_gl_base_filter_get_property; - gobject_class->finalize = gst_gl_base_filter_finalize; GST_BASE_TRANSFORM_CLASS (klass)->query = gst_gl_base_filter_query; GST_BASE_TRANSFORM_CLASS (klass)->start = gst_gl_base_filter_start; @@ -117,19 +115,6 @@ gst_gl_base_filter_init (GstGLBaseFilter * filter) filter->priv = GST_GL_BASE_FILTER_GET_PRIVATE (filter); } -static void -gst_gl_base_filter_finalize (GObject * object) -{ - GstGLBaseFilter *filter = GST_GL_BASE_FILTER (object); - - if (filter->priv->other_context) { - gst_object_unref (filter->priv->other_context); - filter->priv->other_context = NULL; - } - - G_OBJECT_CLASS (gst_gl_base_filter_parent_class)->finalize (object); -} - static void gst_gl_base_filter_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) @@ -424,6 +409,11 @@ gst_gl_base_filter_change_state (GstElement * element, switch (transition) { case GST_STATE_CHANGE_READY_TO_NULL: + if (filter->priv->other_context) { + gst_object_unref (filter->priv->other_context); + filter->priv->other_context = NULL; + } + if (filter->display) { gst_object_unref (filter->display); filter->display = NULL;