audio: Fix to avoid co-existance of usb and voice-usb am: 39c55dcd47
am: b88bda1185

Change-Id: I0058e8071fdfd2db48e7b737c684883de39d939b
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 3a4729d..c821263 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -858,7 +858,8 @@
 
         if (force_routing ||
             (usecase->out_snd_device != snd_device &&
-             usecase->devices & AUDIO_DEVICE_OUT_ALL_CODEC_BACKEND &&
+             (usecase->devices & AUDIO_DEVICE_OUT_ALL_CODEC_BACKEND ||
+              usecase->devices & (AUDIO_DEVICE_OUT_USB_DEVICE|AUDIO_DEVICE_OUT_USB_HEADSET)) &&
              platform_check_backends_match(snd_device, usecase->out_snd_device))) {
             ALOGV("%s: Usecase (%s) is active on (%s) - disabling ..",
                   __func__, use_case_table[usecase->id],
diff --git a/hal/msm8916/platform.c b/hal/msm8916/platform.c
index bc3e844..c113eca 100644
--- a/hal/msm8916/platform.c
+++ b/hal/msm8916/platform.c
@@ -60,6 +60,7 @@
 /* fallback app type if the default app type from acdb loader fails */
 #define DEFAULT_APP_TYPE_RX_PATH  0x11130
 #define DEFAULT_APP_TYPE_TX_PATH  0x11132
+#define DEFAULT_RX_BACKEND "SLIMBUS_0_RX"
 
 /* Retry for delay in FW loading*/
 #define RETRY_NUMBER 20
@@ -1174,6 +1175,10 @@
     if (NULL != be_itf1 && NULL != be_itf2) {
         if ((NULL == strstr(be_itf2, be_itf1)) && (NULL == strstr(be_itf1, be_itf2)))
             result = false;
+    } else if (NULL != be_itf2 && (NULL == strstr(be_itf2, DEFAULT_RX_BACKEND))) {
+        result = false;
+    } else if (NULL != be_itf1 && (NULL == strstr(be_itf1, DEFAULT_RX_BACKEND))) {
+        result = false;
     }
 
     ALOGV("%s: be_itf1 = %s, be_itf2 = %s, match %d", __func__, be_itf1, be_itf2, result);
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index 0f759a5..d6b393f 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -64,6 +64,7 @@
 
 #define DEFAULT_APP_TYPE_RX_PATH  69936
 #define DEFAULT_APP_TYPE_TX_PATH  69938
+#define DEFAULT_RX_BACKEND "SLIMBUS_0_RX"
 
 #define TOSTRING_(x) #x
 #define TOSTRING(x) TOSTRING_(x)
@@ -1644,8 +1645,6 @@
 
 bool platform_check_backends_match(snd_device_t snd_device1, snd_device_t snd_device2)
 {
-    bool result = true;
-
     ALOGV("%s: snd_device1 = %s, snd_device2 = %s", __func__,
                 platform_get_snd_device_name(snd_device1),
                 platform_get_snd_device_name(snd_device2));
@@ -1660,16 +1659,24 @@
                 platform_get_snd_device_name(snd_device2));
         return false;
     }
+
     const char * be_itf1 = hw_interface_table[snd_device1];
     const char * be_itf2 = hw_interface_table[snd_device2];
-
-    if (NULL != be_itf1 && NULL != be_itf2) {
-        if ((NULL == strstr(be_itf2, be_itf1)) && (NULL == strstr(be_itf1, be_itf2)))
-            result = false;
+    /*
+      hw_interface_table has overrides for a snd_device.
+      if there is no entry for a device, assume DEFAULT_RX_BACKEND
+    */
+    if (be_itf1 == NULL) {
+        be_itf1 = DEFAULT_RX_BACKEND;
     }
-
-    ALOGV("%s: be_itf1 = %s, be_itf2 = %s, match %d", __func__, be_itf1, be_itf2, result);
-    return result;
+    if (be_itf2 == NULL) {
+        be_itf2 = DEFAULT_RX_BACKEND;
+    }
+    ALOGV("%s: be_itf1 = %s, be_itf2 = %s", __func__, be_itf1, be_itf2);
+    /*
+      this takes care of finding a device within a combo device pair as well
+     */
+    return strstr(be_itf1, be_itf2) != NULL || strstr(be_itf2, be_itf1) != NULL;
 }
 
 int platform_get_pcm_device_id(audio_usecase_t usecase, int device_type)