mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
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.
This commit is contained in:
parent
02e48ad8dc
commit
5f64d6df6c
1 changed files with 14 additions and 8 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue