eglglessink: Instrument EGL error reporting

This commit is contained in:
Reynaldo H. Verdejo Pinochet 2012-09-11 13:51:25 -03:00 committed by Sebastian Dröge
parent b8c83f98b7
commit 1d77bf6c0f

View file

@ -243,6 +243,7 @@ static gboolean gst_eglglessink_setup_vbo (GstEglGlesSink * eglglessink,
static GstFlowReturn gst_eglglessink_render_and_display (GstEglGlesSink * sink, static GstFlowReturn gst_eglglessink_render_and_display (GstEglGlesSink * sink,
GstBuffer * buf); GstBuffer * buf);
static inline gboolean got_gl_error (const char *wtf); static inline gboolean got_gl_error (const char *wtf);
static inline void show_egl_error (const char *wtf);
static GstBufferClass *gsteglglessink_buffer_parent_class = NULL; static GstBufferClass *gsteglglessink_buffer_parent_class = NULL;
#define GST_TYPE_EGLGLESBUFFER (gst_eglglesbuffer_get_type()) #define GST_TYPE_EGLGLESBUFFER (gst_eglglesbuffer_get_type())
@ -271,17 +272,20 @@ GST_BOILERPLATE_FULL (GstEglGlesSink, gst_eglglessink, GstVideoSink,
pix_surface = eglCreatePixmapSurface (display, config, pix, egl_attribs); pix_surface = eglCreatePixmapSurface (display, config, pix, egl_attribs);
if (pix_surface == EGL_NO_SURFACE) { if (pix_surface == EGL_NO_SURFACE) {
show_egl_error ("eglCreatePixmapSurface");
GST_CAT_ERROR (GST_CAT_DEFAULT, "Unable to create pixmap surface"); GST_CAT_ERROR (GST_CAT_DEFAULT, "Unable to create pixmap surface");
goto EGL_ERROR; goto EGL_ERROR;
} }
if (my_eglLockSurfaceKHR (display, pix_surface, lock_attribs) == EGL_FALSE) { if (my_eglLockSurfaceKHR (display, pix_surface, lock_attribs) == EGL_FALSE) {
show_egl_error ("eglLockSurfaceKHR");
GST_CAT_ERROR (GST_CAT_DEFAULT, "Unable to lock surface"); GST_CAT_ERROR (GST_CAT_DEFAULT, "Unable to lock surface");
goto EGL_ERROR; goto EGL_ERROR;
} }
if (eglQuerySurface (display, pix_surface, EGL_BITMAP_POINTER_KHR, buffer) if (eglQuerySurface (display, pix_surface, EGL_BITMAP_POINTER_KHR, buffer)
== EGL_FALSE) { == EGL_FALSE) {
show_egl_error ("eglQuerySurface");
GST_CAT_ERROR (GST_CAT_DEFAULT, GST_CAT_ERROR (GST_CAT_DEFAULT,
"Unable to query surface for bitmap pointer"); "Unable to query surface for bitmap pointer");
goto EGL_ERROR_LOCKED; goto EGL_ERROR_LOCKED;
@ -294,9 +298,8 @@ EGL_ERROR_LOCKED:
EGL_ERROR: EGL_ERROR:
GST_CAT_ERROR (GST_CAT_DEFAULT, "EGL call returned error %x", eglGetError ()); GST_CAT_ERROR (GST_CAT_DEFAULT, "EGL call returned error %x", eglGetError ());
if (!eglDestroySurface (display, pix_surface)) { if (!eglDestroySurface (display, pix_surface)) {
show_egl_error ("eglDestroySurface");
GST_CAT_ERROR (GST_CAT_DEFAULT, "Couldn't destroy surface"); GST_CAT_ERROR (GST_CAT_DEFAULT, "Couldn't destroy surface");
GST_CAT_ERROR (GST_CAT_DEFAULT, "EGL call returned error %x",
eglGetError ());
} }
return NULL; return NULL;
} }
@ -823,10 +826,18 @@ got_gl_error (const char *wtf)
GST_CAT_ERROR (GST_CAT_DEFAULT, "GL ERROR: %s returned %x", wtf, error); GST_CAT_ERROR (GST_CAT_DEFAULT, "GL ERROR: %s returned %x", wtf, error);
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
} }
static inline void
show_egl_error (const char *wtf)
{
EGLint error;
if ((error = eglGetError ()) != EGL_SUCCESS)
GST_CAT_DEBUG (GST_CAT_DEFAULT, "EGL ERROR: %s returned %x", wtf, error);
}
static EGLNativeWindowType static EGLNativeWindowType
gst_eglglessink_create_window (GstEglGlesSink * eglglessink, gint width, gst_eglglessink_create_window (GstEglGlesSink * eglglessink, gint width,
gint height) gint height)
@ -1007,7 +1018,10 @@ gst_eglglessink_setup_vbo (GstEglGlesSink * eglglessink, gboolean reset)
glVertexAttribPointer (0, 3, GL_FLOAT, GL_FALSE, 0, 0); glVertexAttribPointer (0, 3, GL_FLOAT, GL_FALSE, 0, 0);
if (got_gl_error ("glVertexAttribPointer")) if (got_gl_error ("glVertexAttribPointer"))
goto HANDLE_ERROR_LOCKED; goto HANDLE_ERROR_LOCKED;
glEnableVertexAttribArray (0); glEnableVertexAttribArray (0);
if (got_gl_error ("glEnableVertexAttribArray"))
goto HANDLE_ERROR_LOCKED;
glBindBuffer (GL_ELEMENT_ARRAY_BUFFER, eglglessink->idata); glBindBuffer (GL_ELEMENT_ARRAY_BUFFER, eglglessink->idata);
if (got_gl_error ("glBindBuffer idata")) if (got_gl_error ("glBindBuffer idata"))
@ -1046,14 +1060,15 @@ gst_eglglessink_init_egl_surface (GstEglGlesSink * eglglessink)
eglglessink->config, eglglessink->window, NULL); eglglessink->config, eglglessink->window, NULL);
if (eglglessink->surface == EGL_NO_SURFACE) { if (eglglessink->surface == EGL_NO_SURFACE) {
GST_ERROR_OBJECT (eglglessink, "Can't create surface, eglCreateSurface"); show_egl_error ("eglCreateWindowSurface");
GST_ERROR_OBJECT (eglglessink, "Can't create surface");
goto HANDLE_EGL_ERROR_LOCKED; goto HANDLE_EGL_ERROR_LOCKED;
} }
if (!eglMakeCurrent (eglglessink->display, eglglessink->surface, if (!eglMakeCurrent (eglglessink->display, eglglessink->surface,
eglglessink->surface, eglglessink->context)) { eglglessink->surface, eglglessink->context)) {
GST_ERROR_OBJECT (eglglessink, "Couldn't bind surface/context, " show_egl_error ("eglCreateWindowSurface");
"eglMakeCurrent"); GST_ERROR_OBJECT (eglglessink, "Couldn't bind surface/context");
goto HANDLE_EGL_ERROR_LOCKED; goto HANDLE_EGL_ERROR_LOCKED;
} }
@ -1157,8 +1172,8 @@ gst_eglglessink_init_egl_display (GstEglGlesSink * eglglessink)
goto HANDLE_ERROR; /* No EGL error is set by eglGetDisplay() */ goto HANDLE_ERROR; /* No EGL error is set by eglGetDisplay() */
} }
if (eglInitialize (eglglessink->display, &egl_major, &egl_minor) if (!eglInitialize (eglglessink->display, &egl_major, &egl_minor)) {
== EGL_FALSE) { show_egl_error ("eglInitialize");
GST_ERROR_OBJECT (eglglessink, "Could not init EGL display connection"); GST_ERROR_OBJECT (eglglessink, "Could not init EGL display connection");
goto HANDLE_EGL_ERROR; goto HANDLE_EGL_ERROR;
} }
@ -1175,7 +1190,8 @@ gst_eglglessink_init_egl_display (GstEglGlesSink * eglglessink)
if (!eglChooseConfig (eglglessink->display, eglglessink_RGB16_config, if (!eglChooseConfig (eglglessink->display, eglglessink_RGB16_config,
&eglglessink->config, 1, &egl_configs)) { &eglglessink->config, 1, &egl_configs)) {
GST_ERROR_OBJECT (eglglessink, "eglChooseConfig failed"); show_egl_error ("eglChooseConfig");
GST_ERROR_OBJECT (eglglessink, "Could not choose EGL config");
goto HANDLE_EGL_ERROR; goto HANDLE_EGL_ERROR;
} }