Commit b8e1a0b4 by tonihei Committed by Tianyi Feng

Verify source is not released before updating ad playback state

Updates to the ad playback state are posted on the main handler,
so they may arrive after the source has already been released
(=the internal MediaSource is null). This can cause NPEs.

PiperOrigin-RevId: 555102426
(cherry picked from commit eb0e7aced70d16aec0f6b67c0bb5c290ab87be54)
parent a3884d84
...@@ -704,7 +704,9 @@ public final class ImaServerSideAdInsertionMediaSource extends CompositeMediaSou ...@@ -704,7 +704,9 @@ public final class ImaServerSideAdInsertionMediaSource extends CompositeMediaSou
@MainThread @MainThread
private void invalidateServerSideAdInsertionAdPlaybackState() { private void invalidateServerSideAdInsertionAdPlaybackState() {
if (!adPlaybackState.equals(AdPlaybackState.NONE) && contentTimeline != null) { if (!adPlaybackState.equals(AdPlaybackState.NONE)
&& contentTimeline != null
&& serverSideAdInsertionMediaSource != null) {
Timeline contentTimeline = checkNotNull(this.contentTimeline); Timeline contentTimeline = checkNotNull(this.contentTimeline);
ImmutableMap<Object, AdPlaybackState> splitAdPlaybackStates; ImmutableMap<Object, AdPlaybackState> splitAdPlaybackStates;
if (Objects.equals(streamRequest.getFormat(), StreamFormat.DASH)) { if (Objects.equals(streamRequest.getFormat(), StreamFormat.DASH)) {
......
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