summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2018-04-27 18:24:00 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2018-04-27 18:24:00 +0000
commita973d530df653009168544b3e6aafda442c1367c (patch)
treeb74555f7d25e51594d5f6e15452cb044eddf1116 /core/java
parent6288cf1d35f833e0aff341f63dc412246d033409 (diff)
parentdf34b49fa2920cdc81a94b438c5abbeb9409f320 (diff)
Merge "camera2/legacy: Fix expected errors on eglSwapBuffers" into pi-dev
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/hardware/camera2/legacy/SurfaceTextureRenderer.java30
1 files changed, 24 insertions, 6 deletions
diff --git a/core/java/android/hardware/camera2/legacy/SurfaceTextureRenderer.java b/core/java/android/hardware/camera2/legacy/SurfaceTextureRenderer.java
index a05a8ec00e79..83a02285e720 100644
--- a/core/java/android/hardware/camera2/legacy/SurfaceTextureRenderer.java
+++ b/core/java/android/hardware/camera2/legacy/SurfaceTextureRenderer.java
@@ -529,14 +529,32 @@ public class SurfaceTextureRenderer {
private boolean swapBuffers(EGLSurface surface)
throws LegacyExceptionUtils.BufferQueueAbandonedException {
boolean result = EGL14.eglSwapBuffers(mEGLDisplay, surface);
+
int error = EGL14.eglGetError();
- if (error == EGL14.EGL_BAD_SURFACE) {
- throw new LegacyExceptionUtils.BufferQueueAbandonedException();
- } else if (error != EGL14.EGL_SUCCESS) {
- throw new IllegalStateException("swapBuffers: EGL error: 0x" +
- Integer.toHexString(error));
+ switch (error) {
+ case EGL14.EGL_SUCCESS:
+ return result;
+
+ // Check for an abandoned buffer queue, or other error conditions out
+ // of the user's control.
+ //
+ // From the EGL 1.4 spec (2013-12-04), Section 3.9.4 Posting Errors:
+ //
+ // If eglSwapBuffers is called and the native window associated with
+ // surface is no longer valid, an EGL_BAD_NATIVE_WINDOW error is
+ // generated.
+ //
+ // We also interpret EGL_BAD_SURFACE as indicating an abandoned
+ // surface, even though the EGL spec does not document it as such, for
+ // backwards compatibility with older versions of this file.
+ case EGL14.EGL_BAD_NATIVE_WINDOW:
+ case EGL14.EGL_BAD_SURFACE:
+ throw new LegacyExceptionUtils.BufferQueueAbandonedException();
+
+ default:
+ throw new IllegalStateException(
+ "swapBuffers: EGL error: 0x" + Integer.toHexString(error));
}
- return result;
}
private void checkEglError(String msg) {