gtkglsink: reset the context/display in READY_TO_NULL
authorMatthew Waters <matthew@centricular.com>
Fri, 12 Jun 2015 02:29:37 +0000 (12:29 +1000)
committerMatthew Waters <matthew@centricular.com>
Fri, 12 Jun 2015 02:32:06 +0000 (12:32 +1000)
Fixes context propagation in pipelines with upstream GL elements.

ext/gtk/gstgtkglsink.c

index 9ad1950..f278873 100644 (file)
@@ -134,31 +134,10 @@ gst_gtk_gl_sink_set_property (GObject * object, guint prop_id,
 }
 
 static void
-_reset (GstGtkGLSink * gtk_sink)
-{
-  if (gtk_sink->display) {
-    gst_object_unref (gtk_sink->display);
-    gtk_sink->display = NULL;
-  }
-
-  if (gtk_sink->context) {
-    gst_object_unref (gtk_sink->context);
-    gtk_sink->context = NULL;
-  }
-
-  if (gtk_sink->gtk_context) {
-    gst_object_unref (gtk_sink->gtk_context);
-    gtk_sink->gtk_context = NULL;
-  }
-}
-
-static void
 gst_gtk_gl_sink_finalize (GObject * object)
 {
   GstGtkGLSink *gtk_sink = GST_GTK_GL_SINK (object);;
 
-  _reset (gtk_sink);
-
   g_object_unref (gtk_sink->widget);
 
   G_OBJECT_CLASS (parent_class)->finalize (object);
@@ -316,6 +295,20 @@ gst_gtk_gl_sink_change_state (GstElement * element, GstStateChange transition)
       gtk_gst_gl_widget_set_buffer (gtk_sink->widget, NULL);
       break;
     case GST_STATE_CHANGE_READY_TO_NULL:
+      if (gtk_sink->display) {
+        gst_object_unref (gtk_sink->display);
+        gtk_sink->display = NULL;
+      }
+
+      if (gtk_sink->context) {
+        gst_object_unref (gtk_sink->context);
+        gtk_sink->context = NULL;
+      }
+
+      if (gtk_sink->gtk_context) {
+        gst_object_unref (gtk_sink->gtk_context);
+        gtk_sink->gtk_context = NULL;
+      }
       break;
     default:
       break;
@@ -354,8 +347,6 @@ gst_gtk_gl_sink_set_caps (GstBaseSink * bsink, GstCaps * caps)
 
   GST_DEBUG ("set caps with %" GST_PTR_FORMAT, caps);
 
-  _reset (gtk_sink);
-
   if (!gst_video_info_from_caps (&gtk_sink->v_info, caps))
     return FALSE;