Fix the double PCM open during HFP call
If the second call is receving during a HFP call, audio path may change
to deep-buffer for ringtone playback intermediately and then come
back to HFP. So in this case, just keep the previsous opened PCM instead
of re-opening the PCM.
Bug: 66324788
Change-Id: I37666dac2602dc6d9d57a7fedc5a33f04890c1b5
(cherry picked from commit 74ab78e8356119b01f5d23d82221d8e2d5c9b3ac)
diff --git a/hal/audio_extn/hfp.c b/hal/audio_extn/hfp.c
index 07a9711..ad1530a 100644
--- a/hal/audio_extn/hfp.c
+++ b/hal/audio_extn/hfp.c
@@ -438,10 +438,17 @@
ret = str_parms_get_str(parms, AUDIO_PARAMETER_HFP_ENABLE, value,
sizeof(value));
if (ret >= 0) {
- if (!strncmp(value,"true",sizeof(value)))
- ret = start_hfp(adev,parms);
- else
- stop_hfp(adev);
+ if (!strncmp(value,"true",sizeof(value))) {
+ if (!hfpmod.is_hfp_running)
+ start_hfp(adev,parms);
+ else
+ ALOGW("%s: HFP is already active.", __func__);
+ } else {
+ if (hfpmod.is_hfp_running)
+ stop_hfp(adev);
+ else
+ ALOGW("%s: ignore STOP, HFC not active", __func__);
+ }
}
memset(value, 0, sizeof(value));
ret = str_parms_get_str(parms,AUDIO_PARAMETER_HFP_SET_SAMPLING_RATE, value,