Commit 3e0bae61 by olly Committed by Oliver Woodman

Minor ExoPlayerImplInternal cleanup

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=130547431
parent 0d2dbb16
...@@ -414,7 +414,7 @@ import java.io.IOException; ...@@ -414,7 +414,7 @@ import java.io.IOException;
if (playingPeriod == null) { if (playingPeriod == null) {
// We're still waiting for the first period to be prepared. // We're still waiting for the first period to be prepared.
maybeThrowPeriodPrepareError(); maybeThrowPeriodPrepareError();
scheduleNextOperation(MSG_DO_SOME_WORK, operationStartTimeMs, PREPARING_SOURCE_INTERVAL_MS); scheduleNextWork(operationStartTimeMs, PREPARING_SOURCE_INTERVAL_MS);
return; return;
} }
...@@ -471,24 +471,25 @@ import java.io.IOException; ...@@ -471,24 +471,25 @@ import java.io.IOException;
} }
} }
handler.removeMessages(MSG_DO_SOME_WORK);
if ((playWhenReady && state == ExoPlayer.STATE_READY) || state == ExoPlayer.STATE_BUFFERING) { if ((playWhenReady && state == ExoPlayer.STATE_READY) || state == ExoPlayer.STATE_BUFFERING) {
scheduleNextOperation(MSG_DO_SOME_WORK, operationStartTimeMs, RENDERING_INTERVAL_MS); scheduleNextWork(operationStartTimeMs, RENDERING_INTERVAL_MS);
} else if (enabledRenderers.length != 0) { } else if (enabledRenderers.length != 0) {
scheduleNextOperation(MSG_DO_SOME_WORK, operationStartTimeMs, IDLE_INTERVAL_MS); scheduleNextWork(operationStartTimeMs, IDLE_INTERVAL_MS);
} else {
handler.removeMessages(MSG_DO_SOME_WORK);
} }
TraceUtil.endSection(); TraceUtil.endSection();
} }
private void scheduleNextOperation(int operationType, long thisOperationStartTimeMs, private void scheduleNextWork(long thisOperationStartTimeMs, long intervalMs) {
long intervalMs) { handler.removeMessages(MSG_DO_SOME_WORK);
long nextOperationStartTimeMs = thisOperationStartTimeMs + intervalMs; long nextOperationStartTimeMs = thisOperationStartTimeMs + intervalMs;
long nextOperationDelayMs = nextOperationStartTimeMs - SystemClock.elapsedRealtime(); long nextOperationDelayMs = nextOperationStartTimeMs - SystemClock.elapsedRealtime();
if (nextOperationDelayMs <= 0) { if (nextOperationDelayMs <= 0) {
handler.sendEmptyMessage(operationType); handler.sendEmptyMessage(MSG_DO_SOME_WORK);
} else { } else {
handler.sendEmptyMessageDelayed(operationType, nextOperationDelayMs); handler.sendEmptyMessageDelayed(MSG_DO_SOME_WORK, nextOperationDelayMs);
} }
} }
...@@ -758,7 +759,7 @@ import java.io.IOException; ...@@ -758,7 +759,7 @@ import java.io.IOException;
handler.sendEmptyMessage(MSG_DO_SOME_WORK); handler.sendEmptyMessage(MSG_DO_SOME_WORK);
} }
public boolean haveSufficientBuffer(boolean rebuffering) { private boolean haveSufficientBuffer(boolean rebuffering) {
if (loadingPeriod == null) { if (loadingPeriod == null) {
return false; return false;
} }
...@@ -774,7 +775,7 @@ import java.io.IOException; ...@@ -774,7 +775,7 @@ import java.io.IOException;
return loadControl.shouldStartPlayback(bufferedPositionUs - positionUs, rebuffering); return loadControl.shouldStartPlayback(bufferedPositionUs - positionUs, rebuffering);
} }
public void maybeThrowPeriodPrepareError() throws IOException { private void maybeThrowPeriodPrepareError() throws IOException {
if (loadingPeriod != null && !loadingPeriod.prepared if (loadingPeriod != null && !loadingPeriod.prepared
&& (readingPeriod == null || readingPeriod.nextPeriod == loadingPeriod)) { && (readingPeriod == null || readingPeriod.nextPeriod == loadingPeriod)) {
for (Renderer renderer : enabledRenderers) { for (Renderer renderer : enabledRenderers) {
...@@ -786,7 +787,7 @@ import java.io.IOException; ...@@ -786,7 +787,7 @@ import java.io.IOException;
} }
} }
public void handleSourceInfoRefreshed(Pair<Timeline, Object> timelineAndManifest) private void handleSourceInfoRefreshed(Pair<Timeline, Object> timelineAndManifest)
throws ExoPlaybackException, IOException { throws ExoPlaybackException, IOException {
eventHandler.obtainMessage(MSG_SOURCE_INFO_REFRESHED, timelineAndManifest).sendToTarget(); eventHandler.obtainMessage(MSG_SOURCE_INFO_REFRESHED, timelineAndManifest).sendToTarget();
Timeline oldTimeline = this.timeline; Timeline oldTimeline = this.timeline;
...@@ -893,7 +894,7 @@ import java.io.IOException; ...@@ -893,7 +894,7 @@ import java.io.IOException;
} }
} }
public void updatePeriods() throws ExoPlaybackException, IOException { private void updatePeriods() throws ExoPlaybackException, IOException {
if (timeline == null) { if (timeline == null) {
// We're waiting to get information about periods. // We're waiting to get information about periods.
mediaSource.maybeThrowSourceInfoRefreshError(); mediaSource.maybeThrowSourceInfoRefreshError();
...@@ -1007,7 +1008,7 @@ import java.io.IOException; ...@@ -1007,7 +1008,7 @@ import java.io.IOException;
} }
} }
public void handlePeriodPrepared(MediaPeriod period) throws ExoPlaybackException { private void handlePeriodPrepared(MediaPeriod period) throws ExoPlaybackException {
if (loadingPeriod == null || loadingPeriod.mediaPeriod != period) { if (loadingPeriod == null || loadingPeriod.mediaPeriod != period) {
// Stale event. // Stale event.
return; return;
...@@ -1029,7 +1030,7 @@ import java.io.IOException; ...@@ -1029,7 +1030,7 @@ import java.io.IOException;
maybeContinueLoading(); maybeContinueLoading();
} }
public void handleContinueLoadingRequested(MediaPeriod period) { private void handleContinueLoadingRequested(MediaPeriod period) {
if (loadingPeriod == null || loadingPeriod.mediaPeriod != period) { if (loadingPeriod == null || loadingPeriod.mediaPeriod != period) {
return; return;
} }
......
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