mirror of
https://github.com/samsonjs/media.git
synced 2026-04-13 12:35:48 +00:00
Avoid notifying connection twice from MediaControllerImplLegacy.
The connection to a legacy MediaSession may receive additional onSessionReady callbacks that are treated as additional state updates. We currently also set the "notifyConnected" flag for these updates even though we are connected already, causing an IllegalStateException. Fix the exception by not setting this flag. We can also remove the wording about "locked" updates since this class operates everything on a single application thread. Issue: androidx/media#49 PiperOrigin-RevId: 487487286
This commit is contained in:
parent
07f0589ce7
commit
b24161a6f6
2 changed files with 10 additions and 10 deletions
|
|
@ -99,6 +99,9 @@ Release notes
|
|||
`DefaultNotificationProvider` on API 26 and API 27 (the badge is
|
||||
automatically hidden on API 28+)
|
||||
([#131](https://github.com/androidx/media/issues/131)).
|
||||
* Fix bug where a second binder connection from a legacy MediaSession to a
|
||||
Media3 MediaController causes IllegalStateExceptions
|
||||
([#49](https://github.com/androidx/media/issues/49)).
|
||||
* RTSP:
|
||||
* Add H263 fragmented packet handling
|
||||
([#119](https://github.com/androidx/media/pull/119)).
|
||||
|
|
|
|||
|
|
@ -1211,8 +1211,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
|
|||
return browserCompat;
|
||||
}
|
||||
|
||||
// Should be used without a lock to prevent potential deadlock.
|
||||
void onConnectedNotLocked() {
|
||||
void onConnected() {
|
||||
if (released || connected) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -1240,18 +1239,16 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
|
|||
controllerCompat.registerCallback(
|
||||
controllerCompatCallback, getInstance().applicationHandler);
|
||||
});
|
||||
// Post a runnable to prevent callbacks from being called by onConnectedNotLocked()
|
||||
// Post a runnable to prevent callbacks from being called by onConnected()
|
||||
// before the constructor returns (b/196941334).
|
||||
getInstance()
|
||||
.applicationHandler
|
||||
.post(
|
||||
() -> {
|
||||
if (!controllerCompat.isSessionReady()) {
|
||||
// If the session not ready here, then call onConnectedNotLocked() immediately. The
|
||||
// session may be a framework MediaSession and we cannot know whether it can be
|
||||
// ready
|
||||
// later.
|
||||
onConnectedNotLocked();
|
||||
// If the session not ready here, then call onConnected() immediately. The session
|
||||
// may be a framework MediaSession and we cannot know whether it can be ready later.
|
||||
onConnected();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -1608,7 +1605,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
|
|||
@Override
|
||||
public void onSessionReady() {
|
||||
if (!connected) {
|
||||
onConnectedNotLocked();
|
||||
onConnected();
|
||||
} else {
|
||||
// Handle the case when extra binder is available after connectToSession().
|
||||
// Initial values are notified already, so only notify values that are available when
|
||||
|
|
@ -1622,7 +1619,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
|
|||
onCaptioningEnabledChanged(isCaptioningEnabled);
|
||||
|
||||
pendingChangesHandler.removeMessages(MSG_HANDLE_PENDING_UPDATES);
|
||||
handleNewLegacyParameters(/* notifyConnected= */ true, pendingLegacyPlayerInfo);
|
||||
handleNewLegacyParameters(/* notifyConnected= */ false, pendingLegacyPlayerInfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue