hal: fix voip device selection is not proper after voice call stop
In voip+voice concurrency case, when voip resume after voice call stop,
voip device still uses voice devices. This is due to in_call flag isn't
reset even if voice usecase doesn't exist.
Fix it by adding function to check voice usecase existence and get
correct device for non-voice usecases.
Change-Id: I39ba1092a0ab19c686baa1b80bb9913f64849590
diff --git a/hal/msm8916/platform.c b/hal/msm8916/platform.c
index fb44369..7bc508d 100644
--- a/hal/msm8916/platform.c
+++ b/hal/msm8916/platform.c
@@ -4112,7 +4112,7 @@
* enforced audible (e.g. Camera shutter sound).
*/
if ((mode == AUDIO_MODE_IN_CALL) ||
- voice_is_in_call(adev) ||
+ voice_check_voicecall_usecases_active(adev) ||
voice_extn_compress_voip_is_active(adev))
is_active_voice_call = true;
@@ -4195,7 +4195,7 @@
}
if ((mode == AUDIO_MODE_IN_CALL) ||
- voice_is_in_call(adev) ||
+ voice_check_voicecall_usecases_active(adev) ||
voice_extn_compress_voip_is_active(adev)) {
if (devices & AUDIO_DEVICE_OUT_WIRED_HEADPHONE ||
devices & AUDIO_DEVICE_OUT_WIRED_HEADSET ||
@@ -4571,8 +4571,10 @@
ALOGV("%s: enter: out_device(%#x) in_device(%#x) channel_count (%d) channel_mask (0x%x)",
__func__, out_device, in_device, channel_count, channel_mask);
if (my_data->external_mic) {
- if ((out_device != AUDIO_DEVICE_NONE) && ((mode == AUDIO_MODE_IN_CALL) || voice_is_in_call(adev) ||
- voice_extn_compress_voip_is_active(adev) || audio_extn_hfp_is_active(adev))) {
+ if ((out_device != AUDIO_DEVICE_NONE) && ((mode == AUDIO_MODE_IN_CALL) ||
+ voice_check_voicecall_usecases_active(adev) ||
+ voice_extn_compress_voip_is_active(adev) ||
+ audio_extn_hfp_is_active(adev))) {
if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE ||
out_device & AUDIO_DEVICE_OUT_EARPIECE ||
out_device & AUDIO_DEVICE_OUT_SPEAKER )
@@ -4586,8 +4588,10 @@
if (snd_device != AUDIO_DEVICE_NONE)
goto exit;
- if ((out_device != AUDIO_DEVICE_NONE) && ((mode == AUDIO_MODE_IN_CALL) || voice_is_in_call(adev) ||
- voice_extn_compress_voip_is_active(adev) || audio_extn_hfp_is_active(adev))) {
+ if ((out_device != AUDIO_DEVICE_NONE) && ((mode == AUDIO_MODE_IN_CALL) ||
+ voice_check_voicecall_usecases_active(adev) ||
+ voice_extn_compress_voip_is_active(adev) ||
+ audio_extn_hfp_is_active(adev))) {
if ((adev->voice.tty_mode != TTY_MODE_OFF) &&
!voice_extn_compress_voip_is_active(adev)) {
if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE ||
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index 0931d42..263dc1a 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -4074,7 +4074,7 @@
* enforced audible (e.g. Camera shutter sound).
*/
if ((mode == AUDIO_MODE_IN_CALL) ||
- voice_is_in_call(adev) ||
+ voice_check_voicecall_usecases_active(adev) ||
voice_extn_compress_voip_is_active(adev))
is_active_voice_call = true;
@@ -4159,7 +4159,7 @@
}
if ((mode == AUDIO_MODE_IN_CALL) ||
- voice_is_in_call(adev) ||
+ voice_check_voicecall_usecases_active(adev) ||
voice_extn_compress_voip_is_active(adev)) {
if (devices & AUDIO_DEVICE_OUT_WIRED_HEADPHONE ||
devices & AUDIO_DEVICE_OUT_WIRED_HEADSET ||
@@ -4547,8 +4547,10 @@
ALOGV("%s: enter: out_device(%#x) in_device(%#x) channel_count (%d) channel_mask (0x%x)",
__func__, out_device, in_device, channel_count, channel_mask);
if (my_data->external_mic) {
- if ((out_device != AUDIO_DEVICE_NONE) && ((mode == AUDIO_MODE_IN_CALL) || voice_is_in_call(adev) ||
- voice_extn_compress_voip_is_active(adev) || audio_extn_hfp_is_active(adev))) {
+ if ((out_device != AUDIO_DEVICE_NONE) && ((mode == AUDIO_MODE_IN_CALL) ||
+ voice_check_voicecall_usecases_active(adev) ||
+ voice_extn_compress_voip_is_active(adev) ||
+ audio_extn_hfp_is_active(adev))) {
if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE ||
out_device & AUDIO_DEVICE_OUT_EARPIECE ||
out_device & AUDIO_DEVICE_OUT_SPEAKER )
@@ -4562,8 +4564,10 @@
if (snd_device != AUDIO_DEVICE_NONE)
goto exit;
- if ((out_device != AUDIO_DEVICE_NONE) && ((mode == AUDIO_MODE_IN_CALL) || voice_is_in_call(adev) ||
- voice_extn_compress_voip_is_active(adev) || audio_extn_hfp_is_active(adev))) {
+ if ((out_device != AUDIO_DEVICE_NONE) && ((mode == AUDIO_MODE_IN_CALL) ||
+ voice_check_voicecall_usecases_active(adev) ||
+ voice_extn_compress_voip_is_active(adev) ||
+ audio_extn_hfp_is_active(adev))) {
if ((adev->voice.tty_mode != TTY_MODE_OFF) &&
!voice_extn_compress_voip_is_active(adev)) {
if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE ||
diff --git a/hal/voice.c b/hal/voice.c
index ff6da5a..91eb3ff 100644
--- a/hal/voice.c
+++ b/hal/voice.c
@@ -363,6 +363,22 @@
return session_id;
}
+bool voice_check_voicecall_usecases_active(struct audio_device *adev)
+{
+ struct listnode *node;
+ struct audio_usecase *usecase = NULL;
+
+ list_for_each(node, &adev->usecase_list) {
+ usecase = node_to_item(node, struct audio_usecase, list);
+ if (usecase->type == VOICE_CALL) {
+ ALOGV("%s: voice usecase:%s is active", __func__,
+ use_case_table[usecase->id]);
+ return true;
+ }
+ }
+ return false;
+}
+
int voice_check_and_set_incall_rec_usecase(struct audio_device *adev,
struct stream_in *in)
{
diff --git a/hal/voice.h b/hal/voice.h
index bc9aa21..38d5721 100644
--- a/hal/voice.h
+++ b/hal/voice.h
@@ -104,4 +104,5 @@
bool voice_is_call_state_active(struct audio_device *adev);
void voice_set_device_mute_flag (struct audio_device *adev, bool state);
snd_device_t voice_get_incall_rec_backend_device(struct stream_in *in);
+bool voice_check_voicecall_usecases_active(struct audio_device *adev);
#endif //VOICE_H