Skip to content

Commit

Permalink
Fix missing release calls on loadingPeriodHolder
Browse files Browse the repository at this point in the history
playingPeriodHolder can be null in the case that the first
period is still being prepared. We need to make sure we
release the period that's being prepared in such cases,
which is loadingPeriodHolder.

Issue: #1914

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=135793472
  • Loading branch information
ojw28 committed Oct 11, 2016
1 parent 907b9bf commit 83107cc
Showing 1 changed file with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -538,16 +538,23 @@ private long seekToPeriodPosition(int periodIndex, long periodPositionUs)
periodIndex = C.INDEX_UNSET;
}

// Clear the timeline, but keep the requested period if it is already prepared.
MediaPeriodHolder<T> periodHolder = playingPeriodHolder;
MediaPeriodHolder<T> newPlayingPeriodHolder = null;
while (periodHolder != null) {
if (periodHolder.index == periodIndex && periodHolder.prepared) {
newPlayingPeriodHolder = periodHolder;
} else {
periodHolder.release();
if (playingPeriodHolder == null) {
// We're still waiting for the first period to be prepared.
if (loadingPeriodHolder != null) {
loadingPeriodHolder.release();
}
} else {
// Clear the timeline, but keep the requested period if it is already prepared.
MediaPeriodHolder<T> periodHolder = playingPeriodHolder;
while (periodHolder != null) {
if (periodHolder.index == periodIndex && periodHolder.prepared) {
newPlayingPeriodHolder = periodHolder;
} else {
periodHolder.release();
}
periodHolder = periodHolder.next;
}
periodHolder = periodHolder.next;
}

// Disable all the renderers if the period is changing.
Expand Down Expand Up @@ -892,7 +899,8 @@ private void attemptRestart(Timeline newTimeline, Timeline oldTimeline,
}

// Release all loaded periods.
releasePeriodHoldersFrom(playingPeriodHolder);
releasePeriodHoldersFrom(playingPeriodHolder != null ? playingPeriodHolder
: loadingPeriodHolder);
bufferAheadPeriodCount = 0;
playingPeriodHolder = null;
readingPeriodHolder = null;
Expand Down

0 comments on commit 83107cc

Please sign in to comment.