Bug 949855 - No sound comes out when FM Radio is first time started. r=mchen, a=koi+
authorPin Zhang <pzhang@mozilla.com>
Wed, 18 Dec 2013 13:30:56 +0800
changeset 175400 e0b9aa6cc835cf0c59c48fe544410cdc0f11b74f
parent 175399 089dca4d34d96119895eac031e2cb86301c78bdb
child 175401 f429fc42cbc3c49a9e35a8ede98be78172804cd7
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmchen, koi
bugs949855
milestone28.0a2
Bug 949855 - No sound comes out when FM Radio is first time started. r=mchen, a=koi+
dom/fmradio/FMRadioService.cpp
--- a/dom/fmradio/FMRadioService.cpp
+++ b/dom/fmradio/FMRadioService.cpp
@@ -118,17 +118,16 @@ public:
   NS_IMETHOD Run()
   {
     FMRadioSettings info;
     info.upperLimit() = mUpperLimit;
     info.lowerLimit() = mLowerLimit;
     info.spaceType() = mSpaceType;
 
     EnableFMRadio(info);
-    IFMRadioService::Singleton()->EnableAudio(true);
 
     return NS_OK;
   }
 
 private:
   int32_t mUpperLimit;
   int32_t mLowerLimit;
   int32_t mSpaceType;
@@ -297,19 +296,19 @@ FMRadioService::EnableAudio(bool aAudioE
   MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!");
 
   nsCOMPtr<nsIAudioManager> audioManager =
     do_GetService("@mozilla.org/telephony/audiomanager;1");
   if (!audioManager) {
     return;
   }
 
-  bool AudioEnabled;
-  audioManager->GetFmRadioAudioEnabled(&AudioEnabled);
-  if (AudioEnabled != aAudioEnabled) {
+  bool audioEnabled;
+  audioManager->GetFmRadioAudioEnabled(&audioEnabled);
+  if (audioEnabled != aAudioEnabled) {
     audioManager->SetFmRadioAudioEnabled(aAudioEnabled);
   }
 }
 
 /**
  * Round the frequency to match the range of frequency and the channel width. If
  * the given frequency is out of range, return 0. For example:
  *  - lower: 87500KHz, upper: 108000KHz, channel width: 200KHz
@@ -731,16 +730,22 @@ FMRadioService::Notify(const FMRadioOper
 
       // Fire success callback on the enable request.
       TransitionState(SuccessResponse(), Enabled);
 
       // To make sure the FM app will get the right frequency after the FM
       // radio is enabled, we have to set the frequency first.
       SetFMRadioFrequency(mPendingFrequencyInKHz);
 
+      // Bug 949855: enable audio after the FM radio HW is enabled, to make sure
+      // 'hw.fm.isAnalog' could be detected as |true| during first time launch.
+      // This case is for audio output on analog path, i.e. 'ro.moz.fm.noAnalog'
+      // is not |true|.
+      EnableAudio(true);
+
       // Update the current frequency without sending the`FrequencyChanged`
       // event, to make sure the FM app will get the right frequency when the
       // `EnabledChange` event is sent.
       mPendingFrequencyInKHz = GetFMRadioFrequency();
       UpdatePowerState();
 
       // The frequency was changed from '0' to some meaningful number, so we
       // should send the `FrequencyChanged` event manually.