diff --git a/hal/audio_hw.c b/hal/audio_hw.c index c4ad4c93..58fcea47 100644 --- a/hal/audio_hw.c +++ b/hal/audio_hw.c @@ -1786,13 +1786,16 @@ static int out_set_parameters(struct audio_stream *stream, const char *kvpairs) if (!out->standby) select_devices(adev, out->usecase); - if ((adev->mode == AUDIO_MODE_IN_CALL) && - output_drives_call(adev, out)) { - adev->current_call_output = out; - if (!voice_is_in_call(adev)) - ret = voice_start_call(adev); - else + if (output_drives_call(adev, out)) { + if(!voice_is_in_call(adev)) { + if (adev->mode == AUDIO_MODE_IN_CALL) { + adev->current_call_output = out; + ret = voice_start_call(adev); + } + } else { + adev->current_call_output = out; voice_update_devices_for_all_voice_usecases(adev); + } } } diff --git a/hal/msm8916/platform.c b/hal/msm8916/platform.c index 2bca793d..f0288600 100644 --- a/hal/msm8916/platform.c +++ b/hal/msm8916/platform.c @@ -1067,7 +1067,7 @@ int platform_switch_voice_call_device_pre(void *platform) int ret = 0; if (my_data->csd != NULL && - my_data->adev->mode == AUDIO_MODE_IN_CALL) { + voice_is_in_call(my_data->adev)) { /* This must be called before disabling mixer controls on APQ side */ ret = my_data->csd->disable_device(); if (ret < 0) { @@ -1338,8 +1338,7 @@ snd_device_t platform_get_output_snd_device(void *platform, audio_devices_t devi goto exit; } - if ((mode == AUDIO_MODE_IN_CALL) || - voice_extn_compress_voip_is_active(adev)) { + if (voice_is_in_call(adev) || voice_extn_compress_voip_is_active(adev)) { if (devices & AUDIO_DEVICE_OUT_WIRED_HEADPHONE || devices & AUDIO_DEVICE_OUT_WIRED_HEADSET) { if ((adev->voice.tty_mode != TTY_MODE_OFF) && @@ -1452,7 +1451,7 @@ snd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_d ALOGV("%s: enter: out_device(%#x) in_device(%#x)", __func__, out_device, in_device); - if ((out_device != AUDIO_DEVICE_NONE) && ((mode == AUDIO_MODE_IN_CALL) || + if ((out_device != AUDIO_DEVICE_NONE) && (voice_is_in_call(adev) || voice_extn_compress_voip_is_active(adev) || audio_extn_hfp_is_active(adev))) { if ((adev->voice.tty_mode != TTY_MODE_OFF) && !voice_extn_compress_voip_is_active(adev)) { diff --git a/hal/msm8960/platform.c b/hal/msm8960/platform.c index e2c30f4b..9b70e291 100644 --- a/hal/msm8960/platform.c +++ b/hal/msm8960/platform.c @@ -493,7 +493,8 @@ int platform_switch_voice_call_device_pre(void *platform) struct platform_data *my_data = (struct platform_data *)platform; int ret = 0; - if (my_data->csd_client != NULL) { + if (my_data->csd_client != NULL && + voice_is_in_call(my_data->adev)) { /* This must be called before disabling the mixer controls on APQ side */ if (my_data->csd_disable_device == NULL) { ALOGE("%s: dlsym error for csd_disable_device", __func__); @@ -644,7 +645,7 @@ snd_device_t platform_get_output_snd_device(void *platform, audio_devices_t devi goto exit; } - if (mode == AUDIO_MODE_IN_CALL) { + if (voice_is_in_call(adev)) { if (devices & AUDIO_DEVICE_OUT_WIRED_HEADPHONE || devices & AUDIO_DEVICE_OUT_WIRED_HEADSET) { if (adev->voice.tty_mode == TTY_MODE_FULL) @@ -736,11 +737,7 @@ snd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_d ALOGV("%s: enter: out_device(%#x) in_device(%#x)", __func__, out_device, in_device); - if (mode == AUDIO_MODE_IN_CALL) { - if (out_device == AUDIO_DEVICE_NONE) { - ALOGE("%s: No output device set for voice call", __func__); - goto exit; - } + if ((out_device != AUDIO_DEVICE_NONE) && voice_is_in_call(adev)) { if (adev->voice.tty_mode != TTY_MODE_OFF) { if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE || out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET) { diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c index dd4bc68d..a46e414b 100644 --- a/hal/msm8974/platform.c +++ b/hal/msm8974/platform.c @@ -1310,7 +1310,7 @@ int platform_switch_voice_call_device_pre(void *platform) int ret = 0; if (my_data->csd != NULL && - my_data->adev->mode == AUDIO_MODE_IN_CALL) { + voice_is_in_call(my_data->adev)) { /* This must be called before disabling mixer controls on APQ side */ ret = my_data->csd->disable_device(); if (ret < 0) { @@ -1618,7 +1618,7 @@ snd_device_t platform_get_output_snd_device(void *platform, audio_devices_t devi goto exit; } - if ((mode == AUDIO_MODE_IN_CALL) || + if (voice_is_in_call(adev) || voice_extn_compress_voip_is_active(adev)) { if (devices & AUDIO_DEVICE_OUT_WIRED_HEADPHONE || devices & AUDIO_DEVICE_OUT_WIRED_HEADSET) { @@ -1738,7 +1738,7 @@ snd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_d ALOGV("%s: enter: out_device(%#x) in_device(%#x)", __func__, out_device, in_device); if (my_data->external_mic) { - if (((out_device != AUDIO_DEVICE_NONE) && (mode == AUDIO_MODE_IN_CALL)) || + if ((out_device != AUDIO_DEVICE_NONE && voice_is_in_call(adev)) || voice_extn_compress_voip_is_active(adev) || audio_extn_hfp_is_active(adev)) { if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE || out_device & AUDIO_DEVICE_OUT_EARPIECE || @@ -1753,7 +1753,7 @@ snd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_d if (snd_device != AUDIO_DEVICE_NONE) goto exit; - if ((out_device != AUDIO_DEVICE_NONE) && ((mode == AUDIO_MODE_IN_CALL) || + if ((out_device != AUDIO_DEVICE_NONE) && ((voice_is_in_call(adev)) || voice_extn_compress_voip_is_active(adev) || audio_extn_hfp_is_active(adev))) { if ((adev->voice.tty_mode != TTY_MODE_OFF) && !voice_extn_compress_voip_is_active(adev)) { diff --git a/hal/voice.c b/hal/voice.c index c4fa1631..53e30337 100644 --- a/hal/voice.c +++ b/hal/voice.c @@ -373,11 +373,11 @@ int voice_start_call(struct audio_device *adev) { int ret = 0; + adev->voice.in_call = true; ret = voice_extn_start_call(adev); if (ret == -ENOSYS) { ret = voice_start_usecase(adev, USECASE_VOICE_CALL); } - adev->voice.in_call = true; return ret; }