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
This commit is contained in:
olly 2020-09-03 20:35:35 +01:00 committed by Oliver Woodman
parent d1631cf86f
commit 45dc66ef2f

View file

@ -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.
*