Merge "hal: add input source check to open compress voip input"
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 1b008db..1a7b83e 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -1889,6 +1889,18 @@
/* no audio source uses val == 0 */
if ((in->source != val) && (val != 0)) {
in->source = val;
+ 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) &&
+ (popcount(in->channel_mask) == 1)) {
+ ret = voice_extn_compress_voip_open_input_stream(in);
+ if (ret != 0) {
+ ALOGE("%s: Compress voip input cannot be opened, error:%d",
+ __func__, ret);
+ goto done;
+ }
+ }
}
}
@@ -1903,6 +1915,7 @@
}
}
+done:
pthread_mutex_unlock(&adev->lock);
pthread_mutex_unlock(&in->lock);
@@ -2502,16 +2515,7 @@
in->config.rate = config->sample_rate;
in->format = config->format;
- if ((in->dev->mode == AUDIO_MODE_IN_COMMUNICATION) &&
- (voice_extn_compress_voip_is_config_supported(config))) {
- ret = voice_extn_compress_voip_open_input_stream(in);
- if (ret != 0)
- {
- ALOGE("%s: Compress voip input cannot be opened, error:%d",
- __func__, ret);
- goto err_open;
- }
- } else if (channel_count == 6) {
+ if (channel_count == 6) {
if(audio_extn_ssr_get_enabled()) {
if(audio_extn_ssr_init(adev, in)) {
ALOGE("%s: audio_extn_ssr_init failed", __func__);
@@ -2523,7 +2527,8 @@
goto err_open;
}
} else if (audio_extn_compr_cap_enabled() &&
- audio_extn_compr_cap_format_supported(config->format)) {
+ audio_extn_compr_cap_format_supported(config->format) &&
+ (in->dev->mode != AUDIO_MODE_IN_COMMUNICATION)) {
audio_extn_compr_cap_init(adev, in);
} else {
in->config.channels = channel_count;