hal: update input source type during open input stream

Currently input stream source type is updated in in_set_parameters().
Some of the effects like AEC are applied based on input source type.
If effects API is called before in_set_parameters() then that effect
does not apply. Fix this issue by updating the source type in
adev_open_input_stream() instead of in_set_parameters().

Change-Id: Iff0670264e156840c40f1f15cfc93fd5b2506e0d
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 528cbb9..1ef002b 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -2826,7 +2826,7 @@
                                   struct audio_stream_in **stream_in,
                                   audio_input_flags_t flags __unused,
                                   const char *address __unused,
-                                  audio_source_t source __unused)
+                                  audio_source_t source)
 {
     struct audio_device *adev = (struct audio_device *)dev;
     struct stream_in *in;
@@ -2840,8 +2840,8 @@
 
     in = (struct stream_in *)calloc(1, sizeof(struct stream_in));
     ALOGD("%s: enter: sample_rate(%d) channel_mask(%#x) devices(%#x)\
-        stream_handle(%p)",__func__, config->sample_rate, config->channel_mask,
-        devices, &in->stream);
+        stream_handle(%p) io_handle(%d) source(%d)",__func__, config->sample_rate, config->channel_mask,
+        devices, &in->stream, handle, source);
 
     pthread_mutex_init(&in->lock, (const pthread_mutexattr_t *) NULL);
 
@@ -2862,7 +2862,7 @@
     in->stream.get_input_frames_lost = in_get_input_frames_lost;
 
     in->device = devices;
-    in->source = AUDIO_SOURCE_DEFAULT;
+    in->source = source;
     in->dev = adev;
     in->standby = 1;
     in->channel_mask = config->channel_mask;
@@ -2918,6 +2918,13 @@
                                             config->format,
                                             channel_count);
         in->config.period_size = buffer_size / frame_size;
+        if ((in->source == AUDIO_SOURCE_VOICE_COMMUNICATION) &&
+               (in->dev->mode == AUDIO_MODE_IN_COMMUNICATION) &&
+               (voice_extn_compress_voip_is_format_supported(in->format)) &&
+               (in->config.rate == 8000 || in->config.rate == 16000) &&
+               (audio_channel_count_from_in_mask(in->channel_mask) == 1)) {
+            voice_extn_compress_voip_open_input_stream(in);
+        }
     }
 
     *stream_in = &in->stream;