From ce629348618a4f6fc36b47ca7c250d3a0e9db991 Mon Sep 17 00:00:00 2001 From: hoangtc Date: Thu, 19 Jul 2018 07:13:34 -0700 Subject: [PATCH] Fix a bug with VideoRendererOutputCapturer when extracting frames of different size Currently, when the VideoRendererOutputCapturer updates output size, it will set the new surface, then release the old surface. This can lead to problem when both surface depends on EGL, since the second release() can release EGL resources of the first surface. This CL reverses this process, and ensures that the old surface is released before the new one is created. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=205235451 --- .../google/android/exoplayer2/util/EGLSurfaceTexture.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/library/core/src/main/java/com/google/android/exoplayer2/util/EGLSurfaceTexture.java b/library/core/src/main/java/com/google/android/exoplayer2/util/EGLSurfaceTexture.java index 5324a0b3da..7e831f0512 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/util/EGLSurfaceTexture.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/util/EGLSurfaceTexture.java @@ -149,6 +149,11 @@ public final class EGLSurfaceTexture implements SurfaceTexture.OnFrameAvailableL if (Util.SDK_INT >= 19) { EGL14.eglReleaseThread(); } + if (display != null && !display.equals(EGL14.EGL_NO_DISPLAY)) { + // Android is unusual in that it uses a reference-counted EGLDisplay. So for + // every eglInitialize() we need an eglTerminate(). + EGL14.eglTerminate(display); + } display = null; context = null; surface = null;