summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVíctor Manuel Jáquez Leal <vjaquez@igalia.com>2017-08-01 18:10:50 +0200
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>2017-08-01 18:10:50 +0200
commit5f64d6df6cf3e62265e3ed29ef9c41cbe6f1b5fa (patch)
treef303b78a06a45d040c666afdb675fed2b5e061cf
parent02e48ad8dc3f31971786addb795d54851ff2360c (diff)
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.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/gst/vaapi/gstvaapipluginbase.c b/gst/vaapi/gstvaapipluginbase.c
index 6a81f371..76d13610 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