Audio: update stream volume if device route successful.
Volume unmutes even if Bt-A2dp is not ready and routing
fails.
Unmute the volume only if routing to Bt-A2dp is success.
If unsuccessful unmute the stream on A2dp device disconnect.
CRs-Fixed: 2453246
Change-Id: Ic4c967da3360918db0b2ead80429ae33c6b826cc
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 434ece8..bfaac46 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -8145,6 +8145,21 @@
adev->allow_afe_proxy_usage = true;
}
}
+ if (audio_is_a2dp_out_device(device)) {
+ struct audio_usecase *usecase;
+ struct listnode *node;
+ list_for_each(node, &adev->usecase_list) {
+ usecase = node_to_item(node, struct audio_usecase, list);
+ if (PCM_PLAYBACK == usecase->type && usecase->stream.out &&
+ (usecase->stream.out->flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) &&
+ usecase->stream.out->a2dp_compress_mute) {
+ struct stream_out *out = usecase->stream.out;
+ ALOGD("Unmuting the stream when Bt-A2dp disconnected and stream is mute");
+ out->a2dp_compress_mute = false;
+ out_set_compr_volume(&out->stream, out->volume_l, out->volume_r);
+ }
+ }
+ }
}
audio_extn_hfp_set_parameters(adev, parms);
@@ -9307,7 +9322,7 @@
select_devices(adev, uc_info->id);
pthread_mutex_lock(&out->compr_mute_lock);
if ((out->flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) &&
- (out->a2dp_compress_mute)) {
+ (out->a2dp_compress_mute) && (uc_info->out_snd_device == SND_DEVICE_OUT_BT_A2DP)) {
out->a2dp_compress_mute = false;
out_set_compr_volume(&out->stream, out->volume_l, out->volume_r);
}