Commit 7e9793b6 by bachinger Committed by microkatz

Use final reference to content timeline inside handler message

The content timeline field may be updated when the live timeline
is refreshed in the looper event preceding the runnable that is
posted to the player thread. Hence a new timeline may contain a
new period uid that is not present in the ad playback state map.

Using a final reference makes sure period and ad playback state
match when asserted.

PiperOrigin-RevId: 518228165
parent 55e77477
......@@ -185,6 +185,7 @@ public final class ServerSideAdInsertionMediaSource extends BaseMediaSource
if (playbackHandler == null) {
this.adPlaybackStates = adPlaybackStates;
} else {
Timeline finalContentTimeline = contentTimeline;
playbackHandler.post(
() -> {
for (SharedMediaPeriod mediaPeriod : mediaPeriods.values()) {
......@@ -203,9 +204,9 @@ public final class ServerSideAdInsertionMediaSource extends BaseMediaSource
}
}
this.adPlaybackStates = adPlaybackStates;
if (contentTimeline != null) {
if (finalContentTimeline != null) {
refreshSourceInfo(
new ServerSideAdInsertionTimeline(contentTimeline, adPlaybackStates));
new ServerSideAdInsertionTimeline(finalContentTimeline, adPlaybackStates));
}
});
}
......
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