Bug 938809 - Support calling seeking/tuning functions off main thread in HAL, r=dhylands
authorMichael Wu <mwu@mozilla.com>
Tue, 29 Jul 2014 20:28:12 -0400
changeset 196812 ef03bec1272a480fe6a86afa9b23be4e865ea867
parent 196811 b8d783033da73ad39250b48472258954958e30e9
child 196813 4cc9e0c5dd67f9dabae2b45c3c212a985624e0b4
push id9311
push usermwu@mozilla.com
push dateWed, 30 Jul 2014 17:49:12 +0000
treeherderb2g-inbound@4cc9e0c5dd67 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdhylands
bugs938809
milestone34.0a1
Bug 938809 - Support calling seeking/tuning functions off main thread in HAL, r=dhylands
hal/Hal.h
hal/gonk/GonkFMRadio.cpp
--- a/hal/Hal.h
+++ b/hal/Hal.h
@@ -521,26 +521,31 @@ void EnableFMRadio(const hal::FMRadioSet
 /**
  * Disable the FM radio.
  */
 void DisableFMRadio();
 
 /**
  * Seek to an available FM radio station.
  *
+ * This can be called off main thread, but all calls must be completed
+ * before calling DisableFMRadio.
  */
 void FMRadioSeek(const hal::FMRadioSeekDirection& aDirection);
 
 /**
  * Get the current FM radio settings.
  */
 void GetFMRadioSettings(hal::FMRadioSettings* aInfo);
 
 /**
  * Set the FM radio's frequency.
+ *
+ * This can be called off main thread, but all calls must be completed
+ * before calling DisableFMRadio.
  */
 void SetFMRadioFrequency(const uint32_t frequency);
 
 /**
  * Get the FM radio's frequency.
  */
 uint32_t GetFMRadioFrequency();
 
--- a/hal/gonk/GonkFMRadio.cpp
+++ b/hal/gonk/GonkFMRadio.cpp
@@ -397,30 +397,28 @@ FMRadioSeek(const hal::FMRadioSeekDirect
 #else
   seek.spacing = sRadioSettings.spaceType() * 1000;
 #endif
 
   int rc = ioctl(sRadioFD, VIDIOC_S_HW_FREQ_SEEK, &seek);
   if (sMsmFMMode && rc >= 0)
     return;
 
-  hal::FMRadioOperationInformation info;
-  info.operation() = hal::FM_RADIO_OPERATION_SEEK;
-  info.status() = rc < 0 ? hal::FM_RADIO_OPERATION_STATUS_FAIL :
-                           hal::FM_RADIO_OPERATION_STATUS_SUCCESS;
-  hal::NotifyFMRadioStatus(info);
+  NS_DispatchToMainThread(new RadioUpdate(hal::FM_RADIO_OPERATION_SEEK,
+                                          rc < 0 ?
+                                          hal::FM_RADIO_OPERATION_STATUS_FAIL :
+                                          hal::FM_RADIO_OPERATION_STATUS_SUCCESS));
 
   if (rc < 0) {
     HAL_LOG(("Could not initiate hardware seek"));
     return;
   }
 
-  info.operation() = hal::FM_RADIO_OPERATION_TUNE;
-  info.status() = hal::FM_RADIO_OPERATION_STATUS_SUCCESS;
-  hal::NotifyFMRadioStatus(info);
+  NS_DispatchToMainThread(new RadioUpdate(hal::FM_RADIO_OPERATION_TUNE,
+                                          hal::FM_RADIO_OPERATION_STATUS_SUCCESS));
 }
 
 void
 GetFMRadioSettings(hal::FMRadioSettings* aInfo)
 {
   if (!sRadioEnabled) {
     return;
   }
@@ -445,21 +443,20 @@ SetFMRadioFrequency(const uint32_t frequ
 
   int rc = ioctl(sRadioFD, VIDIOC_S_FREQUENCY, &freq);
   if (rc < 0)
     HAL_LOG(("Could not set radio frequency"));
 
   if (sMsmFMMode && rc >= 0)
     return;
 
-  hal::FMRadioOperationInformation info;
-  info.operation() = hal::FM_RADIO_OPERATION_TUNE;
-  info.status() = rc < 0 ? hal::FM_RADIO_OPERATION_STATUS_FAIL :
-                           hal::FM_RADIO_OPERATION_STATUS_SUCCESS;
-  hal::NotifyFMRadioStatus(info);
+  NS_DispatchToMainThread(new RadioUpdate(hal::FM_RADIO_OPERATION_TUNE,
+                                          rc < 0 ?
+                                          hal::FM_RADIO_OPERATION_STATUS_FAIL :
+                                          hal::FM_RADIO_OPERATION_STATUS_SUCCESS));
 }
 
 uint32_t
 GetFMRadioFrequency()
 {
   if (!sRadioEnabled)
     return 0;