Skip to content

Commit a5302be

Browse files
ojw28Oliver Woodman
authored andcommitted
Destroy EGLSurface during DummySurface cleanup
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=168020525
1 parent 09a8c7c commit a5302be

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

‎library/core/src/main/java/com/google/android/exoplayer2/video/DummySurface.java‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import static android.opengl.EGL14.eglCreateContext;
3636
import static android.opengl.EGL14.eglCreatePbufferSurface;
3737
import static android.opengl.EGL14.eglDestroyContext;
38+
import static android.opengl.EGL14.eglDestroySurface;
3839
import static android.opengl.EGL14.eglGetDisplay;
3940
import static android.opengl.EGL14.eglInitialize;
4041
import static android.opengl.EGL14.eglMakeCurrent;
@@ -175,8 +176,9 @@ private static class DummySurfaceThread extends HandlerThread implements OnFrame
175176
private static final int MSG_RELEASE = 3;
176177

177178
private final int[] textureIdHolder;
178-
private EGLContext context;
179179
private EGLDisplay display;
180+
private EGLContext context;
181+
private EGLSurface pbuffer;
180182
private Handler handler;
181183
private SurfaceTexture surfaceTexture;
182184

@@ -315,7 +317,7 @@ private void initInternal(boolean secure) {
315317
EGL_HEIGHT, 1,
316318
EGL_NONE};
317319
}
318-
EGLSurface pbuffer = eglCreatePbufferSurface(display, config, pbufferAttributes, 0);
320+
pbuffer = eglCreatePbufferSurface(display, config, pbufferAttributes, 0);
319321
Assertions.checkState(pbuffer != null, "eglCreatePbufferSurface failed");
320322

321323
boolean eglMadeCurrent = eglMakeCurrent(display, pbuffer, pbuffer, context);
@@ -334,11 +336,15 @@ private void releaseInternal() {
334336
glDeleteTextures(1, textureIdHolder, 0);
335337
}
336338
} finally {
339+
if (pbuffer != null) {
340+
eglDestroySurface(display, pbuffer);
341+
}
337342
if (context != null) {
338343
eglDestroyContext(display, context);
339344
}
340-
display = null;
345+
pbuffer = null;
341346
context = null;
347+
display = null;
342348
surface = null;
343349
surfaceTexture = null;
344350
}

0 commit comments

Comments
 (0)