Bug 862306 - Route audio stream to BT_SCO in AudioManager. r=mwu, a=leo+
authorRandy Lin <rlin@mozilla.com>
Thu, 18 Apr 2013 16:47:09 +0200
changeset 119127 a677aace8abbe5a987e89a1f7754fedc387227c9
parent 119126 3533e3017f32746a3f0a60cc35a0d247e3d2c987
child 119128 e0bab06d5d36102508469084d265528c1374f343
push id685
push userryanvm@gmail.com
push dateThu, 18 Apr 2013 18:40:39 +0000
reviewersmwu, leo
bugs862306
milestone18.0
Bug 862306 - Route audio stream to BT_SCO in AudioManager. r=mwu, a=leo+
dom/system/gonk/AudioManager.cpp
--- a/dom/system/gonk/AudioManager.cpp
+++ b/dom/system/gonk/AudioManager.cpp
@@ -149,21 +149,27 @@ AudioManager::Observe(nsISupports* aSubj
       String8 cmd;
       cmd.appendFormat("bt_samplerate=%d", kBtSampleRate);
       AudioSystem::setParameters(0, cmd);
       const char* address = NS_ConvertUTF16toUTF8(nsDependentString(aData)).get();
       AudioSystem::setDeviceConnectionState(AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET,
                                             AUDIO_POLICY_DEVICE_STATE_AVAILABLE, address);
       AudioSystem::setDeviceConnectionState(AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET,
                                             AUDIO_POLICY_DEVICE_STATE_AVAILABLE, address);
+      SetForceForUse(nsIAudioManager::USE_COMMUNICATION, nsIAudioManager::FORCE_BT_SCO);
     } else {
       AudioSystem::setDeviceConnectionState(AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET,
                                             AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE, "");
       AudioSystem::setDeviceConnectionState(AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET,
                                             AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE, "");
+      // only force to none if the current force setting is bt_sco
+      int32_t force;
+      GetForceForUse(nsIAudioManager::USE_COMMUNICATION, &force);
+      if (force == nsIAudioManager::FORCE_BT_SCO)
+        SetForceForUse(nsIAudioManager::USE_COMMUNICATION, nsIAudioManager::FORCE_NONE);
     }
 
     return NS_OK;
   }
   return NS_ERROR_UNEXPECTED;
 }
 
 static void