Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,15 @@ public ProgressiveMediaPeriod(
this.progressiveMediaExtractor = progressiveMediaExtractor;
this.singleSampleDurationUs = singleSampleDurationUs;
loadCondition = new ConditionVariable();
handler = Util.createHandlerForCurrentLooper();
maybeFinishPrepareRunnable = this::maybeFinishPrepare;
onContinueLoadingRequestedRunnable =
() -> {
if (!released) {
handler.post(maybeFinishPrepareRunnable);
checkNotNull(callback).onContinueLoadingRequested(ProgressiveMediaPeriod.this);
}
};
handler = Util.createHandlerForCurrentLooper();
sampleQueueTrackIds = new TrackId[0];
sampleQueues = new SampleQueue[0];
controlledTrackOutputs = new ControlledTrackOutput[0];
Expand Down Expand Up @@ -725,6 +726,7 @@ public void onLoadCompleted(
/* mediaStartTimeUs= */ loadable.seekTimeUs,
durationUs);
loadingFinished = true;
handler.post(maybeFinishPrepareRunnable);
checkNotNull(callback).onContinueLoadingRequested(this);
}

Expand Down Expand Up @@ -907,7 +909,35 @@ private void maybeFinishPrepare() {
}
for (SampleQueue sampleQueue : sampleQueues) {
if (sampleQueue.getUpstreamFormat() == null) {
return;
if (loadingFinished) {
// File fully exhausted; this track never produced any data.
} else if (!loadCondition.isOpen()) {
// Loading is paused (e.g. DefaultLoadControl byte budget full). Only assign a
// placeholder if at least one real video and one real audio track have already
// been seen, confirming this is an extra PMT-declared stream that carries no data
// rather than a legitimate track whose format packet hasn't arrived yet.
boolean haveVideo = false;
boolean haveAudio = false;
for (SampleQueue q : sampleQueues) {
Format f = q.getUpstreamFormat();
if (f == null) {
continue;
}
if (MimeTypes.isVideo(f.sampleMimeType)) {
haveVideo = true;
} else if (MimeTypes.isAudio(f.sampleMimeType)) {
haveAudio = true;
}
}
if (!haveVideo || !haveAudio) {
return;
}
} else {
// Actively loading; a format may still arrive from the loading thread.
return;
}
Log.i(TAG, "Empty declared track — assigning placeholder (loadingFinished=" + loadingFinished + "). PATCHED_BUILD_OK");
sampleQueue.format(new Format.Builder().build());
}
}
loadCondition.close();
Expand Down