mirror of
https://github.com/androidx/media.git
synced 2025-05-09 16:40:55 +08:00
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:
parent
88fc682dde
commit
db215ff156
@ -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) {
|
||||
|
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user