diff options
author | Reynaldo H. Verdejo Pinochet <reynaldo@collabora.com> | 2012-09-13 00:11:49 -0300 |
---|---|---|
committer | Reynaldo H. Verdejo Pinochet <reynaldo@collabora.com> | 2012-09-13 00:17:28 -0300 |
commit | fdf97274b605d8e4b7be2c46d236e3fcbf8bbf79 (patch) | |
tree | 90c2b173ad109e2ede8e89ca0b029fe04574520b | |
parent | c54488c11b2a3e33df22b0be6e1c227c97d09242 (diff) |
Caps nego EGL fixes
- Fix alloc lol on format list: Asked for 2 slices and used 3.
- Reordered display & context init logic to prepare for actual
config checking before claiming support for a given format.
Change deals basically with setting up EGL display at start()
and choose an EGL config only at setcaps time.
-rw-r--r-- | ext/eglgles/gsteglglessink.c | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/ext/eglgles/gsteglglessink.c b/ext/eglgles/gsteglglessink.c index 9a5e76278..b8acd2fe5 100644 --- a/ext/eglgles/gsteglglessink.c +++ b/ext/eglgles/gsteglglessink.c @@ -263,6 +263,7 @@ static EGLint *gst_eglglesbuffer_create_native (EGLNativeWindowType win, static EGLNativeWindowType gst_eglglessink_create_window (GstEglGlesSink * eglglessink, gint width, gint height); static gboolean gst_eglglessink_init_egl_display (GstEglGlesSink * eglglessink); +static gboolean gst_eglglessink_choose_config (GstEglGlesSink * eglglessink); static gboolean gst_eglglessink_init_egl_surface (GstEglGlesSink * eglglessink); static void gst_eglglessink_init_egl_exts (GstEglGlesSink * eglglessink); static gboolean gst_eglglessink_setup_vbo (GstEglGlesSink * eglglessink, @@ -514,10 +515,6 @@ gst_eglglesbuffer_get_type (void) } -/* This function is sort of meaningless right now as we - * Only Support one image format / caps but was left here - * as a reference for future improvements. - */ static gint gst_eglglessink_get_compat_format_from_caps (GstEglGlesSink * eglglessink, GstCaps * caps) @@ -787,8 +784,12 @@ gst_eglglessink_start (GstBaseSink * sink) goto HANDLE_ERROR; } + if (!gst_eglglessink_init_egl_display (eglglessink)) { + GST_ERROR_OBJECT (eglglessink, "Couldn't init EGL display"); + goto HANDLE_ERROR; + } /* Init supported format/caps list */ - format = g_new0 (GstEglGlesImageFmt, 2); + format = g_new0 (GstEglGlesImageFmt, 3); format->fmt = GST_EGLGLESSINK_IMAGE_RGB888; format->eglcfg = eglglessink_RGB888_config; @@ -1212,11 +1213,8 @@ HANDLE_ERROR: static gboolean gst_eglglessink_init_egl_display (GstEglGlesSink * eglglessink) { - GLint egl_configs; EGLint egl_major, egl_minor; - EGLint con_attribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE }; - GST_DEBUG_OBJECT (eglglessink, "Enter EGL initial configuration"); eglglessink->display = eglGetDisplay (EGL_DEFAULT_DISPLAY); @@ -1241,6 +1239,24 @@ gst_eglglessink_init_egl_display (GstEglGlesSink * eglglessink) GST_INFO_OBJECT (eglglessink, "System reports supported EGL version v%d.%d", egl_major, egl_minor); + eglBindAPI (EGL_OPENGL_ES_API); + + return TRUE; + + /* Errors */ +HANDLE_EGL_ERROR: + GST_ERROR_OBJECT (eglglessink, "EGL call returned error %x", eglGetError ()); +HANDLE_ERROR: + GST_ERROR_OBJECT (eglglessink, "Couldn't setup window/surface from handle"); + return FALSE; +} + +static gboolean +gst_eglglessink_choose_config (GstEglGlesSink * eglglessink) +{ + EGLint con_attribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE }; + GLint egl_configs; + if (!eglChooseConfig (eglglessink->display, eglglessink->selected_fmt->eglcfg, &eglglessink->config, 1, &egl_configs)) { show_egl_error ("eglChooseConfig"); @@ -1248,8 +1264,6 @@ gst_eglglessink_init_egl_display (GstEglGlesSink * eglglessink) goto HANDLE_EGL_ERROR; } - eglBindAPI (EGL_OPENGL_ES_API); - eglglessink->context = eglCreateContext (eglglessink->display, eglglessink->config, EGL_NO_CONTEXT, con_attribs); @@ -1265,8 +1279,7 @@ gst_eglglessink_init_egl_display (GstEglGlesSink * eglglessink) /* Errors */ HANDLE_EGL_ERROR: GST_ERROR_OBJECT (eglglessink, "EGL call returned error %x", eglGetError ()); -HANDLE_ERROR: - GST_ERROR_OBJECT (eglglessink, "Couldn't setup window/surface from handle"); + GST_ERROR_OBJECT (eglglessink, "Couldn't choose config"); return FALSE; } @@ -1497,8 +1510,8 @@ gst_eglglessink_setcaps (GstBaseSink * bsink, GstCaps * caps) } } - if (!gst_eglglessink_init_egl_display (eglglessink)) { - GST_ERROR_OBJECT (eglglessink, "Couldn't init EGL display"); + if (!gst_eglglessink_choose_config (eglglessink)) { + GST_ERROR_OBJECT (eglglessink, "Couldn't choose EGL config"); goto HANDLE_ERROR; } |