mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +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
|
* 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(
|
static <T extends ExoMediaCrypto> void replaceSessionReferences(
|
||||||
@Nullable DrmSession<T> previousSession, @Nullable DrmSession<T> newSession) {
|
@Nullable DrmSession<T> previousSession, @Nullable DrmSession<T> newSession) {
|
||||||
|
if (previousSession == newSession) {
|
||||||
|
// Do nothing.
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (newSession != null) {
|
if (newSession != null) {
|
||||||
newSession.acquireReference();
|
newSession.acquireReference();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue