Merge "hal: fix no audio in qchat call with speaker as default device"

This commit is contained in:
Linux Build Service Account 2014-01-13 23:12:16 -08:00 committed by Gerrit - the friendly Code Review server
commit c53f56484b
3 changed files with 24 additions and 5 deletions

View File

@ -424,6 +424,7 @@ void voice_init(struct audio_device *adev)
adev->voice.tty_mode = TTY_MODE_OFF;
adev->voice.volume = 1.0f;
adev->voice.mic_mute = false;
adev->voice.voice_device_set = false;
for (i = 0; i < MAX_VOICE_SESSIONS; i++) {
adev->voice.session[i].pcm_rx = NULL;
adev->voice.session[i].pcm_tx = NULL;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, The Linux Foundation. All rights reserved.
* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
* Not a contribution.
*
* Copyright (C) 2013 The Android Open Source Project
@ -60,6 +60,7 @@ struct voice {
int tty_mode;
bool mic_mute;
float volume;
bool voice_device_set;
};
enum {

View File

@ -143,6 +143,7 @@ static int update_calls(struct audio_device *adev)
struct voice_session *session = NULL;
int fd = 0;
int ret = 0;
bool is_in_call = false;
ALOGD("%s: enter:", __func__);
@ -202,6 +203,10 @@ static int update_calls(struct audio_device *adev)
ALOGE("%s: voice_end_call() failed for usecase: %d\n",
__func__, usecase_id);
} else {
voice_extn_is_in_call(adev, &is_in_call);
if (!is_in_call) {
adev->voice.voice_device_set = false;
}
session->state.current = session->state.new;
}
break;
@ -274,6 +279,7 @@ static int update_call_states(struct audio_device *adev,
struct voice_session *session = NULL;
int i = 0;
bool is_in_call;
int no_of_calls_active = 0;
for (i = 0; i < MAX_VOICE_SESSIONS; i++) {
if (vsid == adev->voice.session[i].vsid) {
@ -282,17 +288,27 @@ static int update_call_states(struct audio_device *adev,
}
}
for (i = 0; i < MAX_VOICE_SESSIONS; i++) {
if (CALL_INACTIVE != adev->voice.session[i].state.current)
no_of_calls_active++;
}
/* When there is only one call active, wait for audio policy manager to set
* the mode to AUDIO_MODE_NORMAL and trigger routing to end the last call.
*/
if (no_of_calls_active == 1 && call_state == CALL_INACTIVE)
return 0;
if (session) {
session->state.new = call_state;
voice_extn_is_in_call(adev, &is_in_call);
ALOGD("%s is_in_call:%d mode:%d\n", __func__, is_in_call, adev->mode);
ALOGD("%s is_in_call:%d voice_device_set:%d, mode:%d\n",
__func__, is_in_call, adev->voice.voice_device_set, adev->mode);
/* Dont start voice call before device routing for voice usescases has
* occured, otherwise voice calls will be started unintendedly on
* speaker.
*/
if (is_in_call ||
(adev->mode == AUDIO_MODE_IN_CALL &&
adev->primary_output->devices != AUDIO_DEVICE_OUT_SPEAKER)) {
if (is_in_call || adev->voice.voice_device_set) {
/* 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.
@ -377,6 +393,7 @@ int voice_extn_start_call(struct audio_device *adev)
* udpated.
*/
ALOGV("%s: enter:", __func__);
adev->voice.voice_device_set = true;
return update_calls(adev);
}