hal: stop voice call when mode is set to AUDIO_MODE_NORMAL
Do not wait for a routing command after mode is set to NORMAL to
disconnect voice calls.
Start voice call use case only when mode is set to IN_CALL.
Bug: 17687327
Change-Id: Ida33fd6b215fcc70c0afe510b8f0a0d90496385e
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index c14078e..3c82a85 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -598,7 +598,9 @@
* and enable both RX and TX devices though one of them is same as current
* device.
*/
- if (usecase->type == VOICE_CALL) {
+ if ((usecase->type == VOICE_CALL) &&
+ (usecase->in_snd_device != SND_DEVICE_NONE) &&
+ (usecase->out_snd_device != SND_DEVICE_NONE)) {
status = platform_switch_voice_call_device_pre(adev->platform);
}
@@ -617,10 +619,13 @@
* New device information should be sent to modem before enabling
* the devices to reduce in-call device switch time.
*/
- if (usecase->type == VOICE_CALL)
+ if ((usecase->type == VOICE_CALL) &&
+ (usecase->in_snd_device != SND_DEVICE_NONE) &&
+ (usecase->out_snd_device != SND_DEVICE_NONE)) {
status = platform_switch_voice_call_enable_device_config(adev->platform,
out_snd_device,
in_snd_device);
+ }
/* Enable new sound devices */
if (out_snd_device != SND_DEVICE_NONE) {
@@ -1327,13 +1332,6 @@
* Because select_devices() must be called to switch back the music
* playback to headset.
*/
- if (((adev->mode == AUDIO_MODE_NORMAL) || (adev->mode == AUDIO_MODE_IN_COMMUNICATION)) &&
- voice_is_in_call(adev) &&
- output_drives_call(adev, out)) {
- ret = voice_stop_call(adev);
- adev->current_call_output = NULL;
- }
-
if (val != 0) {
out->devices = val;
@@ -1343,7 +1341,8 @@
if ((adev->mode == AUDIO_MODE_IN_CALL) &&
output_drives_call(adev, out)) {
- if (adev->current_call_output != out) {
+ if (adev->current_call_output != NULL &&
+ adev->current_call_output != out) {
voice_stop_call(adev);
}
if (!voice_is_in_call(adev)) {
@@ -2287,6 +2286,11 @@
if (adev->mode != mode) {
ALOGD("%s: mode %d\n", __func__, mode);
adev->mode = mode;
+ if ((mode == AUDIO_MODE_NORMAL || mode == AUDIO_MODE_IN_COMMUNICATION) &&
+ voice_is_in_call(adev)) {
+ voice_stop_call(adev);
+ adev->current_call_output = NULL;
+ }
}
pthread_mutex_unlock(&adev->lock);
diff --git a/hal/voice_extn/voice_extn.c b/hal/voice_extn/voice_extn.c
index 8822bbd..89b659c 100644
--- a/hal/voice_extn/voice_extn.c
+++ b/hal/voice_extn/voice_extn.c
@@ -295,7 +295,8 @@
* occured, otherwise voice calls will be started unintendedly on
* speaker.
*/
- if (is_call_active || adev->voice.in_call) {
+ if (is_call_active ||
+ (adev->voice.in_call && adev->mode == AUDIO_MODE_IN_CALL)) {
/* Device routing is not triggered for voice calls on the subsequent
* subs, Hence update the call states if voice call is already
* active on other sub.