hal: route use cases properly to SCO device when it arrives
When ever BT_SCO=ON arrives, make sure to route
all use cases to SCO device, otherwise due to delay
in BT_SCO=ON and lack of synchronization for create audio patch
request for SCO device, some times use case not routed properly to
SCO device during VOIP call
Change-Id: I360d195858c26ace18e92fc0975ff3108ba866e4
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 8a6011b..3b784b8 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -8747,7 +8747,30 @@
/* When set to false, HAL should disable EC and NS */
if (strcmp(value, AUDIO_PARAMETER_VALUE_ON) == 0){
adev->bt_sco_on = true;
- } else {
+ /*
+ * When ever BT_SCO=ON arrives, make sure to route
+ * all use cases to SCO device, otherwise due to delay in
+ * BT_SCO=ON and lack of synchronization with create audio patch
+ * request for SCO device, some times use case not routed properly to
+ * SCO device
+ */
+ struct audio_usecase *usecase;
+ struct listnode *node;
+ list_for_each(node, &adev->usecase_list) {
+ usecase = node_to_item(node, struct audio_usecase, list);
+ if (usecase->stream.in && (usecase->type == PCM_CAPTURE) &&
+ (!is_btsco_device(SND_DEVICE_NONE, usecase->in_snd_device))) {
+ ALOGD("BT_SCO ON, switch all in use case to it");
+ select_devices(adev, usecase->id);
+ }
+ if (usecase->stream.out && (usecase->type == PCM_PLAYBACK) &&
+ (!is_btsco_device(usecase->out_snd_device, SND_DEVICE_NONE))) {
+ ALOGD("BT_SCO ON, switch all out use case to it");
+ select_devices(adev, usecase->id);
+ }
+ }
+ }
+ else {
adev->bt_sco_on = false;
audio_extn_sco_reset_configuration();
}