From 0f80f824b28c57bb4e42c2c5084e0d2f5374f94d Mon Sep 17 00:00:00 2001 From: alwu Date: Thu, 8 Jul 2021 21:28:48 +0000 Subject: [PATCH] Bug 1715415 - part2 : clear the active session Id when stopping a controller. r=chunmin As we would not deactivate the controller if we have an active session [1], clear the active session Id in order to trigger the process of deactivating controller later. [1] https://searchfox.org/mozilla-central/rev/f351e19360729b351bfc7c1386d6e4ca4ea676e2/dom/media/mediacontrol/MediaController.cpp#352-362 Differential Revision: https://phabricator.services.mozilla.com/D117956 --- dom/media/mediacontrol/MediaController.cpp | 1 + dom/media/mediacontrol/MediaStatusManager.h | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/dom/media/mediacontrol/MediaController.cpp b/dom/media/mediacontrol/MediaController.cpp index b2b3c13ae85a..6b3a31663810 100644 --- a/dom/media/mediacontrol/MediaController.cpp +++ b/dom/media/mediacontrol/MediaController.cpp @@ -170,6 +170,7 @@ void MediaController::Stop() { LOG("Stop"); UpdateMediaControlActionToContentMediaIfNeeded( MediaControlAction(MediaControlKey::Stop)); + MediaStatusManager::ClearActiveMediaSessionContextIdIfNeeded(); } uint64_t MediaController::Id() const { return mTopLevelBrowsingContextId; } diff --git a/dom/media/mediacontrol/MediaStatusManager.h b/dom/media/mediacontrol/MediaStatusManager.h index e7a7a8581166..33c09573861c 100644 --- a/dom/media/mediacontrol/MediaStatusManager.h +++ b/dom/media/mediacontrol/MediaStatusManager.h @@ -212,6 +212,8 @@ class MediaStatusManager : public IMediaInfoUpdater { // media session and owns the audio focus within a tab. Maybe mActiveMediaSessionContextId; + void ClearActiveMediaSessionContextIdIfNeeded(); + private: nsString GetDefaultFaviconURL() const; nsString GetDefaultTitle() const; @@ -221,7 +223,6 @@ class MediaStatusManager : public IMediaInfoUpdater { bool IsSessionOwningAudioFocus(uint64_t aBrowsingContextId) const; void SetActiveMediaSessionContextId(uint64_t aBrowsingContextId); - void ClearActiveMediaSessionContextIdIfNeeded(); void HandleAudioFocusOwnerChanged(Maybe& aBrowsingContextId); void NotifySupportedKeysChangedIfNeeded(uint64_t aBrowsingContextId);