From 1abd05dbff2f880586e8713a57e682773c4ef52a Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Tue, 4 Feb 2020 14:01:47 +1100 Subject: [PATCH] glviewconvert: fix reset context for GL context change We need to remove GL resources from the old context instead of the new GL context. The two GL context may not even be shared. --- gst-libs/gst/gl/gstglviewconvert.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/gst-libs/gst/gl/gstglviewconvert.c b/gst-libs/gst/gl/gstglviewconvert.c index d6e6cd9383..aab126f982 100644 --- a/gst-libs/gst/gl/gstglviewconvert.c +++ b/gst-libs/gst/gl/gstglviewconvert.c @@ -358,11 +358,20 @@ void gst_gl_view_convert_set_context (GstGLViewConvert * viewconvert, GstGLContext * context) { + GstGLContext *old_context = NULL; + g_return_if_fail (GST_IS_GL_VIEW_CONVERT (viewconvert)); - if (gst_object_replace ((GstObject **) & viewconvert->context, - GST_OBJECT (context))) + GST_OBJECT_LOCK (viewconvert); + if (context != viewconvert->context) { gst_gl_view_convert_reset (viewconvert); + if (viewconvert->context) + old_context = viewconvert->context; + viewconvert->context = context ? gst_object_ref (context) : NULL; + } + GST_OBJECT_UNLOCK (viewconvert); + + gst_clear_object (&old_context); } static gboolean