Always keep front period uid in MediaPeriodQueue.

Since we have the Playlist layer on top, it's always guaranteed that a
new playlist item has a new uid. So we can just keep the old one in all
cases and don't have to be careful to delete it. The deletion was necessary
previously in case multiple MediaSources use the same uids.

PiperOrigin-RevId: 291152349
This commit is contained in:
tonihei 2020-01-23 14:04:21 +00:00 committed by Ian Baker
parent 0f63c501a8
commit 23f316d67e
2 changed files with 5 additions and 12 deletions

View File

@ -1014,7 +1014,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
maybeContinueLoading();
} else {
// New period has not been prepared.
queue.clear(/* keepFrontPeriodUid= */ true);
queue.clear();
resetRendererPosition(periodPositionUs);
}
@ -1139,7 +1139,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
}
}
queue.clear(/* keepFrontPeriodUid= */ !clearPlaylist);
queue.clear();
shouldContinueLoading = false;
Timeline timeline = playbackInfo.timeline;
if (clearPlaylist) {

View File

@ -256,21 +256,14 @@ import com.google.android.exoplayer2.util.Assertions;
return removedReading;
}
/**
* Clears the queue.
*
* @param keepFrontPeriodUid Whether the queue should keep the id of the media period in the front
* of queue (typically the playing one) for later reuse.
*/
public void clear(boolean keepFrontPeriodUid) {
/** Clears the queue. */
public void clear() {
MediaPeriodHolder front = playing;
if (front != null) {
oldFrontPeriodUid = keepFrontPeriodUid ? front.uid : null;
oldFrontPeriodUid = front.uid;
oldFrontPeriodWindowSequenceNumber = front.info.id.windowSequenceNumber;
removeAfter(front);
front.release();
} else if (!keepFrontPeriodUid) {
oldFrontPeriodUid = null;
}
playing = null;
loading = null;