summaryrefslogtreecommitdiffstats
path: root/hal
diff options
context:
space:
mode:
authorZhou Song <zhous@codeaurora.org>2019-05-21 18:08:51 +0800
committerZhou Song <zhous@codeaurora.org>2019-05-23 11:04:04 +0800
commita32012a6c022d463f5c3602c1018ed2d526cc2cc (patch)
tree543cb48dba5f7378b5fca590d57cd3ddce72c0c9 /hal
parent8a314f777c2d599988e457512a8bffe530db3a52 (diff)
downloadhardware_qcom_audio-a32012a6c022d463f5c3602c1018ed2d526cc2cc.tar.gz
hardware_qcom_audio-a32012a6c022d463f5c3602c1018ed2d526cc2cc.tar.bz2
hardware_qcom_audio-a32012a6c022d463f5c3602c1018ed2d526cc2cc.zip
hal: force device switch when BT SCO is off
When BT SCO is off, the active use cases may still stay on SCO devices which is not expected, switch the device to handset or handset mic before receiving routing command from audio policy manager. Change-Id: I5817824fd921b2d5f9e17ee8aed02d0bd2cee0fc
Diffstat (limited to 'hal')
-rw-r--r--hal/audio_hw.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 1638a229..9769653c 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -6815,6 +6815,8 @@ static int adev_set_parameters(struct audio_hw_device *dev, const char *kvpairs)
int val;
int ret;
int status = 0;
+ struct listnode *node;
+ struct audio_usecase *usecase = NULL;
ALOGD("%s: enter: %s", __func__, kvpairs);
parms = str_parms_create_str(kvpairs);
@@ -6822,16 +6824,30 @@ static int adev_set_parameters(struct audio_hw_device *dev, const char *kvpairs)
if (!parms)
goto error;
+ pthread_mutex_lock(&adev->lock);
ret = str_parms_get_str(parms, "BT_SCO", value, sizeof(value));
if (ret >= 0) {
/* When set to false, HAL should disable EC and NS */
- if (strcmp(value, AUDIO_PARAMETER_VALUE_ON) == 0)
+ if (strcmp(value, AUDIO_PARAMETER_VALUE_ON) == 0){
adev->bt_sco_on = true;
- else
+ } else {
+ ALOGD("route device to handset/mic when sco is off");
adev->bt_sco_on = false;
+ list_for_each(node, &adev->usecase_list) {
+ usecase = node_to_item(node, struct audio_usecase, list);
+ if ((usecase->type == PCM_PLAYBACK) && usecase->stream.out &&
+ (usecase->stream.out->devices & AUDIO_DEVICE_OUT_ALL_SCO))
+ usecase->stream.out->devices = AUDIO_DEVICE_OUT_EARPIECE;
+ else if ((usecase->type == PCM_CAPTURE) && usecase->stream.in &&
+ (usecase->stream.in->device & AUDIO_DEVICE_IN_ALL_SCO))
+ usecase->stream.in->device = AUDIO_DEVICE_IN_BUILTIN_MIC;
+ else
+ continue;
+ select_devices(adev, usecase->id);
+ }
+ }
}
- pthread_mutex_lock(&adev->lock);
status = voice_set_parameters(adev, parms);
if (status != 0)
goto done;