From f25bbc3a43b7c4b90c632d6e1e8ace2e1f510caa Mon Sep 17 00:00:00 2001 From: Andrea Marchesini Date: Fri, 10 Jul 2015 17:38:49 +0100 Subject: [PATCH] Bug 1113086 - AudioChannel policy in Browser API - patch 4 - Muted by default, e=alwu --- dom/audiochannel/AudioChannelService.cpp | 12 ++++++++++++ dom/audiochannel/AudioChannelService.h | 4 +++- modules/libpref/init/all.js | 2 ++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/dom/audiochannel/AudioChannelService.cpp b/dom/audiochannel/AudioChannelService.cpp index 253ff3a7f57..30fa3268523 100644 --- a/dom/audiochannel/AudioChannelService.cpp +++ b/dom/audiochannel/AudioChannelService.cpp @@ -40,6 +40,9 @@ 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) @@ -169,6 +172,9 @@ AudioChannelService::AudioChannelService() #endif } } + + Preferences::AddBoolVarCache(&sAudioChannelMutedByDefault, + "dom.audiochannel.mutedByDefault"); } AudioChannelService::~AudioChannelService() @@ -825,6 +831,12 @@ AudioChannelService::ChildStatusReceived(uint64_t aChildID, data->mActiveContentOrNormalChannel = aContentOrNormalChannel; } +/* static */ bool +AudioChannelService::IsAudioChannelMutedByDefault() +{ + return sAudioChannelMutedByDefault; +} + /* static */ PLDHashOperator AudioChannelService::NotifyEnumerator(AudioChannelAgent* aAgent, AudioChannel* aAudioChannel, diff --git a/dom/audiochannel/AudioChannelService.h b/dom/audiochannel/AudioChannelService.h index 2b9d10c63d6..1c8345fe162 100644 --- a/dom/audiochannel/AudioChannelService.h +++ b/dom/audiochannel/AudioChannelService.h @@ -48,6 +48,8 @@ public: */ static void Shutdown(); + static bool IsAudioChannelMutedByDefault(); + /** * Any audio channel agent that starts playing should register itself to * this service, sharing the AudioChannel. @@ -146,7 +148,7 @@ private: { AudioChannelConfig() : mVolume(1.0) - , mMuted(false) + , mMuted(IsAudioChannelMutedByDefault()) , mNumberOfAgents(0) {} diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index 7171a176fcc..8a0fda5f19c 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -4957,6 +4957,8 @@ pref("reader.toolbar.vertical", true); 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.