From 5f64d6df6cf3e62265e3ed29ef9c41cbe6f1b5fa Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Tue, 1 Aug 2017 18:10:50 +0200 Subject: [PATCH] plugins: check gst_gl_ensure_element_data() return value Refactor gst_vaapi_plugin_base_create_gl_context() in order to check the return value of gst_gl_ensure_element_data(). The result is a code bit cleaner. --- gst/vaapi/gstvaapipluginbase.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/gst/vaapi/gstvaapipluginbase.c b/gst/vaapi/gstvaapipluginbase.c index 6a81f37..76d1361 100644 --- a/gst/vaapi/gstvaapipluginbase.c +++ b/gst/vaapi/gstvaapipluginbase.c @@ -1213,16 +1213,14 @@ gst_vaapi_plugin_base_create_gl_context (GstVaapiPluginBase * plugin) GstGLContext *gl_other_context, *gl_context = NULL; GstGLDisplay *gl_display; - gst_gl_ensure_element_data (plugin, (GstGLDisplay **) & plugin->gl_display, - (GstGLContext **) & plugin->gl_other_context); + if (!gst_gl_ensure_element_data (plugin, + (GstGLDisplay **) & plugin->gl_display, + (GstGLContext **) & plugin->gl_other_context)) + goto no_valid_gl_display; gl_display = (GstGLDisplay *) plugin->gl_display; - if (!gl_display || - gst_gl_display_get_handle_type (gl_display) == GST_GL_DISPLAY_TYPE_ANY) { - gst_object_replace (&plugin->gl_display, NULL); - gst_object_replace (&plugin->gl_other_context, NULL); - return NULL; - } + 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"); @@ -1241,6 +1239,14 @@ gst_vaapi_plugin_base_create_gl_context (GstVaapiPluginBase * plugin) GST_OBJECT_UNLOCK (gl_display); return GST_OBJECT_CAST (gl_context); + + /* ERRORS */ +no_valid_gl_display: + { + gst_object_replace (&plugin->gl_display, NULL); + gst_object_replace (&plugin->gl_other_context, NULL); + return NULL; + } #else return NULL; #endif -- 2.7.4