hal: re-route VOIP TX path for enabling correct VOIP EC port
If VOIP TX path is enabled before RX path when connecting
headset or other device, it will enable echo-reference-voip
with default port, because out device hasn't been enabled
and won't be corrected.
Re-route VOIP TX path for enabling echo-reference-voip
with correct port
Change-Id: Iad1270a98f9b16a60f2a79f3be3651e11c48fa79
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 3d98f06..5be3f4a 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2020, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2021, The Linux Foundation. All rights reserved.
* Not a Contribution.
*
* Copyright (C) 2013 The Android Open Source Project
@@ -2983,6 +2983,30 @@
}
enable_audio_route(adev, usecase);
+ if (uc_id == USECASE_AUDIO_PLAYBACK_VOIP) {
+ struct stream_in *voip_in = get_voice_communication_input(adev);
+ struct audio_usecase *voip_in_usecase = NULL;
+ voip_in_usecase = get_usecase_from_list(adev, USECASE_AUDIO_RECORD_VOIP);
+ if (voip_in != NULL &&
+ voip_in_usecase != NULL &&
+ !(out_snd_device == AUDIO_DEVICE_OUT_SPEAKER ||
+ out_snd_device == AUDIO_DEVICE_OUT_SPEAKER_SAFE) &&
+ (voip_in_usecase->in_snd_device ==
+ platform_get_input_snd_device(adev->platform, voip_in,
+ &usecase->stream.out->device_list,usecase->type))) {
+ /*
+ * if VOIP TX is enabled before VOIP RX, needs to re-route the TX path
+ * for enabling echo-reference-voip with correct port
+ */
+ ALOGD("%s: VOIP TX is enabled before VOIP RX,needs to re-route the TX path",__func__);
+ disable_audio_route(adev, voip_in_usecase);
+ disable_snd_device(adev, voip_in_usecase->in_snd_device);
+ enable_snd_device(adev, voip_in_usecase->in_snd_device);
+ enable_audio_route(adev, voip_in_usecase);
+ }
+ }
+
+
audio_extn_qdsp_set_device(usecase);
/* If input stream is already running then effect needs to be