audio: hal: fix click "resume call" two times will cause no sound in HFP call.
If click "resume call" many times when making hfp call, telecom will send
REQUEST_UNHOLD and call start_hfp in audio hal many times, then pcm_open
failed, and no sound will be heard when we make hfp call again. So return 0
at the beginning of start_hfp if hfp is already active.
Bug: 33226115
Bug: 33459120
Change-Id: I517918ef55fce96cf3761e04db89ed634250165f
diff --git a/hal/audio_extn/hfp.c b/hal/audio_extn/hfp.c
index 07d5469..07a9711 100644
--- a/hal/audio_extn/hfp.c
+++ b/hal/audio_extn/hfp.c
@@ -28,6 +28,7 @@
#include <stdlib.h>
#include <cutils/str_parms.h>
#include "audio_extn/tfa_98xx.h"
+#include "audio_extn.h"
#define AUDIO_PARAMETER_HFP_ENABLE "hfp_enable"
#define AUDIO_PARAMETER_HFP_SET_SAMPLING_RATE "hfp_set_sampling_rate"
@@ -247,6 +248,11 @@
int32_t pcm_dev_rx_id, pcm_dev_tx_id, pcm_dev_asm_rx_id, pcm_dev_asm_tx_id;
ALOGD("%s: enter", __func__);
+
+ if (adev->enable_hfp == true) {
+ ALOGD("%s: HFP is already active!\n", __func__);
+ return 0;
+ }
adev->enable_hfp = true;
platform_set_mic_mute(adev->platform, false);