hal: Fix VoIP Mute failure in SIP call during Voice call HOLD

- Unable to apply the mute in MT SIP call during Voice call
  in CALL_HOLD.
- Mute is only applied if the voice call state is INACTIVE.
  Thus when SIP call is made during Voice call in CALL_HOLD,
  the mute is not being reflected.
- Fix this issue by checking voice stream type to allow
  the mute to be applied.

Change-Id: I3af5225edd8e9a4123867b647de9405d5c4b9efc
CRs-Fixed: 642893
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index c0d47d9..1fb6fda 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -1977,7 +1977,7 @@
      * Instead of writing zeroes here, we could trust the hardware
      * to always provide zeroes when muted.
      */
-    if (ret == 0 && voice_get_mic_mute(adev) && !voice_is_in_call(adev))
+    if (ret == 0 && voice_get_mic_mute(adev) && !voice_is_in_call_rec_stream(in))
         memset(buffer, 0, bytes);
 
 exit:
diff --git a/hal/voice.c b/hal/voice.c
index 82813f6..4417ece 100644
--- a/hal/voice.c
+++ b/hal/voice.c
@@ -189,6 +189,19 @@
     return in_call;
 }
 
+bool voice_is_in_call_rec_stream(struct stream_in *in)
+{
+    bool in_call_rec = false;
+    int ret = 0;
+
+    ret = voice_extn_is_in_call_rec_stream(in, &in_call_rec);
+    if (ret == -ENOSYS) {
+        in_call_rec = false;
+    }
+
+    return in_call_rec;
+}
+
 uint32_t voice_get_active_session_id(struct audio_device *adev)
 {
     int ret = 0;
diff --git a/hal/voice.h b/hal/voice.h
index d160569..0098f94 100644
--- a/hal/voice.h
+++ b/hal/voice.h
@@ -77,6 +77,7 @@
                           struct str_parms *reply);
 void voice_init(struct audio_device *adev);
 bool voice_is_in_call(struct audio_device *adev);
+bool voice_is_in_call_rec_stream(struct stream_in *in);
 int voice_set_mic_mute(struct audio_device *dev, bool state);
 bool voice_get_mic_mute(struct audio_device *dev);
 int voice_set_volume(struct audio_device *adev, float volume);
diff --git a/hal/voice_extn/voice_extn.c b/hal/voice_extn/voice_extn.c
index f6083f3..58a1f8b 100644
--- a/hal/voice_extn/voice_extn.c
+++ b/hal/voice_extn/voice_extn.c
@@ -356,6 +356,19 @@
     return 0;
 }
 
+int voice_extn_is_in_call_rec_stream(struct stream_in *in, bool *in_call_rec)
+{
+    *in_call_rec = false;
+
+    if(in->source == AUDIO_SOURCE_VOICE_DOWNLINK ||
+       in->source == AUDIO_SOURCE_VOICE_UPLINK ||
+       in->source == AUDIO_SOURCE_VOICE_CALL) {
+       *in_call_rec = true;
+    }
+
+    return 0;
+}
+
 void voice_extn_init(struct audio_device *adev)
 {
     adev->voice.session[VOICE_SESS_IDX].vsid =  VOICE_VSID;
diff --git a/hal/voice_extn/voice_extn.h b/hal/voice_extn/voice_extn.h
index f7d20e4..4a9c610 100644
--- a/hal/voice_extn/voice_extn.h
+++ b/hal/voice_extn/voice_extn.h
@@ -33,6 +33,7 @@
                                struct str_parms *query,
                                struct str_parms *reply);
 int voice_extn_is_in_call(struct audio_device *adev, bool *in_call);
+int voice_extn_is_in_call_rec_stream(struct stream_in *in, bool *in_call_rec);
 int voice_extn_get_active_session_id(struct audio_device *adev,
                                      uint32_t *session_id);
 void voice_extn_in_get_parameters(struct stream_in *in,
@@ -80,6 +81,11 @@
     return -ENOSYS;
 }
 
+static int voice_extn_is_in_call_rec_stream(struct stream_in *in, bool *in_call_rec)
+{
+    return -ENOSYS;
+}
+
 static int voice_extn_get_active_session_id(struct audio_device *adev,
                                             uint32_t *session_id)
 {