Commit 23f316d6 by tonihei Committed by Ian Baker

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
parent 0f63c501
...@@ -1014,7 +1014,7 @@ import java.util.concurrent.atomic.AtomicBoolean; ...@@ -1014,7 +1014,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
maybeContinueLoading(); maybeContinueLoading();
} else { } else {
// New period has not been prepared. // New period has not been prepared.
queue.clear(/* keepFrontPeriodUid= */ true); queue.clear();
resetRendererPosition(periodPositionUs); resetRendererPosition(periodPositionUs);
} }
...@@ -1139,7 +1139,7 @@ import java.util.concurrent.atomic.AtomicBoolean; ...@@ -1139,7 +1139,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
} }
} }
queue.clear(/* keepFrontPeriodUid= */ !clearPlaylist); queue.clear();
shouldContinueLoading = false; shouldContinueLoading = false;
Timeline timeline = playbackInfo.timeline; Timeline timeline = playbackInfo.timeline;
if (clearPlaylist) { if (clearPlaylist) {
......
...@@ -256,21 +256,14 @@ import com.google.android.exoplayer2.util.Assertions; ...@@ -256,21 +256,14 @@ import com.google.android.exoplayer2.util.Assertions;
return removedReading; return removedReading;
} }
/** /** Clears the queue. */
* Clears the queue. public void clear() {
*
* @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) {
MediaPeriodHolder front = playing; MediaPeriodHolder front = playing;
if (front != null) { if (front != null) {
oldFrontPeriodUid = keepFrontPeriodUid ? front.uid : null; oldFrontPeriodUid = front.uid;
oldFrontPeriodWindowSequenceNumber = front.info.id.windowSequenceNumber; oldFrontPeriodWindowSequenceNumber = front.info.id.windowSequenceNumber;
removeAfter(front); removeAfter(front);
front.release(); front.release();
} else if (!keepFrontPeriodUid) {
oldFrontPeriodUid = null;
} }
playing = null; playing = null;
loading = null; loading = null;
......
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