Bug 1229234 - Enable audio_is_output_device() on ICS r=alwu
authorSotaro Ikeda <sotaro.ikeda.g@gmail.com>
Sun, 13 Dec 2015 18:13:02 -0800
changeset 276290 03e8c3402a37e4216b0ea57ff2b29f4f4445200b
parent 276289 09fb57f8535835a956e13b77e0a3b14325a4837f
child 276291 cdae79139898baa6909ad3b74f9322989a0db1b1
push id16631
push userphilringnalda@gmail.com
push dateMon, 14 Dec 2015 06:36:29 +0000
treeherderfx-team@871d92a1b070 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersalwu
bugs1229234
milestone45.0a1
Bug 1229234 - Enable audio_is_output_device() on ICS r=alwu
dom/system/gonk/AudioManager.cpp
dom/system/gonk/android_audio/AudioSystem.h
--- a/dom/system/gonk/AudioManager.cpp
+++ b/dom/system/gonk/AudioManager.cpp
@@ -1282,19 +1282,17 @@ AudioManager::SelectDeviceFromDevices(ui
       device = AUDIO_DEVICE_OUT_SPDIF;
     } else if ((device & AUDIO_DEVICE_OUT_AUX_LINE) != 0) {
        device = AUDIO_DEVICE_OUT_AUX_LINE;
 #endif
     } else {
        device &= AUDIO_DEVICE_OUT_ALL_A2DP;
     }
   }
-#if ANDROID_VERSION >= 17
   MOZ_ASSERT(audio_is_output_device(device));
-#endif
   return device;
 }
 AudioManager::VolumeStreamState::VolumeStreamState(AudioManager& aManager,
                                                    int32_t aStreamType)
   : mManager(aManager)
   , mStreamType(aStreamType)
   , mLastDevices(0)
   , mIsDevicesChanged(true)
--- a/dom/system/gonk/android_audio/AudioSystem.h
+++ b/dom/system/gonk/android_audio/AudioSystem.h
@@ -542,26 +542,31 @@ enum {
     AUDIO_DEVICE_IN_ALL_SCO = AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET,
     AUDIO_DEVICE_IN_ALL_USB = (AUDIO_DEVICE_IN_USB_ACCESSORY |
                                AUDIO_DEVICE_IN_USB_DEVICE),
 };
 
 typedef uint32_t audio_devices_t;
 #endif
 
-#if ANDROID_VERSION >= 17
-static inline bool audio_is_output_device(audio_devices_t device)
+static inline bool audio_is_output_device(uint32_t device)
 {
+#if ANDROID_VERSION < 17
+    if ((__builtin_popcount(device) == 1) && ((device & ~AUDIO_DEVICE_OUT_ALL) == 0))
+        return true;
+    else
+        return false;
+#else
     if (((device & AUDIO_DEVICE_BIT_IN) == 0) &&
             (__builtin_popcount(device) == 1) && ((device & ~AUDIO_DEVICE_OUT_ALL) == 0))
         return true;
     else
         return false;
+#endif
 }
-#endif
 
 /* device connection states used for audio_policy->set_device_connection_state()
  *  */
 typedef enum {
     AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE,
     AUDIO_POLICY_DEVICE_STATE_AVAILABLE,
 
     AUDIO_POLICY_DEVICE_STATE_CNT,