Skip to content

Commit

Permalink
Reset loading period after reading discontinuity that requires loading
Browse files Browse the repository at this point in the history
This is the same change as 1a21204, just on the second call site
of readDiscontinuity. The tests didn't cover this case yet because
they never queued more than 2 items in a playlist.

PiperOrigin-RevId: 553485244
  • Loading branch information
tonihei authored and tianyif committed Aug 7, 2023
1 parent 97bfbc4 commit 6f24573
Show file tree
Hide file tree
Showing 10 changed files with 13,780 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2176,6 +2176,13 @@ private void maybeUpdateReadingPeriod() throws ExoPlaybackException {
// be disabled and re-enabled when they start playing the next period.
setAllRendererStreamsFinal(
/* streamEndPositionUs= */ readingPeriodHolder.getStartPositionRendererTime());
if (!readingPeriodHolder.isFullyBuffered()) {
// The discontinuity caused the period to not be fully buffered. Continue loading from this
// period again and discard all other periods we already started loading.
queue.removeAfter(readingPeriodHolder);
handleLoadingMediaPeriodChanged(/* loadingTrackSelectionChanged= */ false);
maybeContinueLoading();
}
return;
}
for (int i = 0; i < renderers.length; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public static List<Boolean[]> configs() {
ShadowMediaCodecConfig.forAllSupportedMimeTypes();

@Test
public void test() throws Exception {
public void transitionBetweenDifferentMergeConfigurations() throws Exception {
Context applicationContext = ApplicationProvider.getApplicationContext();
CapturingRenderersFactory capturingRenderersFactory =
new CapturingRenderersFactory(applicationContext);
Expand Down Expand Up @@ -119,6 +119,40 @@ public void test() throws Exception {
+ ".dump");
}

@Test
public void multipleRepetitionsOfSameMergeConfiguration() throws Exception {
Context applicationContext = ApplicationProvider.getApplicationContext();
CapturingRenderersFactory capturingRenderersFactory =
new CapturingRenderersFactory(applicationContext);
ExoPlayer player =
new ExoPlayer.Builder(applicationContext, capturingRenderersFactory)
.setClock(new FakeClock(/* isAutoAdvancing= */ true))
.build();
Surface surface = new Surface(new SurfaceTexture(/* texName= */ 1));
player.setVideoSurface(surface);
PlaybackOutput playbackOutput = PlaybackOutput.register(player, capturingRenderersFactory);

for (int i = 0; i < 5; i++) {
player.addMediaSource(createMergingMediaSource(firstItemVideoClipped, firstItemAudioClipped));
}
player.prepare();
player.play();
TestPlayerRunHelper.runUntilPlaybackState(player, Player.STATE_ENDED);
player.release();
surface.release();

DumpFileAsserts.assertOutput(
applicationContext,
playbackOutput,
"playbackdumps/merging/repeat_"
+ (videoIsPrimaryMergedSource ? "video" : "audio")
+ "_"
+ firstItemVideoClipped
+ "_"
+ firstItemAudioClipped
+ ".dump");
}

private MergingMediaSource createMergingMediaSource(boolean videoClipped, boolean audioClipped) {
MediaSource.Factory mediaSourceFactory =
new DefaultMediaSourceFactory((Context) ApplicationProvider.getApplicationContext());
Expand Down
Loading

0 comments on commit 6f24573

Please sign in to comment.