Skip to content

Commit

Permalink
Fix message indexing bug.
Browse files Browse the repository at this point in the history
We keep an index hint for the next pending player message. This hint
wasn't updated correctly when messages are removed due to a timeline
update.

This change makes sure to only use the hint locally in one method so
that it doesn't need to be updated anywhere else and also adds the "hint"
suffix to the variable name to make it clearer that it's just a hint and
there are no guarantees this index actually exists anymore.

issue:#7278
PiperOrigin-RevId: 309217614
  • Loading branch information
tonihei authored and andrewlewis committed May 29, 2020
1 parent 6805907 commit d14f559
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 5 additions & 1 deletion RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
* Add `SilenceMediaSource.Factory` to support tags.
* Enable the configuration of `SilenceSkippingAudioProcessor`
([#6705](https://github.com/google/ExoPlayer/issues/6705)).
* DownloadService: Fix "Not allowed to start service" `IllegalStateException`
* Fix bug where `PlayerMessages` throw an exception after `MediaSources`
are removed from the playlist
([#7278](https://github.com/google/ExoPlayer/issues/7278)).
* Fix "Not allowed to start service" `IllegalStateException` in
`DownloadService`
([#7306](https://github.com/google/ExoPlayer/issues/7306)).
* Ads:
* Fix `AdsMediaSource` child `MediaSource`s not being released.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
private int pendingPrepareCount;
private SeekPosition pendingInitialSeekPosition;
private long rendererPositionUs;
private int nextPendingMessageIndex;
private int nextPendingMessageIndexHint;
private boolean deliverPendingMessageAtStartPositionRequired;

public ExoPlayerImplInternal(
Expand Down Expand Up @@ -928,7 +928,6 @@ private void resetInternal(
pendingMessageInfo.message.markAsProcessed(/* isDelivered= */ false);
}
pendingMessages.clear();
nextPendingMessageIndex = 0;
}
MediaPeriodId mediaPeriodId =
resetPosition
Expand Down Expand Up @@ -1082,6 +1081,7 @@ private void maybeTriggerPendingMessages(long oldPeriodPositionUs, long newPerio
// Correct next index if necessary (e.g. after seeking, timeline changes, or new messages)
int currentPeriodIndex =
playbackInfo.timeline.getIndexOfPeriod(playbackInfo.periodId.periodUid);
int nextPendingMessageIndex = Math.min(nextPendingMessageIndexHint, pendingMessages.size());
PendingMessageInfo previousInfo =
nextPendingMessageIndex > 0 ? pendingMessages.get(nextPendingMessageIndex - 1) : null;
while (previousInfo != null
Expand Down Expand Up @@ -1127,6 +1127,7 @@ private void maybeTriggerPendingMessages(long oldPeriodPositionUs, long newPerio
? pendingMessages.get(nextPendingMessageIndex)
: null;
}
nextPendingMessageIndexHint = nextPendingMessageIndex;
}

private void ensureStopped(Renderer renderer) throws ExoPlaybackException {
Expand Down

0 comments on commit d14f559

Please sign in to comment.