mirror of
https://github.com/androidx/media.git
synced 2025-05-18 13:09:56 +08:00
Fix NPE in onInputFormatChanged
PiperOrigin-RevId: 344243929
This commit is contained in:
parent
3aa17bfb9b
commit
1201466b5c
@ -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(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user