Commit 74e74402 by olly Committed by Oliver Woodman

Deduplicate ExtractorMediaPeriod discontinuity reporting

This change makes sure progress is being made before reporting
a discontinuity. Else in cases like having no network and
playing a live stream, we allow the discontinuity to be read
each time an internal retry occurs, meaning it gets read
repeatedly. This does no harm, but is noisy and unnecessary.

We should also not allow skipping whilst there is a pending
reset or discontinuity notification, just like we don't allow
reads.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=175953064
parent b8aedfbf
...@@ -303,7 +303,8 @@ import java.util.Arrays; ...@@ -303,7 +303,8 @@ import java.util.Arrays;
@Override @Override
public long readDiscontinuity() { public long readDiscontinuity() {
if (notifyDiscontinuity) { if (notifyDiscontinuity
&& (loadingFinished || getExtractedSamplesCount() > extractedSamplesCountAtStartOfLoad)) {
notifyDiscontinuity = false; notifyDiscontinuity = false;
return lastSeekPositionUs; return lastSeekPositionUs;
} }
...@@ -361,7 +362,7 @@ import java.util.Arrays; ...@@ -361,7 +362,7 @@ import java.util.Arrays;
// SampleStream methods. // SampleStream methods.
/* package */ boolean isReady(int track) { /* package */ boolean isReady(int track) {
return loadingFinished || (!isPendingReset() && sampleQueues[track].hasNextSample()); return !suppressRead() && (loadingFinished || sampleQueues[track].hasNextSample());
} }
/* package */ void maybeThrowError() throws IOException { /* package */ void maybeThrowError() throws IOException {
...@@ -370,7 +371,7 @@ import java.util.Arrays; ...@@ -370,7 +371,7 @@ import java.util.Arrays;
/* package */ int readData(int track, FormatHolder formatHolder, DecoderInputBuffer buffer, /* package */ int readData(int track, FormatHolder formatHolder, DecoderInputBuffer buffer,
boolean formatRequired) { boolean formatRequired) {
if (notifyDiscontinuity || isPendingReset()) { if (suppressRead()) {
return C.RESULT_NOTHING_READ; return C.RESULT_NOTHING_READ;
} }
return sampleQueues[track].read(formatHolder, buffer, formatRequired, loadingFinished, return sampleQueues[track].read(formatHolder, buffer, formatRequired, loadingFinished,
...@@ -378,6 +379,9 @@ import java.util.Arrays; ...@@ -378,6 +379,9 @@ import java.util.Arrays;
} }
/* package */ int skipData(int track, long positionUs) { /* package */ int skipData(int track, long positionUs) {
if (suppressRead()) {
return 0;
}
SampleQueue sampleQueue = sampleQueues[track]; SampleQueue sampleQueue = sampleQueues[track];
if (loadingFinished && positionUs > sampleQueue.getLargestQueuedTimestampUs()) { if (loadingFinished && positionUs > sampleQueue.getLargestQueuedTimestampUs()) {
return sampleQueue.advanceToEnd(); return sampleQueue.advanceToEnd();
...@@ -387,6 +391,10 @@ import java.util.Arrays; ...@@ -387,6 +391,10 @@ import java.util.Arrays;
} }
} }
private boolean suppressRead() {
return notifyDiscontinuity || isPendingReset();
}
// Loader.Callback implementation. // Loader.Callback implementation.
@Override @Override
......
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