From b7b2b80de18b5b0b0bcb362d2b825573ecf4c82d Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Tue, 2 Apr 2024 12:27:13 +1100 Subject: [PATCH] glimagesink: avoid a possible critical on shutdown It is possible that the close callback can be called after glimagesink is changing state to NULL. Protect against that by taking the glimagesink lock and some NULL checking. Part-of: --- .../gst-plugins-base/ext/gl/gstglimagesink.c | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/subprojects/gst-plugins-base/ext/gl/gstglimagesink.c b/subprojects/gst-plugins-base/ext/gl/gstglimagesink.c index 74a959b3c1..f0cc3cad90 100644 --- a/subprojects/gst-plugins-base/ext/gl/gstglimagesink.c +++ b/subprojects/gst-plugins-base/ext/gl/gstglimagesink.c @@ -2485,25 +2485,30 @@ gst_glimage_sink_on_draw (GstGLImageSink * gl_sink) static void gst_glimage_sink_on_close (GstGLImageSink * gl_sink) { - GstGLWindow *window; + GstGLWindow *window = NULL; GST_WARNING_OBJECT (gl_sink, "Output window was closed"); - window = gst_gl_context_get_window (gl_sink->context); + GST_GLIMAGE_SINK_LOCK (gl_sink); + if (gl_sink->context) + window = gst_gl_context_get_window (gl_sink->context); + GST_GLIMAGE_SINK_UNLOCK (gl_sink); - if (gl_sink->key_sig_id) - g_signal_handler_disconnect (window, gl_sink->key_sig_id); - gl_sink->key_sig_id = 0; - if (gl_sink->mouse_sig_id) - g_signal_handler_disconnect (window, gl_sink->mouse_sig_id); - gl_sink->mouse_sig_id = 0; - if (gl_sink->mouse_scroll_sig_id) - g_signal_handler_disconnect (window, gl_sink->mouse_scroll_sig_id); - gl_sink->mouse_scroll_sig_id = 0; + if (window) { + if (gl_sink->key_sig_id) + g_signal_handler_disconnect (window, gl_sink->key_sig_id); + gl_sink->key_sig_id = 0; + if (gl_sink->mouse_sig_id) + g_signal_handler_disconnect (window, gl_sink->mouse_sig_id); + gl_sink->mouse_sig_id = 0; + if (gl_sink->mouse_scroll_sig_id) + g_signal_handler_disconnect (window, gl_sink->mouse_scroll_sig_id); + gl_sink->mouse_scroll_sig_id = 0; + + gst_object_unref (window); + } g_atomic_int_set (&gl_sink->to_quit, 1); - - gst_object_unref (window); } static gboolean