hal: fix music playback mute issues for a2dp suspended scenarios
Music may not be resumed after A2DP resumed due to improper mute
applied and not restored.
CRs-Fixed: 2088539
Change-Id: I3a222f128659de603504f6bed4d4e3cdcc7a125b
diff --git a/hal/audio_extn/a2dp.c b/hal/audio_extn/a2dp.c
index b96a147..548bb7c 100644
--- a/hal/audio_extn/a2dp.c
+++ b/hal/audio_extn/a2dp.c
@@ -805,7 +805,8 @@
a2dp.a2dp_suspended = true;
list_for_each(node, &a2dp.adev->usecase_list) {
uc_info = node_to_item(node, struct audio_usecase, list);
- if (uc_info->type == PCM_PLAYBACK) {
+ if (uc_info->type == PCM_PLAYBACK &&
+ (uc_info->stream.out->devices & AUDIO_DEVICE_OUT_ALL_A2DP)) {
pthread_mutex_unlock(&a2dp.adev->lock);
check_a2dp_restore(a2dp.adev, uc_info->stream.out, false);
pthread_mutex_lock(&a2dp.adev->lock);
@@ -844,7 +845,8 @@
}
list_for_each(node, &a2dp.adev->usecase_list) {
uc_info = node_to_item(node, struct audio_usecase, list);
- if (uc_info->type == PCM_PLAYBACK) {
+ if (uc_info->type == PCM_PLAYBACK &&
+ (uc_info->stream.out->devices & AUDIO_DEVICE_OUT_ALL_A2DP)) {
pthread_mutex_unlock(&a2dp.adev->lock);
check_a2dp_restore(a2dp.adev, uc_info->stream.out, true);
pthread_mutex_lock(&a2dp.adev->lock);
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 996a9a1..6d6adaa 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -1731,10 +1731,10 @@
voice_check_and_update_aanc_path(adev, usecase->out_snd_device, false);
}
- if ((usecase->out_snd_device == SND_DEVICE_OUT_SPEAKER_AND_BT_A2DP) &&
+ if ((out_snd_device == SND_DEVICE_OUT_SPEAKER_AND_BT_A2DP) &&
(!audio_extn_a2dp_is_ready())) {
ALOGW("%s: A2DP profile is not ready, routing to speaker only", __func__);
- usecase->out_snd_device = SND_DEVICE_OUT_SPEAKER;
+ out_snd_device = SND_DEVICE_OUT_SPEAKER;
}
/* Disable current sound devices */
@@ -3113,7 +3113,7 @@
audio_extn_perf_lock_release(&adev->perf_lock_handle);
if ((out->flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) &&
out->a2dp_compress_mute &&
- (!(out->devices & AUDIO_DEVICE_OUT_ALL_A2DP))) {
+ (!(out->devices & AUDIO_DEVICE_OUT_ALL_A2DP) || audio_extn_a2dp_is_ready())) {
pthread_mutex_lock(&out->compr_mute_lock);
out->a2dp_compress_mute = false;
out_set_compr_volume(&out->stream, out->volume_l, out->volume_r);