hal : fix a2dp-sco concurrency issue with combo use case.

A2dp playback is not working fine if sco path setup
is done post bt_sco off.

Add speaker-safe and a2dp combo device for force restart.
Reroute existing combo use cases from speaker-btsco to speaker-a2dp
if any of use case is routed from speaker-btsco to speaker-a2dp.

Change-Id: I694145facdb0ed6d642c356c620e43297bbaaff1
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 7e08c5c..e7c8a93 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -1599,6 +1599,15 @@
   new_uc->dev d11 (a1), d2 (a2)  B1, B2
   resolution: compared to case 1, for this case, d1 and d11 are related
   then need to do the same as case 2 to siwtch to new uc
+
+case 9
+  uc->dev d1 (a1), d2(a2)        B1  B2
+  new_uc->dev d1 (a1), d22 (a2)  B1, B2
+  resolution: disable enable uc-dev on d2 since backends match
+  we cannot enable two streams on two different devices if they
+  share the same backend. This is special case for combo use case
+  with a2dp and sco devices which uses same backend.
+  e.g. speaker-a2dp and speaker-btsco
 */
 static snd_device_t derive_playback_snd_device(void * platform,
                                                struct audio_usecase *uc,
@@ -1645,6 +1654,9 @@
         if (platform_check_backends_match(d3[0], d3[1])) {
             return d2; // case 5
         } else {
+            if ((list_length(&a1) > 1) && (list_length(&a2) > 1) &&
+                 platform_check_backends_match(d1, d2))
+                return d2; //case 9
             if (list_length(&a1) > 1)
                 return d1; //case 7
             // check if d1 is related to any of d3's
@@ -1701,7 +1713,8 @@
      * with new AFE encoder format based on a2dp state
      */
     if ((SND_DEVICE_OUT_BT_A2DP == snd_device ||
-         SND_DEVICE_OUT_SPEAKER_AND_BT_A2DP == snd_device) &&
+         SND_DEVICE_OUT_SPEAKER_AND_BT_A2DP == snd_device ||
+         SND_DEVICE_OUT_SPEAKER_SAFE_AND_BT_A2DP == snd_device) &&
          audio_extn_a2dp_is_force_device_switch()) {
          force_routing = true;
          force_restart_session = true;