diff options
author | Víctor Manuel Jáquez Leal <vjaquez@igalia.com> | 2017-08-01 18:10:50 +0200 |
---|---|---|
committer | Víctor Manuel Jáquez Leal <vjaquez@igalia.com> | 2017-08-24 13:04:22 +0200 |
commit | ee55ffe328a304187a77c3afe3b6b0aa7d370eb1 (patch) | |
tree | 0621dc1e3f9473663aee7514e9b8ec65f0d533a5 | |
parent | c5333ced0065a1322b2d0b294f8dcc3d9da2eeaa (diff) | |
download | gstreamer-vaapi-ee55ffe328a304187a77c3afe3b6b0aa7d370eb1.tar.gz |
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.
-rw-r--r-- | gst/vaapi/gstvaapipluginbase.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/gst/vaapi/gstvaapipluginbase.c b/gst/vaapi/gstvaapipluginbase.c index 8c2b84aa..4f43b6c0 100644 --- a/gst/vaapi/gstvaapipluginbase.c +++ b/gst/vaapi/gstvaapipluginbase.c @@ -1174,16 +1174,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"); @@ -1202,6 +1200,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 |