GstGtkGLSink: Post error if widget gets destroyed

https://bugzilla.gnome.org/show_bug.cgi?id=751104
This commit is contained in:
Xavier Claessens 2015-06-17 09:36:40 -04:00 committed by Matthew Waters
parent 72b48a39d8
commit b71b7dc9e6
2 changed files with 15 additions and 0 deletions

View file

@ -161,6 +161,12 @@ gst_gtk_gl_sink_finalize (GObject * object)
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (parent_class)->finalize (object);
} }
static void
widget_destroy_cb (GtkWidget * widget, GstGtkGLSink * gtk_sink)
{
g_atomic_int_set (&gtk_sink->widget_destroyed, 1);
}
static GtkGstGLWidget * static GtkGstGLWidget *
gst_gtk_gl_sink_get_widget (GstGtkGLSink * gtk_sink) gst_gtk_gl_sink_get_widget (GstGtkGLSink * gtk_sink)
{ {
@ -188,6 +194,8 @@ gst_gtk_gl_sink_get_widget (GstGtkGLSink * gtk_sink)
/* Take the floating ref, otherwise the destruction of the container will /* Take the floating ref, otherwise the destruction of the container will
* make this widget disapear possibly before we are done. */ * make this widget disapear possibly before we are done. */
gst_object_ref_sink (gtk_sink->widget); gst_object_ref_sink (gtk_sink->widget);
g_signal_connect (gtk_sink->widget, "destroy",
G_CALLBACK (widget_destroy_cb), gtk_sink);
return gtk_sink->widget; return gtk_sink->widget;
} }
@ -426,6 +434,12 @@ gst_gtk_gl_sink_show_frame (GstVideoSink * vsink, GstBuffer * buf)
gtk_gst_gl_widget_set_buffer (gtk_sink->widget, buf); gtk_gst_gl_widget_set_buffer (gtk_sink->widget, buf);
if (g_atomic_int_get (&gtk_sink->widget_destroyed)) {
GST_ELEMENT_ERROR (gtk_sink, RESOURCE, NOT_FOUND,
("%s", "Output widget was destroyed"), (NULL));
return GST_FLOW_ERROR;
}
return GST_FLOW_OK; return GST_FLOW_OK;
} }

View file

@ -54,6 +54,7 @@ struct _GstGtkGLSink
GstVideoSink parent; GstVideoSink parent;
GtkGstGLWidget *widget; GtkGstGLWidget *widget;
gboolean widget_destroyed;
GstVideoInfo v_info; GstVideoInfo v_info;
GstBufferPool *pool; GstBufferPool *pool;