libs: surface: egl: error message if no extension
authorVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Wed, 4 Oct 2017 11:51:23 +0000 (13:51 +0200)
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Wed, 1 Nov 2017 10:27:36 +0000 (11:27 +0100)
Instead of silently fail to export the image if there is not available
the EGL_MESA_drm_image, log an error message. Also a code refactoring
was done.

https://bugzilla.gnome.org/show_bug.cgi?id=773453

gst-libs/gst/vaapi/gstvaapisurface_egl.c

index 8c13851..8bc42e5 100644 (file)
@@ -55,22 +55,30 @@ do_create_surface_with_egl_image_unlocked (GstVaapiDisplayEGL * display,
   memset (offset, 0, sizeof (offset));
   memset (stride, 0, sizeof (stride));
 
-  if (vtable->has_EGL_MESA_drm_image) {
-    /* EGL_MESA_drm_image extension */
-    if (!vtable->eglExportDRMImageMESA (ctx->display->base.handle.p, image,
-            &name, NULL, &stride[0]))
-      goto error_export_image_gem_buf;
-
-    size = height * stride[0];
-    return gst_vaapi_surface_new_with_gem_buf_handle (base_display, name, size,
-        format, width, height, offset, stride);
-  }
-  return NULL;
+  if (!vtable->has_EGL_MESA_drm_image)
+    goto error_mission_extension;
+
+  /* EGL_MESA_drm_image extension */
+  if (!vtable->eglExportDRMImageMESA (ctx->display->base.handle.p, image,
+          &name, NULL, &stride[0]))
+    goto error_export_image_gem_buf;
+
+  size = height * stride[0];
+  return gst_vaapi_surface_new_with_gem_buf_handle (base_display, name, size,
+      format, width, height, offset, stride);
 
   /* ERRORS */
 error_export_image_gem_buf:
-  GST_ERROR ("failed to export EGL image to GEM buffer");
-  return NULL;
+  {
+    GST_ERROR ("failed to export EGL image to GEM buffer");
+    return NULL;
+  }
+
+error_mission_extension:
+  {
+    GST_ERROR ("missing EGL_MESA_drm_image extension");
+    return NULL;
+  }
 }
 
 static void