From ff712aead598515a6c9d47bf3050f185c226774c Mon Sep 17 00:00:00 2001 From: aquilescanta Date: Thu, 13 Oct 2016 04:40:44 -0700 Subject: [PATCH] Try not adapting before failing with BehindLiveWindowException in Hls Issue:#1782 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=136025847 --- .../exoplayer2/source/hls/HlsChunkSource.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/library/src/main/java/com/google/android/exoplayer2/source/hls/HlsChunkSource.java b/library/src/main/java/com/google/android/exoplayer2/source/hls/HlsChunkSource.java index 6dade6a02f..53d9e70d76 100644 --- a/library/src/main/java/com/google/android/exoplayer2/source/hls/HlsChunkSource.java +++ b/library/src/main/java/com/google/android/exoplayer2/source/hls/HlsChunkSource.java @@ -257,8 +257,16 @@ import java.util.Locale; chunkMediaSequence = getLiveNextChunkSequenceNumber(previous.chunkIndex, oldVariantIndex, newVariantIndex); if (chunkMediaSequence < mediaPlaylist.mediaSequence) { - fatalError = new BehindLiveWindowException(); - return; + // We try getting the next chunk without adapting in case that's the reason for falling + // behind the live window. + newVariantIndex = oldVariantIndex; + mediaPlaylist = variantPlaylists[newVariantIndex]; + chunkMediaSequence = getLiveNextChunkSequenceNumber(previous.chunkIndex, oldVariantIndex, + newVariantIndex); + if (chunkMediaSequence < mediaPlaylist.mediaSequence) { + fatalError = new BehindLiveWindowException(); + return; + } } } } else {