Commit a162d689 by christosts Committed by Andrew Lewis

MediaCodecRenderer: do not call protected methods from constructor

MediaCodecRenderer is calling its protected methods
resetCodecStateForRelease() and resetCodecStateForFlush() from its
constructor. Classess that override the methods (eg.
DebugMediaCodecVideoRenderer) need to checks if the methods
are called from the superclass constructor thus their members are not
initialized yet.

With this change, the MCR constructor does not call the two
methods and sets the respective state directly on its fields.

PiperOrigin-RevId: 370445978
parent 3f3d1fb5
......@@ -416,7 +416,17 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
// endianness.
bypassBatchBuffer.ensureSpaceForWrite(/* length= */ 0);
bypassBatchBuffer.data.order(ByteOrder.nativeOrder());
resetCodecStateForRelease();
codecOperatingRate = CODEC_OPERATING_RATE_UNSET;
codecAdaptationWorkaroundMode = ADAPTATION_WORKAROUND_MODE_NEVER;
codecReconfigurationState = RECONFIGURATION_STATE_NONE;
inputIndex = C.INDEX_UNSET;
outputIndex = C.INDEX_UNSET;
codecHotswapDeadlineMs = C.TIME_UNSET;
largestQueuedPresentationTimeUs = C.TIME_UNSET;
lastBufferInStreamPresentationTimeUs = C.TIME_UNSET;
codecDrainState = DRAIN_STATE_NONE;
codecDrainAction = DRAIN_ACTION_NONE;
}
/**
......
......@@ -140,10 +140,7 @@ import java.util.ArrayList;
protected void resetCodecStateForFlush() {
super.resetCodecStateForFlush();
clearTimestamps();
if (inputFormatChangeTimesUs != null) {
inputFormatChangeTimesUs.clear();
}
inputFormatChangeTimesUs.clear();
inputFormatChanged = false;
outputMediaFormatChanged = false;
currentMediaFormat = null;
......
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