From c576a455900013b375acd1edf694760ef5629381 Mon Sep 17 00:00:00 2001 From: Zhou Song Date: Mon, 9 Sep 2019 14:17:40 +0800 Subject: [PATCH] hal: tear down a2dp path for non-offloaded streams when suspended When A2dp device is already active and A2dpsuspended=true is received, audio route will be switched to sco mic and BT firmware will open the RX path as 8KHz, while a2dp playback can still keep sending data over slimbus, this can cause noise heard in the BT headset. To avoid this, tear down the A2dp playback before SCO is enabled. Change-Id: Ic0b8d1c725340a3a2878d11717631c45c81dc721 --- hal/audio_hw.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/hal/audio_hw.c b/hal/audio_hw.c index 05803530..8603dc73 100644 --- a/hal/audio_hw.c +++ b/hal/audio_hw.c @@ -9589,11 +9589,10 @@ static int check_a2dp_restore_l(struct audio_device *adev, struct stream_out *ou pthread_mutex_unlock(&out->compr_mute_lock); } } else { - // mute compress stream if suspended - pthread_mutex_lock(&out->compr_mute_lock); - if ((out->flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) && - (!out->a2dp_compress_mute)) { - if (!out->standby) { + if (out->flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) { + // mute compress stream if suspended + pthread_mutex_lock(&out->compr_mute_lock); + if (!out->a2dp_compress_mute && !out->standby) { ALOGD("%s: selecting speaker and muting stream", __func__); devices = out->devices; out->devices = AUDIO_DEVICE_OUT_SPEAKER; @@ -9610,8 +9609,12 @@ static int check_a2dp_restore_l(struct audio_device *adev, struct stream_out *ou out->volume_l = left_p; out->volume_r = right_p; } + pthread_mutex_unlock(&out->compr_mute_lock); + } else { + // tear down a2dp path for non offloaded streams + if (audio_extn_a2dp_source_is_suspended()) + out_standby_l(&out->stream.common); } - pthread_mutex_unlock(&out->compr_mute_lock); } ALOGV("%s: exit", __func__); return 0;