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; ...@@ -93,6 +93,7 @@ import java.util.Arrays;
private int[] sampleQueueTrackIds; private int[] sampleQueueTrackIds;
private boolean sampleQueuesBuilt; private boolean sampleQueuesBuilt;
private boolean prepared; private boolean prepared;
private int actualMinLoadableRetryCount;
private boolean seenFirstTrackSelection; private boolean seenFirstTrackSelection;
private boolean notifyDiscontinuity; private boolean notifyDiscontinuity;
...@@ -160,6 +161,11 @@ import java.util.Arrays; ...@@ -160,6 +161,11 @@ import java.util.Arrays;
sampleQueues = new SampleQueue[0]; sampleQueues = new SampleQueue[0];
pendingResetPositionUs = C.TIME_UNSET; pendingResetPositionUs = C.TIME_UNSET;
length = C.LENGTH_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() { public void release() {
...@@ -359,7 +365,7 @@ import java.util.Arrays; ...@@ -359,7 +365,7 @@ import java.util.Arrays;
} }
/* package */ void maybeThrowError() throws IOException { /* package */ void maybeThrowError() throws IOException {
loader.maybeThrowError(); loader.maybeThrowError(actualMinLoadableRetryCount);
} }
/* package */ int readData(int track, FormatHolder formatHolder, DecoderInputBuffer buffer, /* package */ int readData(int track, FormatHolder formatHolder, DecoderInputBuffer buffer,
...@@ -491,6 +497,10 @@ import java.util.Arrays; ...@@ -491,6 +497,10 @@ import java.util.Arrays;
haveAudioVideoTracks |= isAudioVideo; haveAudioVideoTracks |= isAudioVideo;
} }
tracks = new TrackGroupArray(trackArray); 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; prepared = true;
listener.onSourceInfoRefreshed(durationUs, seekMap.isSeekable()); listener.onSourceInfoRefreshed(durationUs, seekMap.isSeekable());
callback.onPrepared(this); callback.onPrepared(this);
...@@ -516,16 +526,7 @@ import java.util.Arrays; ...@@ -516,16 +526,7 @@ import java.util.Arrays;
pendingResetPositionUs = C.TIME_UNSET; pendingResetPositionUs = C.TIME_UNSET;
} }
extractedSamplesCountAtStartOfLoad = getExtractedSamplesCount(); extractedSamplesCountAtStartOfLoad = getExtractedSamplesCount();
loader.startLoading(loadable, this, actualMinLoadableRetryCount);
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);
} }
private void configureRetry(ExtractingLoadable loadable) { private void configureRetry(ExtractingLoadable loadable) {
......
...@@ -184,8 +184,7 @@ public final class ExtractorMediaSource implements MediaSource, ExtractorMediaPe ...@@ -184,8 +184,7 @@ public final class ExtractorMediaSource implements MediaSource, ExtractorMediaPe
public void onSourceInfoRefreshed(long durationUs, boolean isSeekable) { public void onSourceInfoRefreshed(long durationUs, boolean isSeekable) {
// If we already have the duration from a previous source info refresh, use it. // If we already have the duration from a previous source info refresh, use it.
durationUs = durationUs == C.TIME_UNSET ? timelineDurationUs : durationUs; durationUs = durationUs == C.TIME_UNSET ? timelineDurationUs : durationUs;
if ((timelineDurationUs == durationUs && timelineIsSeekable == isSeekable) if (timelineDurationUs == durationUs && timelineIsSeekable == isSeekable) {
|| (timelineDurationUs != C.TIME_UNSET && durationUs == C.TIME_UNSET)) {
// Suppress no-op source info changes. // Suppress no-op source info changes.
return; 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