Bug 859727 - Should set force to FORCE_NONE after Sco is disconnected, r=echou
authorGina Yeh <gyeh@mozilla.com>
Fri, 12 Apr 2013 16:27:21 +0800
changeset 128569 0b32af5340c3bdaad55ccfc054558f41ee3d852a
parent 128568 6d4badbe3db200c521419bbb61137c61b08ce8bc
child 128570 f26cd5d8fe7f8180a9f5f40882afcc78cd72cc68
push id26392
push usergyeh@mozilla.com
push dateFri, 12 Apr 2013 08:27:32 +0000
treeherdermozilla-inbound@0b32af5340c3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersechou
bugs859727
milestone23.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 859727 - Should set force to FORCE_NONE after Sco is disconnected, r=echou
dom/bluetooth/BluetoothScoManager.cpp
--- a/dom/bluetooth/BluetoothScoManager.cpp
+++ b/dom/bluetooth/BluetoothScoManager.cpp
@@ -61,39 +61,41 @@ public:
 
   ~BluetoothScoManagerObserver()
   {
     Shutdown();
   }
 };
 
 void
-BluetoothScoManager::NotifyAudioManager(const nsAString& aAddress) {
+BluetoothScoManager::NotifyAudioManager(const nsAString& aAddress)
+{
   MOZ_ASSERT(NS_IsMainThread());
 
   nsCOMPtr<nsIObserverService> obs =
     do_GetService("@mozilla.org/observer-service;1");
   NS_ENSURE_TRUE_VOID(obs);
 
+  nsCOMPtr<nsIAudioManager> am =
+    do_GetService("@mozilla.org/telephony/audiomanager;1");
+  NS_ENSURE_TRUE_VOID(am);
+
   if (aAddress.IsEmpty()) {
     if (NS_FAILED(obs->NotifyObservers(nullptr, BLUETOOTH_SCO_STATUS_CHANGED, nullptr))) {
       NS_WARNING("Failed to notify bluetooth-sco-status-changed observsers!");
       return;
     }
+    am->SetForceForUse(am->USE_COMMUNICATION, am->FORCE_NONE);
   } else {
     if (NS_FAILED(obs->NotifyObservers(nullptr, BLUETOOTH_SCO_STATUS_CHANGED, aAddress.BeginReading()))) {
       NS_WARNING("Failed to notify bluetooth-sco-status-changed observsers!");
       return;
     }
+    am->SetForceForUse(am->USE_COMMUNICATION, am->FORCE_BT_SCO);
   }
-
-  nsCOMPtr<nsIAudioManager> am =
-    do_GetService("@mozilla.org/telephony/audiomanager;1");
-  NS_ENSURE_TRUE_VOID(am);
-  am->SetForceForUse(am->USE_COMMUNICATION, am->FORCE_BT_SCO);
 }
 
 NS_IMPL_ISUPPORTS1(BluetoothScoManagerObserver, nsIObserver)
 
 namespace {
 StaticAutoPtr<BluetoothScoManager> gBluetoothScoManager;
 StaticRefPtr<BluetoothScoManagerObserver> sScoObserver;
 bool gInShutdown = false;