Simplify release event logic in DefaultDrmSession

This is a no-op assuming the class is always used correctly.
When release causes referenceCount to reach zero there can be at most
one EventDispatcher still connected (which is the one that must be
passed to that final release() call), so we can always pass the event
directly to the EventDispatcher passed in to release().

PiperOrigin-RevId: 358794004
This commit is contained in:
ibaker 2021-02-22 12:48:47 +00:00 committed by marcbaechinger
parent 399e1365d0
commit 8d942dc213

View File

@ -321,14 +321,10 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
mediaDrm.closeSession(sessionId); mediaDrm.closeSession(sessionId);
sessionId = null; sessionId = null;
} }
dispatchEvent(DrmSessionEventListener.EventDispatcher::drmSessionReleased);
} }
if (eventDispatcher != null) { if (eventDispatcher != null) {
if (isOpen()) { // Acquire and release events are only sent to the provided dispatcher.
// If the session is still open then send the release event only to the provided dispatcher eventDispatcher.drmSessionReleased();
// before removing it.
eventDispatcher.drmSessionReleased();
}
eventDispatchers.remove(eventDispatcher); eventDispatchers.remove(eventDispatcher);
} }
referenceCountListener.onReferenceCountDecremented(this, referenceCount); referenceCountListener.onReferenceCountDecremented(this, referenceCount);