From 3d56306c37e29b2b5094d846cb00d255e54895ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Tue, 10 Oct 2017 19:13:35 +0200 Subject: [PATCH] plugins: set GL objects if ensured Only set the GL display and GL other context if they are ensured. https://bugzilla.gnome.org/show_bug.cgi?id=773453 --- gst/vaapi/gstvaapipluginbase.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/gst/vaapi/gstvaapipluginbase.c b/gst/vaapi/gstvaapipluginbase.c index 8318fa3790..dbdf505c8a 100644 --- a/gst/vaapi/gstvaapipluginbase.c +++ b/gst/vaapi/gstvaapipluginbase.c @@ -1219,18 +1219,14 @@ GstObject * gst_vaapi_plugin_base_create_gl_context (GstVaapiPluginBase * plugin) { #if USE_GST_GL_HELPERS - GstGLContext *gl_other_context, *gl_context = NULL; - GstGLDisplay *gl_display; + GstGLContext *gl_other_context = NULL, *gl_context = NULL; + GstGLDisplay *gl_display = NULL; - if (!gst_gl_ensure_element_data (plugin, - (GstGLDisplay **) & plugin->gl_display, - (GstGLContext **) & plugin->gl_other_context)) + if (!gst_gl_ensure_element_data (plugin, &gl_display, &gl_other_context)) goto no_valid_gl_display; - gl_display = (GstGLDisplay *) plugin->gl_display; if (gst_gl_display_get_handle_type (gl_display) == GST_GL_DISPLAY_TYPE_ANY) goto no_valid_gl_display; - gl_other_context = (GstGLContext *) plugin->gl_other_context; GST_INFO_OBJECT (plugin, "creating a new GstGL context"); @@ -1247,6 +1243,8 @@ gst_vaapi_plugin_base_create_gl_context (GstVaapiPluginBase * plugin) } while (!gst_gl_display_add_context (gl_display, gl_context)); GST_OBJECT_UNLOCK (gl_display); + plugin->gl_display = (GstObject *) gl_display; + plugin->gl_other_context = (GstObject *) gl_context; gst_object_replace (&plugin->gl_context, (GstObject *) gl_context); return GST_OBJECT_CAST (gl_context); @@ -1254,8 +1252,8 @@ gst_vaapi_plugin_base_create_gl_context (GstVaapiPluginBase * plugin) /* ERRORS */ no_valid_gl_display: { - gst_object_replace (&plugin->gl_display, NULL); - gst_object_replace (&plugin->gl_other_context, NULL); + gst_object_replace ((GstObject **) & gl_display, NULL); + gst_object_replace ((GstObject **) & gl_other_context, NULL); return NULL; } #else