hal: fix output device selection when start voice call

When primary output device is set to A2DP, voice usecase
will select BT_A2DP for output device. This is not valid
device for voice call.

Fix it by add A2DP check to avoid voice call start at A2DP.

CRs-Fixed: 2227493
Change-Id: Iad5bda633f7ff2c456ae1a7b015845b37c5e1c39
diff --git a/hal/msm8916/platform.c b/hal/msm8916/platform.c
index 2e824b0..7c713e9 100644
--- a/hal/msm8916/platform.c
+++ b/hal/msm8916/platform.c
@@ -4016,8 +4016,6 @@
                 snd_device = SND_DEVICE_OUT_BT_SCO_WB;
             else
                 snd_device = SND_DEVICE_OUT_BT_SCO;
-        } else if (devices & AUDIO_DEVICE_OUT_ALL_A2DP) {
-                snd_device = SND_DEVICE_OUT_BT_A2DP;
         } else if (devices & AUDIO_DEVICE_OUT_SPEAKER) {
                 if (my_data->is_vbat_speaker) {
                     if (my_data->mono_speaker == SPKR_1)
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index e370641..6fa38f2 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -3858,8 +3858,6 @@
                     } else
                             snd_device = SND_DEVICE_OUT_VOICE_SPEAKER;
                 }
-        } else if (devices & AUDIO_DEVICE_OUT_ALL_A2DP) {
-            snd_device = SND_DEVICE_OUT_BT_A2DP;
         } else if (devices & AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET ||
                    devices & AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET) {
             snd_device = SND_DEVICE_OUT_USB_HEADSET;
diff --git a/hal/voice.c b/hal/voice.c
index 0a48a05..70bb7e1 100644
--- a/hal/voice.c
+++ b/hal/voice.c
@@ -226,16 +226,17 @@
         goto error_start_voice;
     }
 
-    uc_info->in_snd_device = SND_DEVICE_NONE;
-    uc_info->out_snd_device = SND_DEVICE_NONE;
-
-    if (audio_is_bluetooth_sco_device(uc_info->devices) && !adev->bt_sco_on) {
-        ALOGE("start_call: couldn't find BT SCO, SCO is not ready");
+    if ((audio_is_bluetooth_sco_device(uc_info->devices) && !adev->bt_sco_on) ||
+        audio_is_a2dp_out_device(uc_info->devices)) {
+        ALOGE("start_call: BT SCO is chosen but SCO is not ready, or A2DP is selected");
         adev->voice.in_call = false;
         ret = -EIO;
         goto error_start_voice;
     }
 
+    uc_info->in_snd_device = SND_DEVICE_NONE;
+    uc_info->out_snd_device = SND_DEVICE_NONE;
+
     list_add_tail(&adev->usecase_list, &uc_info->list);
 
     select_devices(adev, usecase_id);