From db215ff156a6eb5e434a1b447fff6931b00560d1 Mon Sep 17 00:00:00 2001 From: olly Date: Mon, 5 Dec 2016 04:19:49 -0800 Subject: [PATCH] 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 --- .../main/java/com/google/android/exoplayer2/ExoPlayerImpl.java | 3 --- .../com/google/android/exoplayer2/ExoPlayerImplInternal.java | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/library/src/main/java/com/google/android/exoplayer2/ExoPlayerImpl.java b/library/src/main/java/com/google/android/exoplayer2/ExoPlayerImpl.java index b203bc8fc6..f36ee59f83 100644 --- a/library/src/main/java/com/google/android/exoplayer2/ExoPlayerImpl.java +++ b/library/src/main/java/com/google/android/exoplayer2/ExoPlayerImpl.java @@ -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) { diff --git a/library/src/main/java/com/google/android/exoplayer2/ExoPlayerImplInternal.java b/library/src/main/java/com/google/android/exoplayer2/ExoPlayerImplInternal.java index 9e9cbdf8ca..d666a0423e 100644 --- a/library/src/main/java/com/google/android/exoplayer2/ExoPlayerImplInternal.java +++ b/library/src/main/java/com/google/android/exoplayer2/ExoPlayerImplInternal.java @@ -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 periodPosition = getPeriodPosition(seekTimeline, seekPosition.windowIndex, @@ -1044,6 +1043,7 @@ import java.io.IOException; */ private Pair 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();