Bug 1089526 - Change speaker state. r=baku
authorAlastor Wu <alwu@mozilla.com>
Mon, 16 Feb 2015 10:50:56 +0800
changeset 263495 f8e635d611be9b5ebb9cd7ccc62c92fbe811e19b
parent 263494 48e7d4065ae2b31a87f3827545d179b766a6da7e
child 263496 d99168a16639f5aa0feaf3b68bc7beb8c150e056
push id4718
push userraliiev@mozilla.com
push dateMon, 11 May 2015 18:39:53 +0000
treeherdermozilla-beta@c20c4ef55f08 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1089526
milestone39.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 1089526 - Change speaker state. r=baku
dom/audiochannel/AudioChannelService.cpp
dom/speakermanager/SpeakerManager.cpp
dom/speakermanager/SpeakerManagerService.cpp
--- a/dom/audiochannel/AudioChannelService.cpp
+++ b/dom/audiochannel/AudioChannelService.cpp
@@ -355,16 +355,23 @@ AudioChannelService::GetState(AudioChann
   }
 
   bool oldElementHidden = data->mElementHidden;
   // Update visibility.
   data->mElementHidden = aElementHidden;
 
   data->mState = GetStateInternal(data->mChannel, CONTENT_PROCESS_ID_MAIN,
                                 aElementHidden, oldElementHidden);
+  #ifdef MOZ_WIDGET_GONK
+    bool active = AnyAudioChannelIsActive();
+    for (uint32_t i = 0; i < mSpeakerManager.Length(); i++) {
+      mSpeakerManager[i]->SetAudioChannelActive(active);
+    }
+  #endif
+
   return data->mState;
 }
 
 AudioChannelState
 AudioChannelService::GetStateInternal(AudioChannel aChannel, uint64_t aChildID,
                                       bool aElementHidden,
                                       bool aElementWasHidden)
 {
--- a/dom/speakermanager/SpeakerManager.cpp
+++ b/dom/speakermanager/SpeakerManager.cpp
@@ -206,19 +206,18 @@ SpeakerManager::HandleEvent(nsIDOMEvent*
     }
   }
   return NS_OK;
 }
 
 void
 SpeakerManager::SetAudioChannelActive(bool isActive)
 {
-  if (!isActive && !mVisible) {
+  if (mForcespeaker) {
     SpeakerManagerService *service =
       SpeakerManagerService::GetOrCreateSpeakerManagerService();
     MOZ_ASSERT(service);
-
-    service->ForceSpeaker(false, mVisible);
+    service->ForceSpeaker(isActive, mVisible);
   }
 }
 
 } // namespace dom
 } // namespace mozilla
--- a/dom/speakermanager/SpeakerManagerService.cpp
+++ b/dom/speakermanager/SpeakerManagerService.cpp
@@ -141,18 +141,19 @@ void
 SpeakerManagerService::SetAudioChannelActive(bool aIsActive)
 {
   if (!aIsActive && !mVisible) {
     ForceSpeaker(!mOrgSpeakerStatus, mVisible);
   }
 }
 
 NS_IMETHODIMP
-SpeakerManagerService::Observe(nsISupports* aSubject, const char*
-                               aTopic, const char16_t* aData)
+SpeakerManagerService::Observe(nsISupports* aSubject,
+                               const char* aTopic,
+                               const char16_t* aData)
 {
   if (!strcmp(aTopic, "ipc:content-shutdown")) {
     nsCOMPtr<nsIPropertyBag2> props = do_QueryInterface(aSubject);
     if (!props) {
       NS_WARNING("ipc:content-shutdown message without property bag as subject");
       return NS_OK;
     }