From 1a5d79b78a6e50880f24a04aa0f6840bb6422aea Mon Sep 17 00:00:00 2001 From: bachinger Date: Tue, 1 Dec 2020 12:42:56 +0000 Subject: [PATCH] Schedule load for non-primary playlist for low latency streams Low latency streams potentially need to remove preload chunks in case they are removed from the playlist. Hence we need to schedule loading the next playlist even if the playlist is not a primary playlist. Issue: #5011 PiperOrigin-RevId: 344995891 --- .../hls/playlist/DefaultHlsPlaylistTracker.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/playlist/DefaultHlsPlaylistTracker.java b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/playlist/DefaultHlsPlaylistTracker.java index 9d1ecfe6e4..1b502f3f87 100644 --- a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/playlist/DefaultHlsPlaylistTracker.java +++ b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/playlist/DefaultHlsPlaylistTracker.java @@ -716,10 +716,13 @@ public final class DefaultHlsPlaylistTracker : (playlistSnapshot.targetDurationUs / 2); } earliestNextLoadTimeMs = currentTimeMs + C.usToMs(durationUntilNextLoadUs); - // Schedule a load if this is the primary playlist and it doesn't have an end tag. Else the - // next load will be scheduled when refreshPlaylist is called, or when this playlist becomes - // the primary. - if (playlistUrl.equals(primaryMediaPlaylistUrl) && !playlistSnapshot.hasEndTag) { + // Schedule a load if this is the primary playlist or a playlist of a low-latency stream and + // it doesn't have an end tag. Else the next load will be scheduled when refreshPlaylist is + // called, or when this playlist becomes the primary. + boolean scheduleLoad = + playlistSnapshot.partTargetDurationUs != C.TIME_UNSET + || playlistUrl.equals(primaryMediaPlaylistUrl); + if (scheduleLoad && !playlistSnapshot.hasEndTag) { loadPlaylistInternal(getMediaPlaylistUriForReload()); } }