Fix NPE in onInputFormatChanged

PiperOrigin-RevId: 344243929
This commit is contained in:
olly 2020-11-25 14:43:04 +00:00 committed by Andrew Lewis
parent 3aa17bfb9b
commit 1201466b5c

View File

@ -1408,7 +1408,12 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
// We have an existing codec that we may need to reconfigure, re-initialize, or release to // We have an existing codec that we may need to reconfigure, re-initialize, or release to
// switch to bypass. If the existing codec instance is kept then its operating rate and DRM // switch to bypass. If the existing codec instance is kept then its operating rate and DRM
// session may need to be updated. // session may need to be updated.
MediaCodecAdapter oldCodec = codec;
// Copy the current codec and codecInfo to local variables so they remain accessible if the
// member variables are updated during the logic below.
MediaCodecAdapter codec = this.codec;
MediaCodecInfo codecInfo = this.codecInfo;
Format oldFormat = codecInputFormat; Format oldFormat = codecInputFormat;
if (drmNeedsCodecReinitialization(codecInfo, newFormat, codecDrmSession, sourceDrmSession)) { if (drmNeedsCodecReinitialization(codecInfo, newFormat, codecDrmSession, sourceDrmSession)) {
drainAndReinitializeCodec(); drainAndReinitializeCodec();
@ -1474,7 +1479,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
} }
if (evaluation.result != REUSE_RESULT_NO if (evaluation.result != REUSE_RESULT_NO
&& (codec != oldCodec || codecDrainAction == DRAIN_ACTION_REINITIALIZE)) { && (this.codec != codec || codecDrainAction == DRAIN_ACTION_REINITIALIZE)) {
// Initial evaluation indicated reuse was possible, but codec re-initialization was triggered. // Initial evaluation indicated reuse was possible, but codec re-initialization was triggered.
// The reasons are indicated by overridingDiscardReasons. // The reasons are indicated by overridingDiscardReasons.
return new DecoderReuseEvaluation( return new DecoderReuseEvaluation(