From 4acdc8d0b7363be550ebb88874fe4a399516c42c Mon Sep 17 00:00:00 2001 From: andrewlewis Date: Tue, 29 Jan 2019 16:19:39 +0000 Subject: [PATCH] Fix buffered position when loading has not completed If there is data after the last samples in the container, we may request continue loading after the last samples have been read but before the load has completed. In this situation the buffered position is returned as Long.MAX_VALUE, which prevents continuing loading, yet the media period is not treated as fully buffered because its buffered position is not C.TIME_END_OF_SOURCE. PiperOrigin-RevId: 231406964 --- .../android/exoplayer2/source/ExtractorMediaPeriod.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/ExtractorMediaPeriod.java b/library/core/src/main/java/com/google/android/exoplayer2/source/ExtractorMediaPeriod.java index 823901af2a..76a5428a12 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/ExtractorMediaPeriod.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/ExtractorMediaPeriod.java @@ -346,10 +346,9 @@ import org.checkerframework.checker.nullness.compatqual.NullableType; } else if (isPendingReset()) { return pendingResetPositionUs; } - long largestQueuedTimestampUs = C.TIME_UNSET; + long largestQueuedTimestampUs = Long.MAX_VALUE; if (haveAudioVideoTracks) { // Ignore non-AV tracks, which may be sparse or poorly interleaved. - largestQueuedTimestampUs = Long.MAX_VALUE; int trackCount = sampleQueues.length; for (int i = 0; i < trackCount; i++) { if (trackIsAudioVideoFlags[i] && !sampleQueues[i].isLastSampleQueued()) { @@ -358,7 +357,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType; } } } - if (largestQueuedTimestampUs == C.TIME_UNSET) { + if (largestQueuedTimestampUs == Long.MAX_VALUE) { largestQueuedTimestampUs = getLargestQueuedTimestampUs(); } return largestQueuedTimestampUs == Long.MIN_VALUE ? lastSeekPositionUs