Commit e03623f7 by tonihei Committed by Oliver Woodman

Fix issue with keeping window sequence number after repeated seeks.

The number is shelved in calls to queue.clear() to keep it for the next
media period. However, the queue may also become empty by repeated calls to
advancePlayingPeriod which may happen when seeking to an unprepared period.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=205376036
parent 9bb64b7e
...@@ -228,11 +228,13 @@ import com.google.android.exoplayer2.util.Assertions; ...@@ -228,11 +228,13 @@ import com.google.android.exoplayer2.util.Assertions;
reading = playing.next; reading = playing.next;
} }
playing.release(); playing.release();
playing = playing.next;
length--; length--;
if (length == 0) { if (length == 0) {
loading = null; loading = null;
oldFrontPeriodUid = playing.uid;
oldFrontPeriodWindowSequenceNumber = playing.info.id.windowSequenceNumber;
} }
playing = playing.next;
} else { } else {
playing = loading; playing = loading;
reading = loading; reading = loading;
......
...@@ -1981,6 +1981,44 @@ public final class ExoPlayerTest { ...@@ -1981,6 +1981,44 @@ public final class ExoPlayerTest {
} }
@Test @Test
public void testRepeatedSeeksToUnpreparedPeriodInSameWindowKeepsWindowSequenceNumber()
throws Exception {
Timeline timeline =
new FakeTimeline(
new TimelineWindowDefinition(
/* periodCount= */ 2,
/* id= */ 0,
/* isSeekable= */ true,
/* isDynamic= */ false,
/* durationUs= */ 10 * C.MICROS_PER_SECOND));
FakeMediaSource mediaSource = new FakeMediaSource(timeline, /* manifest= */ null);
ActionSchedule actionSchedule =
new ActionSchedule.Builder("testSeekToUnpreparedPeriod")
.pause()
.waitForPlaybackState(Player.STATE_READY)
.seek(/* windowIndex= */ 0, /* positionMs= */ 9999)
.seek(/* windowIndex= */ 0, /* positionMs= */ 1)
.seek(/* windowIndex= */ 0, /* positionMs= */ 9999)
.play()
.build();
ExoPlayerTestRunner testRunner =
new ExoPlayerTestRunner.Builder()
.setMediaSource(mediaSource)
.setActionSchedule(actionSchedule)
.build()
.start()
.blockUntilEnded(TIMEOUT_MS);
testRunner.assertPlayedPeriodIndices(0, 1, 0, 1);
assertThat(mediaSource.getCreatedMediaPeriods())
.containsAllOf(
new MediaPeriodId(/* periodIndex= */ 0, /* windowSequenceNumber= */ 0),
new MediaPeriodId(/* periodIndex= */ 1, /* windowSequenceNumber= */ 0));
assertThat(mediaSource.getCreatedMediaPeriods())
.doesNotContain(new MediaPeriodId(/* periodIndex= */ 1, /* windowSequenceNumber= */ 1));
}
@Test
public void testRecursivePlayerChangesReportConsistentValuesForAllListeners() throws Exception { public void testRecursivePlayerChangesReportConsistentValuesForAllListeners() throws Exception {
// We add two listeners to the player. The first stops the player as soon as it's ready and both // We add two listeners to the player. The first stops the player as soon as it's ready and both
// record the state change events they receive. // record the state change events they receive.
......
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