summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChun-wei Fan <fanchunwei@src.gnome.org>2023-03-22 13:01:21 +0800
committerChun-wei Fan <fanchunwei@src.gnome.org>2023-03-22 14:55:20 +0800
commit4625b3c8a208aa2aa4a345b47d00ba57484ece38 (patch)
treeaa0540d2ce196da4bb8f10875ebc0cb2a32f11d5
parentc237957ef0a3b6759af45772277ff316212f35d4 (diff)
downloadgtk+-fix-5685.tar.gz
GStreamer Media backend: Pass WGL context ownership back to GdkGLfix-5685
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.
-rw-r--r--modules/media/gtkgstsink.c6
1 files changed, 6 insertions, 0 deletions
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);