From d25fef5357480af5bee11ed00baa7e2b27616f18 Mon Sep 17 00:00:00 2001 From: Michael Gernoth Date: Sun, 18 Jan 2015 19:29:43 +0100 Subject: Camera2 legacy: retry EGL config without EGL_RECORDABLE_ANDROID Some older blobs don't support EGL_RECORDABLE_ANDROID and return no configuration when this attribute is present. Retry eglChooseConfig without it in this case. This fixes the flashlight for devices affected by this and doesn't break camera-functionality. Change-Id: Ic479231744343567233edaa1cccea7bdaafaa14f --- .../hardware/camera2/legacy/SurfaceTextureRenderer.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'core/java/android/hardware/camera2') diff --git a/core/java/android/hardware/camera2/legacy/SurfaceTextureRenderer.java b/core/java/android/hardware/camera2/legacy/SurfaceTextureRenderer.java index bc80fc1..86eb01d 100644 --- a/core/java/android/hardware/camera2/legacy/SurfaceTextureRenderer.java +++ b/core/java/android/hardware/camera2/legacy/SurfaceTextureRenderer.java @@ -433,6 +433,20 @@ public class SurfaceTextureRenderer { EGL14.eglChooseConfig(mEGLDisplay, attribList, /*offset*/ 0, configs, /*offset*/ 0, configs.length, numConfigs, /*offset*/ 0); checkEglError("eglCreateContext RGB888+recordable ES2"); + if (numConfigs[0] == 0) { + Log.w(TAG, "eglChooseConfig returned no configs, retrying without EGL_RECORDABLE_ANDROID"); + int[] attribList2 = { + EGL14.EGL_RED_SIZE, EGL_COLOR_BITLENGTH, + EGL14.EGL_GREEN_SIZE, EGL_COLOR_BITLENGTH, + EGL14.EGL_BLUE_SIZE, EGL_COLOR_BITLENGTH, + EGL14.EGL_RENDERABLE_TYPE, EGL14.EGL_OPENGL_ES2_BIT, + EGL14.EGL_SURFACE_TYPE, EGL14.EGL_PBUFFER_BIT | EGL14.EGL_WINDOW_BIT, + EGL14.EGL_NONE + }; + EGL14.eglChooseConfig(mEGLDisplay, attribList2, /*offset*/ 0, configs, /*offset*/ 0, + configs.length, numConfigs, /*offset*/ 0); + checkEglError("eglCreateContext RGB888 ES2"); + } mConfigs = configs[0]; int[] attrib_list = { EGL14.EGL_CONTEXT_CLIENT_VERSION, GLES_VERSION, -- cgit v1.1