From ad6396a3e5e88e7a26158bfb45fc9c7932df1b7f Mon Sep 17 00:00:00 2001 From: hschlueter Date: Mon, 28 Mar 2022 17:17:03 +0100 Subject: [PATCH] Check if there is a current context before generating textures/FBOs. This avoids silent failures where the generated identifiers are 0. PiperOrigin-RevId: 437775689 --- .../java/com/google/android/exoplayer2/util/GlUtil.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/library/common/src/main/java/com/google/android/exoplayer2/util/GlUtil.java b/library/common/src/main/java/com/google/android/exoplayer2/util/GlUtil.java index 372384dc72..0febeb421f 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/util/GlUtil.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/util/GlUtil.java @@ -370,6 +370,9 @@ public final class GlUtil { * GLES11Ext#GL_TEXTURE_EXTERNAL_OES} for an external texture. */ private static int generateAndBindTexture(int textureTarget) { + checkEglException( + !Util.areEqual(EGL14.eglGetCurrentContext(), EGL14.EGL_NO_CONTEXT), "No current context"); + int[] texId = new int[1]; GLES20.glGenTextures(/* n= */ 1, texId, /* offset= */ 0); checkGlError(); @@ -390,6 +393,9 @@ public final class GlUtil { * @param texId The identifier of the texture to attach to the framebuffer. */ public static int createFboForTexture(int texId) { + checkEglException( + !Util.areEqual(EGL14.eglGetCurrentContext(), EGL14.EGL_NO_CONTEXT), "No current context"); + int[] fboId = new int[1]; GLES20.glGenFramebuffers(/* n= */ 1, fboId, /* offset= */ 0); checkGlError();