mirror of
https://github.com/samsonjs/media.git
synced 2026-04-04 11:05:47 +00:00
Optimize DrmSession reference replacement
Potentially avoids up to two calls to synchronized methods PiperOrigin-RevId: 257578304
This commit is contained in:
parent
91750b8009
commit
3f24d4433a
1 changed files with 6 additions and 1 deletions
|
|
@ -31,10 +31,15 @@ public interface DrmSession<T extends ExoMediaCrypto> {
|
|||
|
||||
/**
|
||||
* Invokes {@code newSession's} {@link #acquireReference()} and {@code previousSession's} {@link
|
||||
* #releaseReference()} in that order. Does nothing for passed null values.
|
||||
* #releaseReference()} in that order. Null arguments are ignored. Does nothing if {@code
|
||||
* previousSession} and {@code newSession} are the same session.
|
||||
*/
|
||||
static <T extends ExoMediaCrypto> void replaceSessionReferences(
|
||||
@Nullable DrmSession<T> previousSession, @Nullable DrmSession<T> newSession) {
|
||||
if (previousSession == newSession) {
|
||||
// Do nothing.
|
||||
return;
|
||||
}
|
||||
if (newSession != null) {
|
||||
newSession.acquireReference();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue