Commit d14f559e by tonihei Committed by Andrew Lewis

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
parent 68059070
...@@ -5,7 +5,11 @@ ...@@ -5,7 +5,11 @@
* Add `SilenceMediaSource.Factory` to support tags. * Add `SilenceMediaSource.Factory` to support tags.
* Enable the configuration of `SilenceSkippingAudioProcessor` * Enable the configuration of `SilenceSkippingAudioProcessor`
([#6705](https://github.com/google/ExoPlayer/issues/6705)). ([#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)). ([#7306](https://github.com/google/ExoPlayer/issues/7306)).
* Ads: * Ads:
* Fix `AdsMediaSource` child `MediaSource`s not being released. * Fix `AdsMediaSource` child `MediaSource`s not being released.
......
...@@ -120,7 +120,7 @@ import java.util.concurrent.atomic.AtomicBoolean; ...@@ -120,7 +120,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
private int pendingPrepareCount; private int pendingPrepareCount;
private SeekPosition pendingInitialSeekPosition; private SeekPosition pendingInitialSeekPosition;
private long rendererPositionUs; private long rendererPositionUs;
private int nextPendingMessageIndex; private int nextPendingMessageIndexHint;
private boolean deliverPendingMessageAtStartPositionRequired; private boolean deliverPendingMessageAtStartPositionRequired;
public ExoPlayerImplInternal( public ExoPlayerImplInternal(
...@@ -928,7 +928,6 @@ import java.util.concurrent.atomic.AtomicBoolean; ...@@ -928,7 +928,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
pendingMessageInfo.message.markAsProcessed(/* isDelivered= */ false); pendingMessageInfo.message.markAsProcessed(/* isDelivered= */ false);
} }
pendingMessages.clear(); pendingMessages.clear();
nextPendingMessageIndex = 0;
} }
MediaPeriodId mediaPeriodId = MediaPeriodId mediaPeriodId =
resetPosition resetPosition
...@@ -1082,6 +1081,7 @@ import java.util.concurrent.atomic.AtomicBoolean; ...@@ -1082,6 +1081,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
// Correct next index if necessary (e.g. after seeking, timeline changes, or new messages) // Correct next index if necessary (e.g. after seeking, timeline changes, or new messages)
int currentPeriodIndex = int currentPeriodIndex =
playbackInfo.timeline.getIndexOfPeriod(playbackInfo.periodId.periodUid); playbackInfo.timeline.getIndexOfPeriod(playbackInfo.periodId.periodUid);
int nextPendingMessageIndex = Math.min(nextPendingMessageIndexHint, pendingMessages.size());
PendingMessageInfo previousInfo = PendingMessageInfo previousInfo =
nextPendingMessageIndex > 0 ? pendingMessages.get(nextPendingMessageIndex - 1) : null; nextPendingMessageIndex > 0 ? pendingMessages.get(nextPendingMessageIndex - 1) : null;
while (previousInfo != null while (previousInfo != null
...@@ -1127,6 +1127,7 @@ import java.util.concurrent.atomic.AtomicBoolean; ...@@ -1127,6 +1127,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
? pendingMessages.get(nextPendingMessageIndex) ? pendingMessages.get(nextPendingMessageIndex)
: null; : null;
} }
nextPendingMessageIndexHint = nextPendingMessageIndex;
} }
private void ensureStopped(Renderer renderer) throws ExoPlaybackException { private void ensureStopped(Renderer renderer) throws ExoPlaybackException {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment