Commit a100175b by andrewlewis Committed by Oliver Woodman

Rename TrackRenderer.reset to TrackRenderer.onReset.

This allows the TrackRenderer superclass to do things when the renderer is
reset, and makes resetting consistent with other 'events' on renderers.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=123974633
parent ff745ac4
......@@ -326,7 +326,13 @@ public final class LibvpxVideoTrackRenderer extends TrackRenderer {
}
@Override
protected void reset(long positionUs) {
protected void onEnabled(boolean joining) throws ExoPlaybackException {
codecCounters.reset();
eventDispatcher.enabled(codecCounters);
}
@Override
protected void onReset(long positionUs) {
inputStreamEnded = false;
outputStreamEnded = false;
renderedFirstFrame = false;
......@@ -337,12 +343,6 @@ public final class LibvpxVideoTrackRenderer extends TrackRenderer {
}
@Override
protected void onEnabled(boolean joining) throws ExoPlaybackException {
codecCounters.reset();
eventDispatcher.enabled(codecCounters);
}
@Override
protected void onStarted() {
droppedFrameCount = 0;
droppedFrameAccumulationStartTimeMs = SystemClock.elapsedRealtime();
......
......@@ -262,6 +262,14 @@ public class MediaCodecAudioTrackRenderer extends MediaCodecTrackRenderer implem
}
@Override
protected void onReset(long positionUs) throws ExoPlaybackException {
super.onReset(positionUs);
audioTrack.reset();
currentPositionUs = positionUs;
allowPositionDiscontinuity = true;
}
@Override
protected void onStarted() {
super.onStarted();
audioTrack.play();
......@@ -306,14 +314,6 @@ public class MediaCodecAudioTrackRenderer extends MediaCodecTrackRenderer implem
}
@Override
protected void reset(long positionUs) throws ExoPlaybackException {
super.reset(positionUs);
audioTrack.reset();
currentPositionUs = positionUs;
allowPositionDiscontinuity = true;
}
@Override
protected boolean processOutputBuffer(long positionUs, long elapsedRealtimeUs, MediaCodec codec,
ByteBuffer buffer, int bufferIndex, int bufferFlags, long bufferPresentationTimeUs,
boolean shouldSkip) throws ExoPlaybackException {
......
......@@ -341,6 +341,15 @@ public abstract class MediaCodecTrackRenderer extends TrackRenderer {
}
@Override
protected void onReset(long positionUs) throws ExoPlaybackException {
inputStreamEnded = false;
outputStreamEnded = false;
if (codec != null) {
flushCodec();
}
}
@Override
protected void onDisabled() {
format = null;
try {
......@@ -392,15 +401,6 @@ public abstract class MediaCodecTrackRenderer extends TrackRenderer {
}
@Override
protected void reset(long positionUs) throws ExoPlaybackException {
inputStreamEnded = false;
outputStreamEnded = false;
if (codec != null) {
flushCodec();
}
}
@Override
protected void onStarted() {
// Do nothing. Overridden to remove throws clause.
}
......
......@@ -236,8 +236,8 @@ public class MediaCodecVideoTrackRenderer extends MediaCodecTrackRenderer {
}
@Override
protected void reset(long positionUs) throws ExoPlaybackException {
super.reset(positionUs);
protected void onReset(long positionUs) throws ExoPlaybackException {
super.onReset(positionUs);
renderedFirstFrame = false;
consecutiveDroppedFrameCount = 0;
joiningDeadlineMs = -1;
......
......@@ -217,6 +217,28 @@ public abstract class TrackRenderer implements ExoPlayerComponent {
}
/**
* Called when a reset is encountered, and also when the renderer is enabled.
*
* @param positionUs The playback position in microseconds.
* @throws ExoPlaybackException If an error occurs handling the reset.
*/
/* package */ final void reset(long positionUs) throws ExoPlaybackException {
onReset(positionUs);
}
/**
* Called when a reset is encountered, and also when the renderer is enabled.
* <p>
* The default implementation is a no-op.
*
* @param positionUs The playback position in microseconds.
* @throws ExoPlaybackException If an error occurs handling the reset.
*/
protected void onReset(long positionUs) throws ExoPlaybackException {
// Do nothing.
}
/**
* Starts the renderer, meaning that calls to {@link #render(long, long)} will cause media to be
* rendered.
*
......@@ -349,17 +371,6 @@ public abstract class TrackRenderer implements ExoPlayerComponent {
protected abstract int supportsFormat(Format format) throws ExoPlaybackException;
/**
* Invoked when a reset is encountered, and also when the renderer is enabled.
* <p>
* This method may be called when the renderer is in the following states:
* {@link #STATE_ENABLED}, {@link #STATE_STARTED}.
*
* @param positionUs The playback position in microseconds.
* @throws ExoPlaybackException If an error occurs handling the reset.
*/
protected abstract void reset(long positionUs) throws ExoPlaybackException;
/**
* Incrementally renders the {@link TrackStream}.
* <p>
* This method should return quickly, and should not block if the renderer is unable to make
......
......@@ -277,18 +277,6 @@ public abstract class AudioDecoderTrackRenderer extends TrackRenderer implements
return currentPositionUs;
}
@Override
protected void reset(long positionUs) {
audioTrack.reset();
currentPositionUs = positionUs;
allowPositionDiscontinuity = true;
inputStreamEnded = false;
outputStreamEnded = false;
if (decoder != null) {
flushDecoder();
}
}
/**
* Invoked when the audio session id becomes known. Once the id is known it will not change
* (and hence this method will not be invoked again) unless the renderer is disabled and then
......@@ -309,6 +297,18 @@ public abstract class AudioDecoderTrackRenderer extends TrackRenderer implements
}
@Override
protected void onReset(long positionUs) {
audioTrack.reset();
currentPositionUs = positionUs;
allowPositionDiscontinuity = true;
inputStreamEnded = false;
outputStreamEnded = false;
if (decoder != null) {
flushDecoder();
}
}
@Override
protected void onStarted() {
audioTrack.play();
}
......
......@@ -98,7 +98,7 @@ public final class MetadataTrackRenderer<T> extends TrackRenderer implements Cal
}
@Override
protected void reset(long positionUs) {
protected void onReset(long positionUs) {
pendingMetadata = null;
inputStreamEnded = false;
}
......
......@@ -112,7 +112,7 @@ public final class TextTrackRenderer extends TrackRenderer implements Callback {
}
@Override
protected void reset(long positionUs) {
protected void onReset(long positionUs) {
inputStreamEnded = false;
outputStreamEnded = false;
if (subtitle != 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