From 6978746f4f16c8bca99a40949eae3435afe73f12 Mon Sep 17 00:00:00 2001 From: bachinger Date: Wed, 16 Feb 2022 17:30:25 +0000 Subject: [PATCH] Clear ad playback state map when AdsLoader is released #minor-release PiperOrigin-RevId: 429067634 --- .../ima/ImaServerSideAdInsertionMediaSource.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libraries/exoplayer_ima/src/main/java/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionMediaSource.java b/libraries/exoplayer_ima/src/main/java/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionMediaSource.java index 6baf54e974..87499ea227 100644 --- a/libraries/exoplayer_ima/src/main/java/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionMediaSource.java +++ b/libraries/exoplayer_ima/src/main/java/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionMediaSource.java @@ -293,7 +293,7 @@ public final class ImaServerSideAdInsertionMediaSource extends CompositeMediaSou } } - /** The state of the {@link AdsLoader}. */ + /** The state of the {@link AdsLoader} that can be used when resuming from the background. */ public static class State implements Bundleable { private final ImmutableMap adPlaybackStates; @@ -389,7 +389,7 @@ public final class ImaServerSideAdInsertionMediaSource extends CompositeMediaSou /** * Releases resources. * - * @return The {@link State} that can be used to resume with. + * @return The {@link State} that can be used when resuming from the background. */ public State release() { for (MediaSourceResourceHolder resourceHolder : mediaSourceResources.values()) { @@ -398,9 +398,11 @@ public final class ImaServerSideAdInsertionMediaSource extends CompositeMediaSou resourceHolder.imaServerSideAdInsertionMediaSource.setStreamManager( /* streamManager= */ null); } + State state = new State(ImmutableMap.copyOf(adPlaybackStateMap)); + adPlaybackStateMap.clear(); mediaSourceResources.clear(); player = null; - return new State(ImmutableMap.copyOf(adPlaybackStateMap)); + return state; } // Internal methods.