Commit ea764b1b by olly Committed by Oliver Woodman

Fix retry count for live streams in ExtractorMediaPeriod

Also simplify boolean condition in ExtractorMediaSource

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=173247443
parent e5e984f4
......@@ -93,6 +93,7 @@ import java.util.Arrays;
private int[] sampleQueueTrackIds;
private boolean sampleQueuesBuilt;
private boolean prepared;
private int actualMinLoadableRetryCount;
private boolean seenFirstTrackSelection;
private boolean notifyDiscontinuity;
......@@ -160,6 +161,11 @@ import java.util.Arrays;
sampleQueues = new SampleQueue[0];
pendingResetPositionUs = C.TIME_UNSET;
length = C.LENGTH_UNSET;
// Assume on-demand for MIN_RETRY_COUNT_DEFAULT_FOR_MEDIA, until prepared.
actualMinLoadableRetryCount =
minLoadableRetryCount == ExtractorMediaSource.MIN_RETRY_COUNT_DEFAULT_FOR_MEDIA
? ExtractorMediaSource.DEFAULT_MIN_LOADABLE_RETRY_COUNT_ON_DEMAND
: minLoadableRetryCount;
}
public void release() {
......@@ -359,7 +365,7 @@ import java.util.Arrays;
}
/* package */ void maybeThrowError() throws IOException {
loader.maybeThrowError();
loader.maybeThrowError(actualMinLoadableRetryCount);
}
/* package */ int readData(int track, FormatHolder formatHolder, DecoderInputBuffer buffer,
......@@ -491,6 +497,10 @@ import java.util.Arrays;
haveAudioVideoTracks |= isAudioVideo;
}
tracks = new TrackGroupArray(trackArray);
if (minLoadableRetryCount == ExtractorMediaSource.MIN_RETRY_COUNT_DEFAULT_FOR_MEDIA
&& length == C.LENGTH_UNSET && seekMap.getDurationUs() == C.TIME_UNSET) {
actualMinLoadableRetryCount = ExtractorMediaSource.DEFAULT_MIN_LOADABLE_RETRY_COUNT_LIVE;
}
prepared = true;
listener.onSourceInfoRefreshed(durationUs, seekMap.isSeekable());
callback.onPrepared(this);
......@@ -516,16 +526,7 @@ import java.util.Arrays;
pendingResetPositionUs = C.TIME_UNSET;
}
extractedSamplesCountAtStartOfLoad = getExtractedSamplesCount();
int minRetryCount = minLoadableRetryCount;
if (minRetryCount == ExtractorMediaSource.MIN_RETRY_COUNT_DEFAULT_FOR_MEDIA) {
// We assume on-demand before we're prepared.
minRetryCount = !prepared || length != C.LENGTH_UNSET
|| (seekMap != null && seekMap.getDurationUs() != C.TIME_UNSET)
? ExtractorMediaSource.DEFAULT_MIN_LOADABLE_RETRY_COUNT_ON_DEMAND
: ExtractorMediaSource.DEFAULT_MIN_LOADABLE_RETRY_COUNT_LIVE;
}
loader.startLoading(loadable, this, minRetryCount);
loader.startLoading(loadable, this, actualMinLoadableRetryCount);
}
private void configureRetry(ExtractingLoadable loadable) {
......
......@@ -184,8 +184,7 @@ public final class ExtractorMediaSource implements MediaSource, ExtractorMediaPe
public void onSourceInfoRefreshed(long durationUs, boolean isSeekable) {
// If we already have the duration from a previous source info refresh, use it.
durationUs = durationUs == C.TIME_UNSET ? timelineDurationUs : durationUs;
if ((timelineDurationUs == durationUs && timelineIsSeekable == isSeekable)
|| (timelineDurationUs != C.TIME_UNSET && durationUs == C.TIME_UNSET)) {
if (timelineDurationUs == durationUs && timelineIsSeekable == isSeekable) {
// Suppress no-op source info changes.
return;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment