Skip to content

Commit

Permalink
Verify source is not released before updating ad playback state
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tonihei authored and tianyif committed Aug 10, 2023
1 parent dedccc5 commit 20d2ce7
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,9 @@ private void setContentTimeline(Timeline contentTimeline) {

@MainThread
private void invalidateServerSideAdInsertionAdPlaybackState() {
if (!adPlaybackState.equals(AdPlaybackState.NONE) && contentTimeline != null) {
if (!adPlaybackState.equals(AdPlaybackState.NONE)
&& contentTimeline != null
&& serverSideAdInsertionMediaSource != null) {
Timeline contentTimeline = checkNotNull(this.contentTimeline);
ImmutableMap<Object, AdPlaybackState> splitAdPlaybackStates;
if (Objects.equals(streamRequest.getFormat(), StreamFormat.DASH)) {
Expand Down

0 comments on commit 20d2ce7

Please sign in to comment.