From 45dc66ef2f69254b32c520ee7fb4f324c5374bc1 Mon Sep 17 00:00:00 2001 From: olly Date: Thu, 3 Sep 2020 20:35:35 +0100 Subject: [PATCH] Clear CodecInfos on InputFormat if codec is null In maybeInitCodecWithFallback, it caches availableCodecInfos with mediaCryptoRequiresSecureDecoder and inputFormat as inputs, and won't clear it if shouldInitCodec is false, resulting in a case where availableCodecInfos is not null and codec is null. When we have a new format, it's reasonable to clear availableCodecInfos if codec is null. Otherwise we might not be able to properly initialize a new codec. PiperOrigin-RevId: 329971796 --- .../exoplayer2/mediacodec/MediaCodecRenderer.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java b/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java index 761e101ce0..de3f595976 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java @@ -1442,6 +1442,9 @@ public abstract class MediaCodecRenderer extends BaseRenderer { } if (codec == null) { + if (!legacyKeepAvailableCodecInfosWithoutCodec()) { + availableCodecInfos = null; + } maybeInitCodecOrBypass(); return; } @@ -1506,6 +1509,14 @@ public abstract class MediaCodecRenderer extends BaseRenderer { } } + /** + * Returns whether to keep available codec infos when the codec hasn't been initialized, which is + * the behavior before a bug fix. See also [Internal: b/162837741]. + */ + protected boolean legacyKeepAvailableCodecInfosWithoutCodec() { + return false; + } + /** * Called when one of the output formats changes. *