From 5c39821723bed0985be73b947d0b5b049e243832 Mon Sep 17 00:00:00 2001 From: Vidyakumar Athota Date: Tue, 31 Mar 2015 21:53:21 -0700 Subject: [PATCH] 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 --- hal/audio_hw.c | 15 +++++++++++---- hal/voice_extn/compress_voip.c | 5 ++++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/hal/audio_hw.c b/hal/audio_hw.c index 33e48c9c..56797703 100644 --- a/hal/audio_hw.c +++ b/hal/audio_hw.c @@ -3364,7 +3364,7 @@ static int adev_open_input_stream(struct audio_hw_device *dev, 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; @@ -3384,8 +3384,8 @@ static int adev_open_input_stream(struct audio_hw_device *dev, } ALOGD("%s: enter: sample_rate(%d) channel_mask(%#x) devices(%#x)\ - stream_handle(%p) io_handle(%d)",__func__, config->sample_rate, config->channel_mask, - devices, &in->stream, handle); + 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); @@ -3406,7 +3406,7 @@ static int adev_open_input_stream(struct audio_hw_device *dev, 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; @@ -3472,6 +3472,13 @@ static int adev_open_input_stream(struct audio_hw_device *dev, channel_count, is_low_latency); 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); + } } /* This stream could be for sound trigger lab, diff --git a/hal/voice_extn/compress_voip.c b/hal/voice_extn/compress_voip.c index e8ba1f94..14af6fc7 100644 --- a/hal/voice_extn/compress_voip.c +++ b/hal/voice_extn/compress_voip.c @@ -697,6 +697,10 @@ int voice_extn_compress_voip_open_input_stream(struct stream_in *in) voip_data.sample_rate = in->config.rate; } + ret = voip_set_mode(in->dev, in->format); + if (ret < 0) + goto done; + in->usecase = USECASE_COMPRESS_VOIP_CALL; if (in->config.rate == 16000) in->config = pcm_config_voip_wb; @@ -704,7 +708,6 @@ int voice_extn_compress_voip_open_input_stream(struct stream_in *in) in->config = pcm_config_voip_nb; voip_data.in_stream_count++; - ret = voip_set_mode(in->dev, in->format); done: ALOGV("%s: exit, ret=%d", __func__, ret);