Skip to content

Commit

Permalink
Fix EPI.seekTo to balance operation acks when seeking during an ad
Browse files Browse the repository at this point in the history
This regression was introduced in
b1e9257

Issue: #8349

#minor-release

PiperOrigin-RevId: 347802049
  • Loading branch information
icbaker authored and christosts committed Dec 17, 2020
1 parent f11a9cd commit abff516
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
2 changes: 2 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
getters.
* Deprecate `HttpDataSource.Factory.getDefaultRequestProperties` and add
`HttpDataSource.Factory.setDefaultRequestProperties` instead.
* Fix playback issues after seeking during an ad
([#8349](https://github.com/google/ExoPlayer/issues/8349))
* Track selection:
* Add option to specify multiple preferred audio or text languages.
* Forward `Timeline` and `MediaPeriodId` to `TrackSelection.Factory`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -613,8 +613,10 @@ public void seekTo(int windowIndex, long positionMs) {
// general because the midroll ad preceding the seek destination must be played before the
// content position can be played, if a different ad is playing at the moment.
Log.w(TAG, "seekTo ignored because an ad is playing");
playbackInfoUpdateListener.onPlaybackInfoUpdate(
new ExoPlayerImplInternal.PlaybackInfoUpdate(playbackInfo));
ExoPlayerImplInternal.PlaybackInfoUpdate playbackInfoUpdate =
new ExoPlayerImplInternal.PlaybackInfoUpdate(this.playbackInfo);
playbackInfoUpdate.incrementPendingOperationAcks(1);
playbackInfoUpdateListener.onPlaybackInfoUpdate(playbackInfoUpdate);
return;
}
@Player.State
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4490,6 +4490,42 @@ public void run(SimpleExoPlayer player) {
assertThat(totalBufferedDurationMs[1]).isEqualTo(adDurationMs);
}

// https://github.com/google/ExoPlayer/issues/8349
@Test
public void seekTo_whilePlayingAd_doesntBlockFutureUpdates() throws Exception {
long contentDurationMs = 10_000;
long adDurationMs = 4_000;
AdPlaybackState adPlaybackState =
new AdPlaybackState(/* adsId= */ new Object(), /* adGroupTimesUs...= */ 0)
.withAdCount(/* adGroupIndex= */ 0, /* adCount= */ 1)
.withAdUri(/* adGroupIndex= */ 0, /* adIndexInAdGroup= */ 0, Uri.EMPTY);
long[][] durationsUs = new long[1][];
durationsUs[0] = new long[] {C.msToUs(adDurationMs)};
adPlaybackState = adPlaybackState.withAdDurationsUs(durationsUs);
Timeline adTimeline =
new FakeTimeline(
new TimelineWindowDefinition(
/* periodCount= */ 1,
/* id= */ 0,
/* isSeekable= */ true,
/* isDynamic= */ false,
/* durationUs= */ C.msToUs(contentDurationMs),
adPlaybackState));
FakeMediaSource adsMediaSource = new FakeMediaSource(adTimeline);

SimpleExoPlayer player = new TestExoPlayerBuilder(context).build();
player.setMediaSource(adsMediaSource);
player.pause();
player.prepare();
runUntilPlaybackState(player, Player.STATE_READY);

player.seekTo(0, 8000);
player.play();

// This times out if playback info updates after the seek are blocked.
runUntilPlaybackState(player, Player.STATE_ENDED);
}

@Test
public void becomingNoisyIgnoredIfBecomingNoisyHandlingIsDisabled() throws Exception {
CountDownLatch becomingNoisyHandlingDisabled = new CountDownLatch(1);
Expand Down

0 comments on commit abff516

Please sign in to comment.