diff options
author | Zhou Song <zhous@codeaurora.org> | 2020-12-27 19:13:04 +0800 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2021-01-27 01:20:16 -0800 |
commit | 3bbcee7a5ba7fa4506624f122a97ee7f1f24636c (patch) | |
tree | f7542b52addad913db48bb5f8bc426bd4aa0b97f | |
parent | 7b59b5e4c45ec160a8f77647d31e17bf72d4da93 (diff) |
hal: switch to current active device when a2dp suspended
When SCO profile is disabled, during voice call, device can be
switched to handset first and followed with a2dpsuspended param,
device will be switched to speaker and if it shares backend with
handset, voice call can be eventually switched to speaker which
is unexpected.
Check if there's any other active usecase and switch to the same
one during check_a2dp_restore.
Change-Id: I2cabccffc5d2601362a5da16b9793c218a009822
-rw-r--r-- | hal/audio_hw.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/hal/audio_hw.c b/hal/audio_hw.c index 55f1005f..ee2ef52a 100644 --- a/hal/audio_hw.c +++ b/hal/audio_hw.c @@ -10369,9 +10369,11 @@ static void adev_snd_mon_cb(void *cookie, struct str_parms *parms) int check_a2dp_restore_l(struct audio_device *adev, struct stream_out *out, bool restore) { struct audio_usecase *uc_info; + struct audio_usecase *usecase; float left_p; float right_p; struct listnode devices; + struct listnode *node; uc_info = get_usecase_from_list(adev, out->usecase); if (uc_info == NULL) { @@ -10407,9 +10409,17 @@ int check_a2dp_restore_l(struct audio_device *adev, struct stream_out *out, bool pthread_mutex_lock(&out->latch_lock); // mute stream and switch to speaker if suspended if (!out->a2dp_muted && !out->standby) { - ALOGD("%s: selecting speaker and muting stream", __func__); assign_devices(&devices, &out->device_list); reassign_device_list(&out->device_list, AUDIO_DEVICE_OUT_SPEAKER, ""); + list_for_each(node, &adev->usecase_list) { + usecase = node_to_item(node, struct audio_usecase, list); + if ((usecase != uc_info) && + platform_check_backends_match(SND_DEVICE_OUT_SPEAKER, + usecase->out_snd_device)) { + assign_devices(&out->device_list, &usecase->stream.out->device_list); + break; + } + } left_p = out->volume_l; right_p = out->volume_r; out->a2dp_muted = true; @@ -10428,6 +10438,8 @@ int check_a2dp_restore_l(struct audio_device *adev, struct stream_out *out, bool usleep(latency * 1000); } select_devices(adev, out->usecase); + ALOGD("%s: switched to device:%s and mute stream", + __func__, platform_get_snd_device_name(uc_info->out_snd_device)); if (is_offload_usecase(out->usecase)) { if (out->offload_state == OFFLOAD_STATE_PLAYING) compress_resume(out->compr); |