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: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6504>
This commit is contained in:
Matthew Waters 2024-04-02 12:27:13 +11:00 committed by GStreamer Marge Bot
parent d9b563e9b2
commit 3f29c897f8

View file

@ -2485,12 +2485,16 @@ gst_glimage_sink_on_draw (GstGLImageSink * gl_sink)
static void static void
gst_glimage_sink_on_close (GstGLImageSink * gl_sink) gst_glimage_sink_on_close (GstGLImageSink * gl_sink)
{ {
GstGLWindow *window; GstGLWindow *window = NULL;
GST_WARNING_OBJECT (gl_sink, "Output window was closed"); GST_WARNING_OBJECT (gl_sink, "Output window was closed");
GST_GLIMAGE_SINK_LOCK (gl_sink);
if (gl_sink->context)
window = gst_gl_context_get_window (gl_sink->context); window = gst_gl_context_get_window (gl_sink->context);
GST_GLIMAGE_SINK_UNLOCK (gl_sink);
if (window) {
if (gl_sink->key_sig_id) if (gl_sink->key_sig_id)
g_signal_handler_disconnect (window, gl_sink->key_sig_id); g_signal_handler_disconnect (window, gl_sink->key_sig_id);
gl_sink->key_sig_id = 0; gl_sink->key_sig_id = 0;
@ -2501,11 +2505,12 @@ gst_glimage_sink_on_close (GstGLImageSink * gl_sink)
g_signal_handler_disconnect (window, gl_sink->mouse_scroll_sig_id); g_signal_handler_disconnect (window, gl_sink->mouse_scroll_sig_id);
gl_sink->mouse_scroll_sig_id = 0; gl_sink->mouse_scroll_sig_id = 0;
g_atomic_int_set (&gl_sink->to_quit, 1);
gst_object_unref (window); gst_object_unref (window);
} }
g_atomic_int_set (&gl_sink->to_quit, 1);
}
static gboolean static gboolean
gst_glimage_sink_redisplay (GstGLImageSink * gl_sink) gst_glimage_sink_redisplay (GstGLImageSink * gl_sink)
{ {