diff options
author | Linux Build Service Account <lnxbuild@localhost> | 2014-08-28 17:04:54 -0700 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2014-08-28 17:04:54 -0700 |
commit | 96d5334f84b5687df131900bf4c78db4288dee1c (patch) | |
tree | ff39252b13ef0e84a620a37049e1b44df54e56fa | |
parent | 7a3faa249b0ee61261763cd4cfca7dea43b6f647 (diff) | |
parent | d30d267836c5101aa7751f2f08cc0cfd7e06e74c (diff) | |
download | android_hardware_qcom_audio-96d5334f84b5687df131900bf4c78db4288dee1c.tar.gz android_hardware_qcom_audio-96d5334f84b5687df131900bf4c78db4288dee1c.tar.bz2 android_hardware_qcom_audio-96d5334f84b5687df131900bf4c78db4288dee1c.zip |
Merge "Merge tag 'AU_LINUX_ANDROID_LNX.LA.3.6.04.04.04.062.189' into HEAD"
-rw-r--r-- | hal/audio_hw.c | 30 | ||||
-rw-r--r-- | hal/voice.c | 21 | ||||
-rw-r--r-- | hal/voice.h | 4 | ||||
-rw-r--r-- | hal/voice_extn/compress_voip.c | 9 | ||||
-rw-r--r-- | hal/voice_extn/voice_extn.c | 31 | ||||
-rw-r--r-- | hal/voice_extn/voice_extn.h | 6 |
6 files changed, 56 insertions, 45 deletions
diff --git a/hal/audio_hw.c b/hal/audio_hw.c index 644cc5ba..090ef2fc 100644 --- a/hal/audio_hw.c +++ b/hal/audio_hw.c @@ -611,23 +611,23 @@ int select_devices(struct audio_device *adev, audio_usecase_t uc_id) * usecase. This is to avoid switching devices for voice call when * check_usecases_codec_backend() is called below. */ - if (voice_is_in_call(adev)) { + if (adev->voice.in_call && adev->mode == AUDIO_MODE_IN_CALL) { vc_usecase = get_usecase_from_list(adev, get_voice_usecase_id_from_list(adev)); - if ((vc_usecase->devices & AUDIO_DEVICE_OUT_ALL_CODEC_BACKEND) || - (usecase->devices == AUDIO_DEVICE_IN_VOICE_CALL)) { + if ((vc_usecase) && ((vc_usecase->devices & AUDIO_DEVICE_OUT_ALL_CODEC_BACKEND) || + (usecase->devices == AUDIO_DEVICE_IN_VOICE_CALL))) { in_snd_device = vc_usecase->in_snd_device; out_snd_device = vc_usecase->out_snd_device; } } else if (voice_extn_compress_voip_is_active(adev)) { voip_usecase = get_usecase_from_list(adev, USECASE_COMPRESS_VOIP_CALL); - if (voip_usecase->devices & AUDIO_DEVICE_OUT_ALL_CODEC_BACKEND) { + if ((voip_usecase) && (voip_usecase->devices & AUDIO_DEVICE_OUT_ALL_CODEC_BACKEND)) { in_snd_device = voip_usecase->in_snd_device; out_snd_device = voip_usecase->out_snd_device; } } else if (audio_extn_hfp_is_active(adev)) { hfp_usecase = get_usecase_from_list(adev, USECASE_AUDIO_HFP_SCO); - if (hfp_usecase->devices & AUDIO_DEVICE_OUT_ALL_CODEC_BACKEND) { + if ((hfp_usecase) && (hfp_usecase->devices & AUDIO_DEVICE_OUT_ALL_CODEC_BACKEND)) { in_snd_device = hfp_usecase->in_snd_device; out_snd_device = hfp_usecase->out_snd_device; } @@ -1531,18 +1531,18 @@ static int out_set_parameters(struct audio_stream *stream, const char *kvpairs) select_devices(adev, out->usecase); if ((adev->mode == AUDIO_MODE_IN_CALL) && - !voice_is_in_call(adev) && + !adev->voice.in_call && (out == adev->primary_output)) { ret = voice_start_call(adev); } else if ((adev->mode == AUDIO_MODE_IN_CALL) && - voice_is_in_call(adev) && + adev->voice.in_call && (out == adev->primary_output)) { voice_update_devices_for_all_voice_usecases(adev); } } if ((adev->mode == AUDIO_MODE_NORMAL) && - voice_is_in_call(adev) && + adev->voice.in_call && (out == adev->primary_output)) { ret = voice_stop_call(adev); } @@ -1577,6 +1577,12 @@ static char* out_get_parameters(const struct audio_stream *stream, const char *k size_t i, j; int ret; bool first = true; + + if (!query || !reply) { + ALOGE("out_get_parameters: failed to allocate mem for query or reply"); + return NULL; + } + ALOGV("%s: enter: keys - %s", __func__, keys); ret = str_parms_get_str(query, AUDIO_PARAMETER_STREAM_SUP_CHANNELS, value, sizeof(value)); if (ret >= 0) { @@ -2066,6 +2072,12 @@ static char* in_get_parameters(const struct audio_stream *stream, char *str; char value[256]; struct str_parms *reply = str_parms_create(); + + if (!query || !reply) { + ALOGE("in_get_parameters: failed to create query or reply"); + return NULL; + } + ALOGV("%s: enter: keys - %s", __func__, keys); voice_extn_in_get_parameters(in, query, reply); @@ -2117,7 +2129,7 @@ static ssize_t in_read(struct audio_stream_in *stream, void *buffer, * Instead of writing zeroes here, we could trust the hardware * to always provide zeroes when muted. */ - if (ret == 0 && voice_get_mic_mute(adev) && !voice_is_in_call(adev)) + if (ret == 0 && voice_get_mic_mute(adev) && !adev->voice.in_call) memset(buffer, 0, bytes); exit: diff --git a/hal/voice.c b/hal/voice.c index 62d01dbe..ac3c125b 100644 --- a/hal/voice.c +++ b/hal/voice.c @@ -175,26 +175,27 @@ int start_call(struct audio_device *adev, audio_usecase_t usecase_id) } session->state.current = CALL_ACTIVE; - return 0; + goto done; error_start_voice: stop_call(adev, usecase_id); +done: ALOGD("%s: exit: status(%d)", __func__, ret); return ret; } -bool voice_is_in_call(struct audio_device *adev) +bool voice_is_call_state_active(struct audio_device *adev) { - bool in_call = false; + bool call_state = false; int ret = 0; - ret = voice_extn_is_in_call(adev, &in_call); + ret = voice_extn_is_call_state_active(adev, &call_state); if (ret == -ENOSYS) { - in_call = (adev->voice.session[VOICE_SESS_IDX].state.current == CALL_ACTIVE) ? true : false; + call_state = (adev->voice.session[VOICE_SESS_IDX].state.current == CALL_ACTIVE) ? true : false; } - return in_call; + return call_state; } uint32_t voice_get_active_session_id(struct audio_device *adev) @@ -217,7 +218,7 @@ int voice_check_and_set_incall_rec_usecase(struct audio_device *adev, int usecase_id; int rec_mode = INCALL_REC_NONE; - if (voice_is_in_call(adev)) { + if (voice_is_call_state_active(adev)) { switch (in->source) { case AUDIO_SOURCE_VOICE_UPLINK: if (audio_extn_compr_cap_enabled() && @@ -343,6 +344,7 @@ int voice_start_call(struct audio_device *adev) if (ret == -ENOSYS) { ret = start_call(adev, USECASE_VOICE_CALL); } + adev->voice.in_call = true; return ret; } @@ -351,6 +353,7 @@ int voice_stop_call(struct audio_device *adev) { int ret = 0; + adev->voice.in_call = false; ret = voice_extn_stop_call(adev); if (ret == -ENOSYS) { ret = stop_call(adev, USECASE_VOICE_CALL); @@ -404,7 +407,7 @@ int voice_set_parameters(struct audio_device *adev, struct str_parms *parms) if (tty_mode != adev->voice.tty_mode) { adev->voice.tty_mode = tty_mode; adev->acdb_settings = (adev->acdb_settings & TTY_MODE_CLEAR) | tty_mode; - if (voice_is_in_call(adev)) + if (voice_is_call_state_active(adev)) voice_update_devices_for_all_voice_usecases(adev); } } @@ -433,7 +436,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; + adev->voice.in_call = false; for (i = 0; i < MAX_VOICE_SESSIONS; i++) { adev->voice.session[i].pcm_rx = NULL; adev->voice.session[i].pcm_tx = NULL; diff --git a/hal/voice.h b/hal/voice.h index 136da512..bae110d1 100644 --- a/hal/voice.h +++ b/hal/voice.h @@ -60,7 +60,7 @@ struct voice { int tty_mode; bool mic_mute; float volume; - bool voice_device_set; + bool in_call; }; enum { @@ -76,7 +76,7 @@ int voice_set_parameters(struct audio_device *adev, struct str_parms *parms); void voice_get_parameters(struct audio_device *adev, struct str_parms *query, struct str_parms *reply); void voice_init(struct audio_device *adev); -bool voice_is_in_call(struct audio_device *adev); +bool voice_is_call_state_active(struct audio_device *adev); int voice_set_mic_mute(struct audio_device *dev, bool state); bool voice_get_mic_mute(struct audio_device *dev); int voice_set_volume(struct audio_device *adev, float volume); diff --git a/hal/voice_extn/compress_voip.c b/hal/voice_extn/compress_voip.c index deb3172c..9937a612 100644 --- a/hal/voice_extn/compress_voip.c +++ b/hal/voice_extn/compress_voip.c @@ -564,8 +564,13 @@ int voice_extn_compress_voip_start_output_stream(struct stream_out *out) ret = voip_start_call(adev, &out->config); out->pcm = voip_data.pcm_rx; uc_info = get_usecase_from_list(adev, USECASE_COMPRESS_VOIP_CALL); - uc_info->stream.out = out; - uc_info->devices = out->devices; + if (uc_info) { + uc_info->stream.out = out; + uc_info->devices = out->devices; + } else { + ret = -EINVAL; + ALOGE("%s: exit(%d): failed to get use case info", __func__, ret); + } ALOGV("%s: exit: status(%d)", __func__, ret); return ret; diff --git a/hal/voice_extn/voice_extn.c b/hal/voice_extn/voice_extn.c index d4fe4215..adfc050c 100644 --- a/hal/voice_extn/voice_extn.c +++ b/hal/voice_extn/voice_extn.c @@ -70,7 +70,7 @@ struct pcm_config pcm_config_incall_music = { extern int start_call(struct audio_device *adev, audio_usecase_t usecase_id); extern int stop_call(struct audio_device *adev, audio_usecase_t usecase_id); -int voice_extn_is_in_call(struct audio_device *adev, bool *in_call); +int voice_extn_is_call_state_active(struct audio_device *adev, bool *is_call_active); static bool is_valid_call_state(int call_state) { @@ -145,7 +145,6 @@ 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__); @@ -205,10 +204,6 @@ 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; @@ -280,8 +275,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; + bool is_call_active; for (i = 0; i < MAX_VOICE_SESSIONS; i++) { if (vsid == adev->voice.session[i].vsid) { @@ -290,21 +284,16 @@ 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++; - } - if (session) { session->state.new = call_state; - voice_extn_is_in_call(adev, &is_in_call); - ALOGD("%s is_in_call:%d voice_device_set:%d, mode:%d\n", - __func__, is_in_call, adev->voice.voice_device_set, adev->mode); + voice_extn_is_call_state_active(adev, &is_call_active); + ALOGD("%s is_call_active:%d in_call:%d, mode:%d\n", + __func__, is_call_active, adev->voice.in_call, 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->voice.voice_device_set) { + if (is_call_active || adev->voice.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. @@ -326,16 +315,16 @@ int voice_extn_get_active_session_id(struct audio_device *adev, return 0; } -int voice_extn_is_in_call(struct audio_device *adev, bool *in_call) +int voice_extn_is_call_state_active(struct audio_device *adev, bool *is_call_active) { struct voice_session *session = NULL; int i = 0; - *in_call = false; + *is_call_active = false; for (i = 0; i < MAX_VOICE_SESSIONS; i++) { session = &adev->voice.session[i]; if(session->state.current != CALL_INACTIVE){ - *in_call = true; + *is_call_active = true; break; } } @@ -389,7 +378,6 @@ int voice_extn_start_call(struct audio_device *adev) * udpated. */ ALOGV("%s: enter:", __func__); - adev->voice.voice_device_set = true; return update_calls(adev); } @@ -436,6 +424,7 @@ int voice_extn_set_parameters(struct audio_device *adev, err = str_parms_get_int(parms, AUDIO_PARAMETER_KEY_CALL_STATE, &value); if (err >= 0) { call_state = value; + str_parms_del(parms, AUDIO_PARAMETER_KEY_CALL_STATE); } else { ALOGE("%s: call_state key not found", __func__); ret = -EINVAL; diff --git a/hal/voice_extn/voice_extn.h b/hal/voice_extn/voice_extn.h index f7d20e4c..a31aefee 100644 --- a/hal/voice_extn/voice_extn.h +++ b/hal/voice_extn/voice_extn.h @@ -32,7 +32,8 @@ int voice_extn_set_parameters(struct audio_device *adev, void voice_extn_get_parameters(const struct audio_device *adev, struct str_parms *query, struct str_parms *reply); -int voice_extn_is_in_call(struct audio_device *adev, bool *in_call); +int voice_extn_is_call_state_active(struct audio_device *adev, + bool *is_call_active); int voice_extn_get_active_session_id(struct audio_device *adev, uint32_t *session_id); void voice_extn_in_get_parameters(struct stream_in *in, @@ -75,7 +76,8 @@ static void voice_extn_get_parameters(const struct audio_device *adev, { } -static int voice_extn_is_in_call(struct audio_device *adev, bool *in_call) +static int voice_extn_is_call_state_active(struct audio_device *adev, + bool *is_call_active) { return -ENOSYS; } |