Commit 929ef172 by andrewlewis Committed by Oliver Woodman

Fix handling of removed periods

If a timeline update removed periods at the end of the timeline which
had been buffered, handleSourceInfoRefreshed would call
getNextPeriodIndex and get back -1 for the last period holder in the
new timeline. Then isLastPeriod(-1) could throw.

Fix this behavior so that the remainder of the timeline is discarded.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=156061016
parent f335fb93
...@@ -1016,11 +1016,10 @@ import java.io.IOException; ...@@ -1016,11 +1016,10 @@ import java.io.IOException;
MediaPeriodHolder previousPeriodHolder = periodHolder; MediaPeriodHolder previousPeriodHolder = periodHolder;
periodHolder = periodHolder.next; periodHolder = periodHolder.next;
periodIndex = timeline.getNextPeriodIndex(periodIndex, period, window, repeatMode); periodIndex = timeline.getNextPeriodIndex(periodIndex, period, window, repeatMode);
boolean isLastPeriod = isLastPeriod(periodIndex); if (periodIndex != C.INDEX_UNSET
timeline.getPeriod(periodIndex, period, true); && periodHolder.uid.equals(timeline.getPeriod(periodIndex, period, true).uid)) {
if (periodHolder.uid.equals(period.uid)) {
// The holder is consistent with the new timeline. Update its index and continue. // The holder is consistent with the new timeline. Update its index and continue.
periodHolder.setIndex(periodIndex, isLastPeriod); periodHolder.setIndex(periodIndex, isLastPeriod(periodIndex));
seenReadingPeriod |= (periodHolder == readingPeriodHolder); seenReadingPeriod |= (periodHolder == readingPeriodHolder);
} else { } else {
// The holder is inconsistent with the new timeline. // The holder is inconsistent with the new timeline.
......
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