Fix GL releasing surface that doesn't need releasing

PiperOrigin-RevId: 576545767
This commit is contained in:
claincly 2023-10-25 09:01:55 -07:00 committed by Copybara-Service
parent 1e2815cade
commit 841b4fba9a

View File

@ -16,6 +16,7 @@
package androidx.media3.common.util;
import static android.opengl.EGL14.EGL_CONTEXT_CLIENT_VERSION;
import static android.opengl.EGL14.EGL_NO_SURFACE;
import static android.opengl.GLU.gluErrorString;
import static androidx.media3.common.util.Assertions.checkArgument;
import static androidx.media3.common.util.Assertions.checkState;
@ -873,6 +874,10 @@ public final class GlUtil {
if (eglDisplay == null || eglSurface == null) {
return;
}
if (EGL14.eglGetCurrentSurface(EGL14.EGL_DRAW) == EGL_NO_SURFACE) {
return;
}
EGL14.eglDestroySurface(eglDisplay, eglSurface);
checkEglException("Error destroying surface");
}