Bug 1361336 - part6: Apply AudioNotificationSender/Receiver in ContentParent/Child; r=cpearce draft
authorChun-Min Chang <chun.m.chang@gmail.com>
Tue, 25 Jul 2017 12:34:14 +0800
changeset 616565 92051dd72a179713e9cc348ec1b5364e079ec643
parent 616564 fbe3ef1d2c254e3f5a87e1ea723e70f997b2c2e1
child 639506 61fc173f4f408cedd2cf9596148bdad3bc358ac0
push id70720
push userbmo:cchang@mozilla.com
push dateThu, 27 Jul 2017 05:33:55 +0000
reviewerscpearce
bugs1361336
milestone56.0a1
Bug 1361336 - part6: Apply AudioNotificationSender/Receiver in ContentParent/Child; r=cpearce
dom/ipc/ContentChild.cpp
dom/ipc/ContentParent.cpp
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -165,16 +165,17 @@
 #if defined(MOZ_WIDGET_ANDROID)
 #include "APKOpen.h"
 #endif
 
 #ifdef XP_WIN
 #include <process.h>
 #define getpid _getpid
 #include "mozilla/widget/AudioSession.h"
+#include "mozilla/audio/AudioNotificationReceiver.h"
 #endif
 
 #ifdef MOZ_X11
 #include "mozilla/X11Util.h"
 #endif
 
 #ifdef ACCESSIBILITY
 #include "nsAccessibilityService.h"
@@ -1337,16 +1338,19 @@ ContentChild::RecvReinitRendering(Endpoi
 
   VideoDecoderManagerChild::InitForContent(Move(aVideoManager));
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 ContentChild::RecvAudioDefaultDeviceChange()
 {
+#ifdef XP_WIN
+  audio::AudioNotificationReceiver::NotifyDefaultDeviceChanged();
+#endif
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 ContentChild::RecvReinitRenderingForDeviceReset()
 {
   gfxPlatform::GetPlatform()->CompositorUpdated();
 
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -232,16 +232,17 @@
 #endif
 #endif
 
 #ifdef MOZ_TOOLKIT_SEARCH
 #include "nsIBrowserSearchService.h"
 #endif
 
 #ifdef XP_WIN
+#include "mozilla/audio/AudioNotificationSender.h"
 #include "mozilla/widget/AudioSession.h"
 #endif
 
 #ifdef MOZ_CRASHREPORTER
 #include "nsThread.h"
 #include "mozilla/ipc/CrashReporterHost.h"
 #endif
 
@@ -2130,22 +2131,27 @@ ContentParent::ContentParent(ContentPare
     sContentParents = new LinkedList<ContentParent>();
   }
   sContentParents->insertBack(this);
 
   // From this point on, NS_WARNING, NS_ASSERTION, etc. should print out the
   // PID along with the warning.
   nsDebugImpl::SetMultiprocessMode("Parent");
 
-#if defined(XP_WIN) && !defined(MOZ_B2G)
+#if defined(XP_WIN)
+  if (XRE_IsParentProcess()) {
+    audio::AudioNotificationSender::Init();
+  }
+#if !defined(MOZ_B2G)
   // Request Windows message deferral behavior on our side of the PContent
   // channel. Generally only applies to the situation where we get caught in
   // a deadlock with the plugin process when sending CPOWs.
   GetIPCChannel()->SetChannelFlags(MessageChannel::REQUIRE_DEFERRED_MESSAGE_PROTECTION);
 #endif
+#endif
 
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
   ChildPrivileges privs = mRemoteType.EqualsLiteral(FILE_REMOTE_TYPE)
                           ? base::PRIVILEGES_FILEREAD
                           : base::PRIVILEGES_DEFAULT;
   mSubprocess = new GeckoChildProcessHost(GeckoProcessType_Content, privs);
 }