Remove all handler messages when controller is released

Issue: androidx/media#74
PiperOrigin-RevId: 448205908
This commit is contained in:
bachinger 2022-05-12 11:37:14 +01:00 committed by Ian Baker
parent efb49f285e
commit 9b07d71f66
2 changed files with 6 additions and 3 deletions

View File

@ -89,6 +89,8 @@
([#59](https://github.com/androidx/media/pull/59))
* Update session position info on timeline
change([#51](https://github.com/androidx/media/issues/51))
* Fix NPE in MediaControllerImplBase after releasing controller
([#74](https://github.com/androidx/media/issues/74))
* Data sources:

View File

@ -309,6 +309,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
serviceConnection = null;
}
connectedToken = null;
flushCommandQueueHandler.removeCallbacksAndMessages(/* token= */ null);
this.iSession = null;
controllerStub.destroy();
if (iSession != null) {
@ -3046,9 +3047,9 @@ import org.checkerframework.checker.nullness.qual.NonNull;
}
public void sendFlushCommandQueueMessage() {
// Send message to notify the end of the transaction. It will be handled when the current
// looper iteration is over.
if (!hasMessages(MSG_FLUSH_COMMAND_QUEUE)) {
if (iSession != null && !hasMessages(MSG_FLUSH_COMMAND_QUEUE)) {
// Send message to notify the end of the transaction. It will be handled when the current
// looper iteration is over.
sendEmptyMessage(MSG_FLUSH_COMMAND_QUEUE);
}
}