@Override public long getBufferedPositionUs() { if (loadingFinished) { return TrackRenderer.END_OF_TRACK_US; } else if (isPendingReset()) { return pendingResetPositionUs; } else { long largestParsedTimestampUs = Long.MIN_VALUE; for (int i = 0; i < sampleQueues.size(); i++) { largestParsedTimestampUs = Math.max(largestParsedTimestampUs, sampleQueues.valueAt(i).getLargestParsedTimestampUs()); } return largestParsedTimestampUs == Long.MIN_VALUE ? downstreamPositionUs : largestParsedTimestampUs; } }
if (onlyReadDiscontinuity || isPendingReset()) { return NOTHING_READ;
@Override public void seekToUs(long positionUs) { Assertions.checkState(prepared); Assertions.checkState(enabledTrackCount > 0); // Treat all seeks into non-seekable media as being to t=0. positionUs = !seekMap.isSeekable() ? 0 : positionUs; long currentPositionUs = isPendingReset() ? pendingResetPositionUs : downstreamPositionUs; downstreamPositionUs = positionUs; lastSeekPositionUs = positionUs; if (currentPositionUs == positionUs) { return; } // If we're not pending a reset, see if we can seek within the sample queues. boolean seekInsideBuffer = !isPendingReset(); for (int i = 0; seekInsideBuffer && i < sampleQueues.size(); i++) { seekInsideBuffer &= sampleQueues.valueAt(i).skipToKeyframeBefore(positionUs); } // If we failed to seek within the sample queues, we need to restart. if (!seekInsideBuffer) { restartFrom(positionUs); } // Either way, we need to send discontinuities to the downstream components. for (int i = 0; i < pendingDiscontinuities.length; i++) { pendingDiscontinuities[i] = true; } }
@Override public boolean continueBuffering(int track, long playbackPositionUs) { Assertions.checkState(prepared); Assertions.checkState(trackEnabledStates[track]); downstreamPositionUs = playbackPositionUs; discardSamplesForDisabledTracks(downstreamPositionUs); if (loadingFinished) { return true; } maybeStartLoading(); if (isPendingReset()) { return false; } return !sampleQueues.valueAt(track).isEmpty(); }
loadable = createLoadableFromStart(); } else { Assertions.checkState(isPendingReset()); if (maxTrackDurationUs != C.UNKNOWN_TIME_US && pendingResetPositionUs >= maxTrackDurationUs) { loadingFinished = true;