Bug 1113086 - AudioChannel policy in Browser API - patch 4 - Muted by default, e=alwu
☠☠ backed out by aa043f7e701f ☠ ☠
authorAndrea Marchesini <amarchesini@mozilla.com>
Thu, 18 Jun 2015 15:56:58 +0100
changeset 280384 84dc903151c1583e00a1c58fabfa989426c2b87d
parent 280383 42dc5dbabdcd7b0b1552a4a10c24109186065ea9
child 280385 127cde112795a618058f490b99b47c3935c269f0
push id4932
push userjlund@mozilla.com
push dateMon, 10 Aug 2015 18:23:06 +0000
treeherdermozilla-beta@6dd5a4f5f745 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1113086
milestone41.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1113086 - AudioChannel policy in Browser API - patch 4 - Muted by default, e=alwu
dom/audiochannel/AudioChannelService.cpp
dom/audiochannel/AudioChannelService.h
modules/libpref/init/all.js
--- a/dom/audiochannel/AudioChannelService.cpp
+++ b/dom/audiochannel/AudioChannelService.cpp
@@ -35,16 +35,19 @@
 #include "mozilla/Preferences.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 using namespace mozilla::hal;
 
 namespace {
 
+// If true, any new AudioChannelAgent will be muted when created.
+bool sAudioChannelMutedByDefault = false;
+
 void
 NotifyChannelActive(uint64_t aWindowID, AudioChannel aAudioChannel,
                     bool aActive)
 {
   nsCOMPtr<nsIObserverService> observerService =
     services::GetObserverService();
   if (NS_WARN_IF(!observerService)) {
     return;
@@ -164,16 +167,19 @@ AudioChannelService::AudioChannelService
       obs->AddObserver(this, "xpcom-shutdown", false);
       obs->AddObserver(this, "inner-window-destroyed", false);
 #ifdef MOZ_WIDGET_GONK
       // To monitor the volume settings based on audio channel.
       obs->AddObserver(this, "mozsettings-changed", false);
 #endif
     }
   }
+
+  Preferences::AddBoolVarCache(&sAudioChannelMutedByDefault,
+                               "dom.audiochannel.mutedByDefault");
 }
 
 AudioChannelService::~AudioChannelService()
 {
 }
 
 void
 AudioChannelService::RegisterAudioChannelAgent(AudioChannelAgent* aAgent,
@@ -820,16 +826,22 @@ AudioChannelService::ChildStatusReceived
     return;
   }
 
   AudioChannelChildStatus* data = mPlayingChildren.LookupOrAdd(aChildID);
   data->mActiveTelephonyChannel = aTelephonyChannel;
   data->mActiveContentOrNormalChannel = aContentOrNormalChannel;
 }
 
+/* static */ bool
+AudioChannelService::IsAudioChannelMutedByDefault()
+{
+  return sAudioChannelMutedByDefault;
+}
+
 /* static */ PLDHashOperator
 AudioChannelService::NotifyEnumerator(AudioChannelAgent* aAgent,
                                       AudioChannel* aAudioChannel,
                                       void* aUnused)
 {
   aAgent->WindowVolumeChanged();
   return PL_DHASH_NEXT;
 }
--- a/dom/audiochannel/AudioChannelService.h
+++ b/dom/audiochannel/AudioChannelService.h
@@ -43,16 +43,18 @@ public:
    */
   static already_AddRefed<AudioChannelService> GetOrCreate();
 
   /**
    * Shutdown the singleton.
    */
   static void Shutdown();
 
+  static bool IsAudioChannelMutedByDefault();
+
   /**
    * Any audio channel agent that starts playing should register itself to
    * this service, sharing the AudioChannel.
    */
   void RegisterAudioChannelAgent(AudioChannelAgent* aAgent, AudioChannel aChannel);
 
   /**
    * Any audio channel agent that stops playing should unregister itself to
@@ -141,17 +143,17 @@ private:
   /* Send the default-volume-channel-changed notification */
   void SetDefaultVolumeControlChannelInternal(int32_t aChannel,
                                               bool aVisible, uint64_t aChildID);
 
   struct AudioChannelConfig final
   {
     AudioChannelConfig()
       : mVolume(1.0)
-      , mMuted(false)
+      , mMuted(IsAudioChannelMutedByDefault())
       , mNumberOfAgents(0)
     {}
 
     float mVolume;
     bool mMuted;
 
     uint32_t mNumberOfAgents;
   };
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -4924,16 +4924,18 @@ pref("reader.toolbar.vertical", true);
 
 #if defined(XP_LINUX) && defined(MOZ_GMP_SANDBOX)
 // Whether to allow, on a Linux system that doesn't support the necessary sandboxing
 // features, loading Gecko Media Plugins unsandboxed.  However, EME CDMs will not be
 // loaded without sandboxing even if this pref is changed.
 pref("media.gmp.insecure.allow", false);
 #endif
 
+pref("dom.audiochannel.mutedByDefault", false);
+
 // Use vsync aligned rendering. b2g prefs are in b2g.js.
 // Hardware vsync supported on windows, os x, and b2g.
 // Linux and fennec will use software vsync.
 pref("gfx.vsync.hw-vsync.enabled", true);
 pref("gfx.vsync.compositor", true);
 pref("gfx.vsync.refreshdriver", true);
 
 // Secure Element API