From 5694cdd8ca2ba340ee5c35fb959a5a57ccbadda3 Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Wed, 13 Jan 2016 13:17:56 +1100 Subject: [PATCH] glimagesink: don't push a reconfigure event from the GL thread Doing so may cause deadlocks when other elements attempt destroy or created GL resources. https://bugzilla.gnome.org/show_bug.cgi?id=760559 --- ext/gl/gstglimagesink.c | 26 +++++++++++++++++++------- ext/gl/gstglimagesink.h | 3 ++- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/ext/gl/gstglimagesink.c b/ext/gl/gstglimagesink.c index 0795170..2e5a603 100644 --- a/ext/gl/gstglimagesink.c +++ b/ext/gl/gstglimagesink.c @@ -1474,6 +1474,15 @@ gst_glimage_sink_prepare (GstBaseSink * bsink, GstBuffer * buf) gst_gl_sync_meta_wait (sync_meta, glimage_sink->context); GST_GLIMAGE_SINK_LOCK (glimage_sink); + if (glimage_sink->window_resized) { + glimage_sink->window_resized = FALSE; + GST_GLIMAGE_SINK_UNLOCK (glimage_sink); + GST_DEBUG_OBJECT (glimage_sink, "Sending reconfigure event on sinkpad."); + gst_pad_push_event (GST_BASE_SINK (glimage_sink)->sinkpad, + gst_event_new_reconfigure ()); + GST_GLIMAGE_SINK_LOCK (glimage_sink); + } + target = &glimage_sink->input_buffer; if (GST_VIDEO_INFO_MULTIVIEW_MODE (&glimage_sink->in_info) == GST_VIDEO_MULTIVIEW_MODE_FRAME_BY_FRAME && @@ -1885,7 +1894,7 @@ gst_glimage_sink_on_resize (GstGLImageSink * gl_sink, gint width, gint height) height = MAX (1, height); /* Check if we would suggest a different width/height now */ - reconfigure = ((gl_sink->window_width != width) + gl_sink->window_resized = ((gl_sink->window_width != width) || (gl_sink->window_height != height)) && (gl_sink->window_width != 0) && (gl_sink->window_height != 0); @@ -1893,12 +1902,6 @@ gst_glimage_sink_on_resize (GstGLImageSink * gl_sink, gint width, gint height) gl_sink->window_width = width; gl_sink->window_height = height; - if (reconfigure) { - GST_DEBUG ("Sending reconfigure event on sinkpad."); - gst_pad_push_event (GST_BASE_SINK (gl_sink)->sinkpad, - gst_event_new_reconfigure ()); - } - gst_gl_insert_debug_marker (gl_sink->context, "%s window resize to %ix%i", GST_OBJECT_NAME (gl_sink), width, height); @@ -2119,6 +2122,15 @@ gst_glimage_sink_redisplay (GstGLImageSink * gl_sink) /* Recreate the output texture if needed */ GST_GLIMAGE_SINK_LOCK (gl_sink); + if (gl_sink->window_resized) { + gl_sink->window_resized = FALSE; + GST_GLIMAGE_SINK_UNLOCK (gl_sink); + GST_DEBUG_OBJECT (gl_sink, "Sending reconfigure event on sinkpad."); + gst_pad_push_event (GST_BASE_SINK (gl_sink)->sinkpad, + gst_event_new_reconfigure ()); + GST_GLIMAGE_SINK_LOCK (gl_sink); + } + if (gl_sink->output_mode_changed && gl_sink->input_buffer != NULL) { GST_DEBUG ("Recreating output after mode/size change"); update_output_format (gl_sink); diff --git a/ext/gl/gstglimagesink.h b/ext/gl/gstglimagesink.h index 8f9b2e6..6e9b98e 100644 --- a/ext/gl/gstglimagesink.h +++ b/ext/gl/gstglimagesink.h @@ -102,7 +102,8 @@ struct _GstGLImageSink GstGLSyncMeta *stored_sync_meta; GLuint redisplay_texture; - gboolean caps_change; + /* protected with drawing_lock */ + gboolean window_resized; guint window_width; guint window_height; -- 2.7.4