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 f51869ce43..80d5cc0866 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 @@ -733,11 +733,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer { throws ExoPlaybackException { this.currentPlaybackSpeed = currentPlaybackSpeed; this.targetPlaybackSpeed = targetPlaybackSpeed; - if (codec != null - && codecDrainAction != DRAIN_ACTION_REINITIALIZE - && getState() != STATE_DISABLED) { - updateCodecOperatingRate(codecInputFormat); - } + updateCodecOperatingRate(codecInputFormat); } @Override @@ -1689,6 +1685,17 @@ public abstract class MediaCodecRenderer extends BaseRenderer { return CODEC_OPERATING_RATE_UNSET; } + /** + * Updates the codec operating rate, or triggers codec release and re-initialization if a + * previously set operating rate needs to be cleared. + * + * @throws ExoPlaybackException If an error occurs releasing or initializing a codec. + * @return False if codec release and re-initialization was triggered. True in all other cases. + */ + protected final boolean updateCodecOperatingRate() throws ExoPlaybackException { + return updateCodecOperatingRate(codecInputFormat); + } + /** * Updates the codec operating rate, or triggers codec release and re-initialization if a * previously set operating rate needs to be cleared. @@ -1702,6 +1709,13 @@ public abstract class MediaCodecRenderer extends BaseRenderer { return true; } + if (codec == null + || codecDrainAction == DRAIN_ACTION_REINITIALIZE + || getState() == STATE_DISABLED) { + // No need to update the operating rate. + return true; + } + float newCodecOperatingRate = getCodecOperatingRateV23(targetPlaybackSpeed, format, getStreamFormats()); if (codecOperatingRate == newCodecOperatingRate) {