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
This commit is contained in:
parent
b8aedfbf4f
commit
74e74402da
@ -303,7 +303,8 @@ import java.util.Arrays;
|
||||
|
||||
@Override
|
||||
public long readDiscontinuity() {
|
||||
if (notifyDiscontinuity) {
|
||||
if (notifyDiscontinuity
|
||||
&& (loadingFinished || getExtractedSamplesCount() > extractedSamplesCountAtStartOfLoad)) {
|
||||
notifyDiscontinuity = false;
|
||||
return lastSeekPositionUs;
|
||||
}
|
||||
@ -361,7 +362,7 @@ import java.util.Arrays;
|
||||
// SampleStream methods.
|
||||
|
||||
/* package */ boolean isReady(int track) {
|
||||
return loadingFinished || (!isPendingReset() && sampleQueues[track].hasNextSample());
|
||||
return !suppressRead() && (loadingFinished || sampleQueues[track].hasNextSample());
|
||||
}
|
||||
|
||||
/* package */ void maybeThrowError() throws IOException {
|
||||
@ -370,7 +371,7 @@ import java.util.Arrays;
|
||||
|
||||
/* package */ int readData(int track, FormatHolder formatHolder, DecoderInputBuffer buffer,
|
||||
boolean formatRequired) {
|
||||
if (notifyDiscontinuity || isPendingReset()) {
|
||||
if (suppressRead()) {
|
||||
return C.RESULT_NOTHING_READ;
|
||||
}
|
||||
return sampleQueues[track].read(formatHolder, buffer, formatRequired, loadingFinished,
|
||||
@ -378,6 +379,9 @@ import java.util.Arrays;
|
||||
}
|
||||
|
||||
/* package */ int skipData(int track, long positionUs) {
|
||||
if (suppressRead()) {
|
||||
return 0;
|
||||
}
|
||||
SampleQueue sampleQueue = sampleQueues[track];
|
||||
if (loadingFinished && positionUs > sampleQueue.getLargestQueuedTimestampUs()) {
|
||||
return sampleQueue.advanceToEnd();
|
||||
@ -387,6 +391,10 @@ import java.util.Arrays;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean suppressRead() {
|
||||
return notifyDiscontinuity || isPendingReset();
|
||||
}
|
||||
|
||||
// Loader.Callback implementation.
|
||||
|
||||
@Override
|
||||
|
Loading…
x
Reference in New Issue
Block a user