Clear the timeline on seeking if renderers are reading ahead.

If a renderer is reading ahead of the playing period, seeking within the
playing period would fail, because renderers would not be disabled but then try
to read from SampleStreams that have a released period.

Also, in the same circumstances, seeking within the reading period would fail,
because all renderers would be disabled, but their sample streams have already
been read. When they are reenabled they expect to see a format but don't
receive one.

In both cases, seeking can just clear the timeline. This only occurs in rare
circumstances when the player is reading ahead, so the cost of re-preparing
will not be incurred often, and allows the seeking logic to be simpler.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=129891060
This commit is contained in:
andrewlewis 2016-08-10 11:39:24 -07:00 committed by Oliver Woodman
parent 932574a3cb
commit e883b7c270

View File

@ -556,8 +556,11 @@ import java.util.ArrayList;
rebuffering = false;
setState(ExoPlayer.STATE_BUFFERING);
if (positionUs == C.UNSET_TIME_US) {
// We don't know where to seek to yet, so clear the whole timeline.
if (positionUs == C.UNSET_TIME_US
|| (readingPeriod != playingPeriod && (periodIndex == playingPeriod.index
|| (readingPeriod != null && periodIndex == readingPeriod.index)))) {
// Clear the timeline because either the seek position is not known, or a renderer is reading
// ahead to the next period and the seek is to either the playing or reading period.
periodIndex = Timeline.NO_PERIOD_INDEX;
}