Fix message indexing bug.

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
This commit is contained in:
tonihei 2020-04-30 15:01:44 +01:00 committed by Andrew Lewis
parent 68059070f4
commit d14f559e94
2 changed files with 8 additions and 3 deletions

View File

@ -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.

View File

@ -120,7 +120,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
private int pendingPrepareCount;
private SeekPosition pendingInitialSeekPosition;
private long rendererPositionUs;
private int nextPendingMessageIndex;
private int nextPendingMessageIndexHint;
private boolean deliverPendingMessageAtStartPositionRequired;
public ExoPlayerImplInternal(
@ -928,7 +928,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
pendingMessageInfo.message.markAsProcessed(/* isDelivered= */ false);
}
pendingMessages.clear();
nextPendingMessageIndex = 0;
}
MediaPeriodId mediaPeriodId =
resetPosition
@ -1082,6 +1081,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
// 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
@ -1127,6 +1127,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
? pendingMessages.get(nextPendingMessageIndex)
: null;
}
nextPendingMessageIndexHint = nextPendingMessageIndex;
}
private void ensureStopped(Renderer renderer) throws ExoPlaybackException {