From d9b563e9b2024669c2cfc5c2626061e5d038ceea Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Tue, 2 Apr 2024 12:25:08 +1100 Subject: [PATCH] glimagesink: unref the potential last ref outside of the glimagesink lock Avoids a deadlock between the state change removing the last ref and the destructer calling the window's on_close handler and trying to take the glimagesink lock. Part-of: --- subprojects/gst-plugins-base/ext/gl/gstglimagesink.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/subprojects/gst-plugins-base/ext/gl/gstglimagesink.c b/subprojects/gst-plugins-base/ext/gl/gstglimagesink.c index dd32d5f178..854c57683b 100644 --- a/subprojects/gst-plugins-base/ext/gl/gstglimagesink.c +++ b/subprojects/gst-plugins-base/ext/gl/gstglimagesink.c @@ -1004,12 +1004,17 @@ gst_glimage_sink_mouse_scroll_event_cb (GstGLWindow * window, static void _set_context (GstGLImageSink * gl_sink, GstGLContext * context) { - GST_GLIMAGE_SINK_LOCK (gl_sink); - if (gl_sink->context) - gst_object_unref (gl_sink->context); + GstGLContext *old_context; + GST_GLIMAGE_SINK_LOCK (gl_sink); + + old_context = gl_sink->context; gl_sink->context = context; + GST_GLIMAGE_SINK_UNLOCK (gl_sink); + + if (old_context) + gst_object_unref (old_context); } static void