diff --git a/dom/audiochannel/AudioChannelService.cpp b/dom/audiochannel/AudioChannelService.cpp index dc0cb4b17a41..f9431c5dbb10 100644 --- a/dom/audiochannel/AudioChannelService.cpp +++ b/dom/audiochannel/AudioChannelService.cpp @@ -207,7 +207,8 @@ NS_IMPL_ADDREF(AudioChannelService) NS_IMPL_RELEASE(AudioChannelService) AudioChannelService::AudioChannelService() - : mDefChannelChildID(CONTENT_PROCESS_ID_UNKNOWN) + : mDisabled(false) + , mDefChannelChildID(CONTENT_PROCESS_ID_UNKNOWN) , mTelephonyChannel(false) , mContentOrNormalChannel(false) , mAnyChannel(false) @@ -237,6 +238,10 @@ void AudioChannelService::RegisterAudioChannelAgent(AudioChannelAgent* aAgent, AudioChannel aChannel) { + if (mDisabled) { + return; + } + uint64_t windowID = aAgent->WindowID(); AudioChannelWindow* winData = GetWindowData(windowID); if (!winData) { @@ -267,6 +272,10 @@ AudioChannelService::RegisterAudioChannelAgent(AudioChannelAgent* aAgent, void AudioChannelService::UnregisterAudioChannelAgent(AudioChannelAgent* aAgent) { + if (mDisabled) { + return; + } + AudioChannelWindow* winData = GetWindowData(aAgent->WindowID()); if (!winData) { return; @@ -457,8 +466,8 @@ AudioChannelService::Observe(nsISupports* aSubject, const char* aTopic, const char16_t* aData) { if (!strcmp(aTopic, "xpcom-shutdown")) { + mDisabled = true; mWindows.Clear(); - Shutdown(); } #ifdef MOZ_WIDGET_GONK diff --git a/dom/audiochannel/AudioChannelService.h b/dom/audiochannel/AudioChannelService.h index a0a65d8c737a..65f312d236b0 100644 --- a/dom/audiochannel/AudioChannelService.h +++ b/dom/audiochannel/AudioChannelService.h @@ -43,6 +43,11 @@ public: */ static already_AddRefed GetOrCreate(); + /** + * Shutdown the singleton. + */ + static void Shutdown(); + static bool IsAudioChannelMutedByDefault(); /** @@ -131,11 +136,6 @@ private: AudioChannelService(); ~AudioChannelService(); - /** - * Shutdown the singleton. - */ - static void Shutdown(); - void MaybeSendStatusUpdate(); bool ContentOrNormalChannelIsActive(); @@ -204,6 +204,8 @@ private: nsTArray mSpeakerManager; #endif + bool mDisabled; + nsCOMPtr mRunnable; uint64_t mDefChannelChildID; diff --git a/layout/build/nsLayoutStatics.cpp b/layout/build/nsLayoutStatics.cpp index 1f0111b39375..aeefa16b2f0d 100644 --- a/layout/build/nsLayoutStatics.cpp +++ b/layout/build/nsLayoutStatics.cpp @@ -435,6 +435,8 @@ nsLayoutStatics::Shutdown() nsHyphenationManager::Shutdown(); nsDOMMutationObserver::Shutdown(); + AudioChannelService::Shutdown(); + DataStoreService::Shutdown(); ContentParent::ShutDown();