hal: Handle pcm_start failures for hfp
- If pcm_start fails for any reason, hfp ignores the failure.
- This could lead to issues as the failures are not handled.
- Return appropriate error and break execution when pcm_start fails.
CRs-Fixed: 684608
Change-Id: Iad43b3d3e3e71e7191d41bbea317f2079d57784a
diff --git a/hal/audio_extn/hfp.c b/hal/audio_extn/hfp.c
index 239c975..e572f6a 100644
--- a/hal/audio_extn/hfp.c
+++ b/hal/audio_extn/hfp.c
@@ -200,10 +200,26 @@
ret = -EIO;
goto exit;
}
- pcm_start(hfpmod.hfp_sco_rx);
- pcm_start(hfpmod.hfp_sco_tx);
- pcm_start(hfpmod.hfp_pcm_rx);
- pcm_start(hfpmod.hfp_pcm_tx);
+ if (pcm_start(hfpmod.hfp_sco_rx) < 0) {
+ ALOGE("%s: pcm start for hfp sco rx failed", __func__);
+ ret = -EINVAL;
+ goto exit;
+ }
+ if (pcm_start(hfpmod.hfp_sco_tx) < 0) {
+ ALOGE("%s: pcm start for hfp sco tx failed", __func__);
+ ret = -EINVAL;
+ goto exit;
+ }
+ if (pcm_start(hfpmod.hfp_pcm_rx) < 0) {
+ ALOGE("%s: pcm start for hfp pcm rx failed", __func__);
+ ret = -EINVAL;
+ goto exit;
+ }
+ if (pcm_start(hfpmod.hfp_pcm_tx) < 0) {
+ ALOGE("%s: pcm start for hfp pcm tx failed", __func__);
+ ret = -EINVAL;
+ goto exit;
+ }
hfpmod.is_hfp_running = true;
hfp_set_volume(adev, hfpmod.hfp_volume);