audio: Fix to avoid co-existance of usb and voice-usb

Avoid co-existance of different modes of the same
device. This can potentially cause conflicts as the
a base device can be operated under different modes
concurrently but yet share the same controls.
Avoid state mismatches buy avoiding such co-existance
scenanios

Bug: 63258828
Test: Duo and Hangouts valls with and without USB headset
Change-Id: I8cfa9ef700cbde3abc5696c464712608bc2b14c7
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index ee25242..677d883 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -866,7 +866,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 b14e831..fc4ebe6 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -62,6 +62,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)
@@ -1642,8 +1643,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));
@@ -1658,16 +1657,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)