Clear ad playback state map when AdsLoader is released

#minor-release

PiperOrigin-RevId: 429067634
This commit is contained in:
bachinger 2022-02-16 17:30:25 +00:00 committed by Ian Baker
parent 2bc65f9463
commit e296bf9197

View File

@ -291,7 +291,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<String, AdPlaybackState> adPlaybackStates;
@ -387,7 +387,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()) {
@ -396,9 +396,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.