Skip to content

Commit

Permalink
Remove all handler messages when controller is released
Browse files Browse the repository at this point in the history
Issue: #74
PiperOrigin-RevId: 448205908
  • Loading branch information
marcbaechinger authored and icbaker committed May 24, 2022
1 parent efb49f2 commit 9b07d71
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ public void release() {
serviceConnection = null;
}
connectedToken = null;
flushCommandQueueHandler.removeCallbacksAndMessages(/* token= */ null);
this.iSession = null;
controllerStub.destroy();
if (iSession != null) {
Expand Down Expand Up @@ -3046,9 +3047,9 @@ public void handleMessage(Message msg) {
}

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);
}
}
Expand Down

0 comments on commit 9b07d71

Please sign in to comment.