Skip to content

Commit

Permalink
Invoke onLoadCanceled/Completed for ExtractorMediaSource
Browse files Browse the repository at this point in the history
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177936271
  • Loading branch information
andrewlewis authored and ojw28 committed Dec 12, 2017
1 parent 82122b9 commit 3c0bb72
Showing 1 changed file with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -405,14 +405,26 @@ private boolean suppressRead() {
@Override
public void onLoadCompleted(ExtractingLoadable loadable, long elapsedRealtimeMs,
long loadDurationMs) {
copyLengthFromLoader(loadable);
loadingFinished = true;
if (durationUs == C.TIME_UNSET) {
long largestQueuedTimestampUs = getLargestQueuedTimestampUs();
durationUs = largestQueuedTimestampUs == Long.MIN_VALUE ? 0
: largestQueuedTimestampUs + DEFAULT_LAST_SAMPLE_DURATION_US;
listener.onSourceInfoRefreshed(durationUs, seekMap.isSeekable());
}
eventDispatcher.loadCompleted(
loadable.dataSpec,
C.DATA_TYPE_MEDIA,
C.TRACK_TYPE_UNKNOWN,
/* trackFormat= */ null,
C.SELECTION_REASON_UNKNOWN,
/* trackSelectionData= */ null,
/* mediaStartTimeUs= */ 0,
durationUs,
elapsedRealtimeMs,
loadDurationMs,
loadable.bytesLoaded);
copyLengthFromLoader(loadable);
loadingFinished = true;
callback.onContinueLoadingRequested(this);
}

Expand All @@ -422,6 +434,18 @@ public void onLoadCanceled(ExtractingLoadable loadable, long elapsedRealtimeMs,
if (released) {
return;
}
eventDispatcher.loadCanceled(
loadable.dataSpec,
C.DATA_TYPE_MEDIA,
C.TRACK_TYPE_UNKNOWN,
/* trackFormat= */ null,
C.SELECTION_REASON_UNKNOWN,
/* trackSelectionData= */ null,
/* mediaStartTimeUs= */ 0,
durationUs,
elapsedRealtimeMs,
loadDurationMs,
loadable.bytesLoaded);
copyLengthFromLoader(loadable);
for (SampleQueue sampleQueue : sampleQueues) {
sampleQueue.reset();
Expand All @@ -434,7 +458,6 @@ public void onLoadCanceled(ExtractingLoadable loadable, long elapsedRealtimeMs,
@Override
public int onLoadError(ExtractingLoadable loadable, long elapsedRealtimeMs,
long loadDurationMs, IOException error) {
copyLengthFromLoader(loadable);
boolean isErrorFatal = isLoadableExceptionFatal(error);
eventDispatcher.loadError(
loadable.dataSpec,
Expand All @@ -450,6 +473,7 @@ public int onLoadError(ExtractingLoadable loadable, long elapsedRealtimeMs,
loadable.bytesLoaded,
error,
/* wasCanceled= */ isErrorFatal);
copyLengthFromLoader(loadable);
if (isErrorFatal) {
return Loader.DONT_RETRY_FATAL;
}
Expand Down

0 comments on commit 3c0bb72

Please sign in to comment.