hal: fix sound leak when receiving voip call
when watching live streaming in fore ground,receive a voip call
and observe a sound leak.
corection is done for assigning the speaker after muting the stream to the
structure. This help in getting the time for exiting output channel for stream.
Change-Id: I9c03372a37207ebc5e11323ee08ee2618b83a417
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 3fcaa45..cf24a5c 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -11101,19 +11101,6 @@
pthread_mutex_lock(&out->latch_lock);
// mute stream and switch to speaker if suspended
if (!out->a2dp_muted && !out->standby) {
- 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->type != PCM_CAPTURE) && (usecase != uc_info) &&
- !is_a2dp_out_device_type(&usecase->stream.out->device_list) &&
- !is_sco_out_device_type(&usecase->stream.out->device_list) &&
- platform_check_backends_match(SND_DEVICE_OUT_SPEAKER,
- usecase->out_snd_device)) {
- assign_devices(&out->device_list, &usecase->stream.out->device_list);
- break;
- }
- }
if ((is_a2dp_out_device_type(&devices) && list_length(&devices) == 1) ||
(uc_info->out_snd_device == SND_DEVICE_OUT_BT_A2DP)) {
out->a2dp_muted = true;
@@ -11134,6 +11121,19 @@
usleep(latency * 1000);
}
}
+ 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->type != PCM_CAPTURE) && (usecase != uc_info) &&
+ !is_a2dp_out_device_type(&usecase->stream.out->device_list) &&
+ !is_sco_out_device_type(&usecase->stream.out->device_list) &&
+ platform_check_backends_match(SND_DEVICE_OUT_SPEAKER,
+ usecase->out_snd_device)) {
+ assign_devices(&out->device_list, &usecase->stream.out->device_list);
+ break;
+ }
+ }
select_devices(adev, out->usecase);
ALOGD("%s: switched to device:%s and stream muted:%d", __func__,
platform_get_snd_device_name(uc_info->out_snd_device), out->a2dp_muted);