Make invalid seek positions fail on playback thread only

Seeks are permitted when there's no timeline, and in this
case playback necessarily fails on the playback thread when
the timeline becomes known. Pushing failure to the same
place when the timeline is known means there's only one
failure path for this case. A later CL will likely introduce
an InvalidSeekPositionException for this case.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=141037708
This commit is contained in:
olly 2016-12-05 04:19:49 -08:00 committed by Oliver Woodman
parent 88fc682dde
commit db215ff156
2 changed files with 1 additions and 4 deletions

View File

@ -179,9 +179,6 @@ import java.util.concurrent.CopyOnWriteArraySet;
@Override
public void seekTo(int windowIndex, long positionMs) {
if (windowIndex < 0 || (!timeline.isEmpty() && windowIndex >= timeline.getWindowCount())) {
throw new IndexOutOfBoundsException();
}
pendingSeekAcks++;
maskingWindowIndex = windowIndex;
if (positionMs == C.TIME_UNSET) {

View File

@ -987,7 +987,6 @@ import java.io.IOException;
// The application performed a blind seek without a non-empty timeline (most likely based on
// knowledge of what the future timeline will be). Use the internal timeline.
seekTimeline = timeline;
Assertions.checkIndex(seekPosition.windowIndex, 0, timeline.getWindowCount());
}
// Map the SeekPosition to a position in the corresponding timeline.
Pair<Integer, Long> periodPosition = getPeriodPosition(seekTimeline, seekPosition.windowIndex,
@ -1044,6 +1043,7 @@ import java.io.IOException;
*/
private Pair<Integer, Long> getPeriodPosition(Timeline timeline, int windowIndex,
long windowPositionUs, long defaultPositionProjectionUs) {
Assertions.checkIndex(windowIndex, 0, timeline.getWindowCount());
timeline.getWindow(windowIndex, window, false, defaultPositionProjectionUs);
if (windowPositionUs == C.TIME_UNSET) {
windowPositionUs = window.getDefaultPositionUs();