Bug 834200 - [Audio] Hook AudioManager::SetPhoneState for getting ring & in_call then register into AudioChannelService. r=baku, a=tef+
authorMarco Chen <mchen@mozilla.com>
Mon, 04 Feb 2013 11:23:06 +0800
changeset 120742 e0cdaff13f73db91c6613f74123f04d14212e4c4
parent 120741 3d2d50b222e927e45e8420e5481e54df4818912f
child 120743 01361f5fda963e3dbc2f58366450d6f728ba837e
push id22389
push useramarchesini@mozilla.com
push dateMon, 04 Feb 2013 12:37:44 +0000
treeherdermozilla-inbound@e0cdaff13f73 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku, tef
bugs834200
milestone21.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 834200 - [Audio] Hook AudioManager::SetPhoneState for getting ring & in_call then register into AudioChannelService. r=baku, a=tef+
dom/system/gonk/AudioManager.cpp
--- a/dom/system/gonk/AudioManager.cpp
+++ b/dom/system/gonk/AudioManager.cpp
@@ -303,30 +303,34 @@ AudioManager::SetPhoneState(int32_t aSta
   }
 
   if (AudioSystem::setPhoneState(aState)) {
     return NS_ERROR_FAILURE;
   }
 
   mPhoneState = aState;
 
-  if (aState == PHONE_STATE_IN_CALL) {
-    if (!mPhoneAudioAgent) {
-      mPhoneAudioAgent = do_CreateInstance("@mozilla.org/audiochannelagent;1");
-      MOZ_ASSERT(mPhoneAudioAgent);
+  if (mPhoneAudioAgent) {
+    mPhoneAudioAgent->StopPlaying();
+    mPhoneAudioAgent = nullptr;
+  }
+
+  if (aState == PHONE_STATE_IN_CALL || aState == PHONE_STATE_RINGTONE) {
+    mPhoneAudioAgent = do_CreateInstance("@mozilla.org/audiochannelagent;1");
+    MOZ_ASSERT(mPhoneAudioAgent);
+    if (aState == PHONE_STATE_IN_CALL) {
       // Telephony doesn't be paused by any other channels.
       mPhoneAudioAgent->Init(AUDIO_CHANNEL_TELEPHONY, nullptr);
+    } else {
+      mPhoneAudioAgent->Init(AUDIO_CHANNEL_RINGER, nullptr);
+    }
 
-      // Telephony can always play.
-      bool canPlay;
-      mPhoneAudioAgent->StartPlaying(&canPlay);
-    }
-  } else if (mPhoneAudioAgent) {
-    mPhoneAudioAgent->StopPlaying();
-    mPhoneAudioAgent = nullptr;
+    // Telephony can always play.
+    bool canPlay;
+    mPhoneAudioAgent->StartPlaying(&canPlay);
   }
 
   return NS_OK;
 }
 
 //
 // Kids, don't try this at home.  We want this to link and work on
 // both GB and ICS.  Problem is, the symbol exported by audioflinger