Skip to content

Commit

Permalink
Fix buffered position when loading has not completed
Browse files Browse the repository at this point in the history
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
  • Loading branch information
andrewlewis authored and ojw28 committed Jan 30, 2019
1 parent 21e593a commit 4acdc8d
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -346,10 +346,9 @@ public long getBufferedPositionUs() {
} 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()) {
Expand All @@ -358,7 +357,7 @@ public long getBufferedPositionUs() {
}
}
}
if (largestQueuedTimestampUs == C.TIME_UNSET) {
if (largestQueuedTimestampUs == Long.MAX_VALUE) {
largestQueuedTimestampUs = getLargestQueuedTimestampUs();
}
return largestQueuedTimestampUs == Long.MIN_VALUE ? lastSeekPositionUs
Expand Down

0 comments on commit 4acdc8d

Please sign in to comment.