Commit 45dc66ef by olly Committed by Oliver Woodman

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
parent d1631cf8
......@@ -1442,6 +1442,9 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
}
if (codec == null) {
if (!legacyKeepAvailableCodecInfosWithoutCodec()) {
availableCodecInfos = null;
}
maybeInitCodecOrBypass();
return;
}
......@@ -1507,6 +1510,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.
*
* <p>The default implementation is a no-op.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment