From 4625b3c8a208aa2aa4a345b47d00ba57484ece38 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Wed, 22 Mar 2023 13:01:21 +0800 Subject: GStreamer Media backend: Pass WGL context ownership back to GdkGL We have no good way to know whether GStreamer is able to playback the file that was fed into it, and when it couldn't (for instance, the installed plugins cannot support decoding the file format), the control of the underlying WGL context is in the GstGL's thread, not GTK's own thread. As a result, we can't just do GdkGLContext calls directly in such scenarios, otherwise the program crashes as the function pointers held by libepoxy (used by GdkGLContext) are rendered invalid. So, to be safe, if OpenGL (WGL) is used, call epoxy_handle_external_wglMakeCurrent() upon sink disposal. Fixes issue #5685. --- modules/media/gtkgstsink.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/media/gtkgstsink.c b/modules/media/gtkgstsink.c index 0e3e29b9f7..49a4e61dc8 100644 --- a/modules/media/gtkgstsink.c +++ b/modules/media/gtkgstsink.c @@ -677,6 +677,12 @@ gtk_gst_sink_dispose (GObject *object) { GtkGstSink *self = GTK_GST_SINK (object); +#if GST_GL_HAVE_WINDOW_WIN32 && (GST_GL_HAVE_PLATFORM_WGL || GST_GL_HAVE_PLATFORM_EGL) && defined (GDK_WINDOWING_WIN32) + /* Windows: Tell libepoxy that we are going back to the GdkGLContext now */ + if (self->gdk_context != NULL) + handle_wgl_makecurrent (self->gdk_context); +#endif + g_clear_object (&self->paintable); g_clear_object (&self->gst_gdk_context); g_clear_object (&self->gst_display); -- cgit v1.2.1