Fix playback of media with >1MB preparation data

Also clarify when getNextLoadPositionUs and continueLoading
can be called.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=142124497
This commit is contained in:
olly 2016-12-15 03:31:18 -08:00 committed by Oliver Woodman
parent 37317520f4
commit 2c3ce7fee3
3 changed files with 32 additions and 5 deletions

View file

@ -676,6 +676,7 @@ import java.io.IOException;
standaloneMediaClock.stop();
rendererMediaClock = null;
rendererMediaClockSource = null;
rendererPositionUs = RENDERER_TIMESTAMP_OFFSET_US;
for (Renderer renderer : enabledRenderers) {
try {
ensureStopped(renderer);
@ -823,9 +824,6 @@ import java.io.IOException;
}
private boolean haveSufficientBuffer(boolean rebuffering) {
if (loadingPeriodHolder == null) {
return false;
}
long loadingPeriodBufferedPositionUs = !loadingPeriodHolder.prepared
? loadingPeriodHolder.startPositionUs
: loadingPeriodHolder.mediaPeriod.getBufferedPositionUs();
@ -1287,7 +1285,8 @@ import java.io.IOException;
}
private void maybeContinueLoading() {
long nextLoadPositionUs = loadingPeriodHolder.mediaPeriod.getNextLoadPositionUs();
long nextLoadPositionUs = !loadingPeriodHolder.prepared ? 0
: loadingPeriodHolder.mediaPeriod.getNextLoadPositionUs();
if (nextLoadPositionUs == C.TIME_END_OF_SOURCE) {
setIsLoading(false);
} else {

View file

@ -244,7 +244,7 @@ import java.io.IOException;
@Override
public long getNextLoadPositionUs() {
return getBufferedPositionUs();
return enabledTrackCount == 0 ? C.TIME_END_OF_SOURCE : getBufferedPositionUs();
}
@Override

View file

@ -133,4 +133,32 @@ public interface MediaPeriod extends SequenceableLoader {
*/
long seekToUs(long positionUs);
// SequenceableLoader interface. Overridden to provide more specific documentation.
/**
* Returns the next load time, or {@link C#TIME_END_OF_SOURCE} if loading has finished.
* <p>
* This method should only be called after the period has been prepared. It may be called when no
* tracks are selected.
*/
@Override
long getNextLoadPositionUs();
/**
* Attempts to continue loading.
* <p>
* This method may be called both during and after the period has been prepared.
* <p>
* A period may call {@link Callback#onContinueLoadingRequested(SequenceableLoader)} on the
* {@link Callback} passed to {@link #prepare(Callback)} to request that this method be called
* when the period is permitted to continue loading data. A period may do this both during and
* after preparation.
*
* @param positionUs The current playback position.
* @return True if progress was made, meaning that {@link #getNextLoadPositionUs()} will return
* a different value than prior to the call. False otherwise.
*/
@Override
boolean continueLoading(long positionUs);
}