Bug 1075727 - Return success/failure in hal::EnableRDS, r=dhylands
authorMichael Wu <mwu@mozilla.com>
Tue, 14 Oct 2014 15:16:22 -0400
changeset 210375 5f053be160fb41543c72b7074b48381393a30f85
parent 210374 de6a6426c5940e3fa8bae70705b7762823c550cd
child 210376 28f02b49b5e6661398c51cb31b781060bc94c008
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersdhylands
bugs1075727
milestone36.0a1
Bug 1075727 - Return success/failure in hal::EnableRDS, r=dhylands
hal/Hal.cpp
hal/Hal.h
hal/fallback/FallbackFMRadio.cpp
hal/gonk/GonkFMRadio.cpp
hal/sandbox/SandboxHal.cpp
--- a/hal/Hal.cpp
+++ b/hal/Hal.cpp
@@ -1107,20 +1107,20 @@ GetFMRadioSignalStrength() {
 }
 
 void
 CancelFMRadioSeek() {
   AssertMainThread();
   PROXY_IF_SANDBOXED(CancelFMRadioSeek());
 }
 
-void
+bool
 EnableRDS(uint32_t aMask) {
   AssertMainThread();
-  PROXY_IF_SANDBOXED(EnableRDS(aMask));
+  RETURN_PROXY_IF_SANDBOXED(EnableRDS(aMask), false);
 }
 
 void
 DisableRDS() {
   AssertMainThread();
   PROXY_IF_SANDBOXED(DisableRDS());
 }
 
--- a/hal/Hal.h
+++ b/hal/Hal.h
@@ -579,17 +579,17 @@ void CancelFMRadioSeek();
 /**
  * Get FM radio band settings by country.
  */
 hal::FMRadioSettings GetFMBandSettings(hal::FMRadioCountry aCountry);
 
 /**
  * Enable RDS data reception
  */
-void EnableRDS(uint32_t aMask);
+bool EnableRDS(uint32_t aMask);
 
 /**
  * Disable RDS data reception
  */
 void DisableRDS();
 
 /**
  * Start a watchdog to compulsively shutdown the system if it hangs.
--- a/hal/fallback/FallbackFMRadio.cpp
+++ b/hal/fallback/FallbackFMRadio.cpp
@@ -52,18 +52,20 @@ GetFMRadioSignalStrength()
 {
   return 0;
 }
 
 void
 CancelFMRadioSeek()
 {}
 
-void
+bool
 EnableRDS(uint32_t aMask)
-{}
+{
+  return false;
+}
 
 void
 DisableRDS()
 {}
 
 } // hal_impl
 } // namespace mozilla
--- a/hal/gonk/GonkFMRadio.cpp
+++ b/hal/gonk/GonkFMRadio.cpp
@@ -631,59 +631,60 @@ readRDSDataThread(void* data)
     }
   }
 
   return nullptr;
 }
 
 static int sRDSPipeFD;
 
-void
+bool
 EnableRDS(uint32_t aMask)
 {
   if (!sRadioEnabled || !sRDSSupported)
-    return;
+    return false;
 
   if (sMsmFMMode)
     setControl(V4L2_CID_PRIVATE_TAVARUA_RDSGROUP_MASK, aMask);
 
   if (sRDSEnabled)
-    return;
+    return true;
 
   int pipefd[2];
   int rc = pipe2(pipefd, O_NONBLOCK);
   if (rc < 0) {
     HAL_LOG("Could not create RDS thread signaling pipes (%d)", rc);
-    return;
+    return false;
   }
 
   ScopedClose writefd(pipefd[1]);
   ScopedClose readfd(pipefd[0]);
 
   rc = setControl(V4L2_CID_RDS_RECEPTION, true);
   if (rc < 0) {
     HAL_LOG("Could not enable RDS reception (%d)", rc);
-    return;
+    return false;
   }
 
   sRDSPipeFD = writefd;
 
   sRDSEnabled = true;
 
   rc = pthread_create(&sRDSThread, nullptr,
                       readRDSDataThread, (void*)pipefd[0]);
   if (rc) {
     HAL_LOG("Could not start RDS reception thread (%d)", rc);
     setControl(V4L2_CID_RDS_RECEPTION, false);
     sRDSEnabled = false;
-    return;
+    return false;
   }
 
   readfd.forget();
   writefd.forget();
+  return true;
 }
 
 void
 DisableRDS()
 {
   if (!sRadioEnabled || !sRDSEnabled)
     return;
 
--- a/hal/sandbox/SandboxHal.cpp
+++ b/hal/sandbox/SandboxHal.cpp
@@ -421,20 +421,21 @@ GetFMRadioSignalStrength()
 }
 
 void
 CancelFMRadioSeek()
 {
   NS_RUNTIMEABORT("FM radio cannot be called from sandboxed contexts.");
 }
 
-void
+bool
 EnableRDS(uint32_t aMask)
 {
   NS_RUNTIMEABORT("FM radio cannot be called from sandboxed contexts.");
+  return false;
 }
 
 void
 DisableRDS()
 {
   NS_RUNTIMEABORT("FM radio cannot be called from sandboxed contexts.");
 }