glimagesink: don't deadlock on resize

Performing any GL function marshalling off the GL thread with glimagesink's
render lock is prone to deadlocks between the GL thread and the non-GL thread.

What can happen is this:
1. non-GL thread attempts to function marshal to the GL thread.
2. while 1 is happening, the winsys gives an event (say resize)
3. This calls back into glimagesink which taks the render lock.
4. As the GL function marshalling is attempting to run on the GL
   and already has glimagesink's render lock locked.  This deadlocks
   as the threads are waiting for each other.
This commit is contained in:
Matthew Waters 2015-12-18 11:49:25 +11:00
parent ae0b8e060e
commit a3ebe19d87

View file

@ -1466,6 +1466,10 @@ gst_glimage_sink_prepare (GstBaseSink * bsink, GstBuffer * buf)
if (!_ensure_gl_setup (glimage_sink))
return GST_FLOW_NOT_NEGOTIATED;
sync_meta = gst_buffer_get_gl_sync_meta (buf);
if (sync_meta)
gst_gl_sync_meta_wait (sync_meta, glimage_sink->context);
GST_GLIMAGE_SINK_LOCK (glimage_sink);
target = &glimage_sink->input_buffer;
if (GST_VIDEO_INFO_MULTIVIEW_MODE (&glimage_sink->in_info) ==
@ -1479,10 +1483,6 @@ gst_glimage_sink_prepare (GstBaseSink * bsink, GstBuffer * buf)
if (glimage_sink->output_mode_changed)
update_output_format (glimage_sink);
sync_meta = gst_buffer_get_gl_sync_meta (buf);
if (sync_meta)
gst_gl_sync_meta_wait (sync_meta, glimage_sink->context);
if (!prepare_next_buffer (glimage_sink)) {
GST_GLIMAGE_SINK_UNLOCK (glimage_sink);
if (old_input)