return ret;
}
-audio_return_t _voice_pcm_open(audio_hal_t *ah)
+audio_return_t _voice_pcm_open_all(audio_hal_t *ah)
{
AUDIO_RETURN_VAL_IF_FAIL(ah, AUDIO_ERR_PARAMETER);
AUDIO_DEVICE_DIRECTION_IN | AUDIO_DEVICE_DIRECTION_OUT, 48000, 2);
}
-audio_return_t _bt_pcm_open(audio_hal_t *ah)
+audio_return_t _bt_pcm_open_all(audio_hal_t *ah)
{
uint32_t samplerate;
return false;
}
-audio_return_t _voice_pcm_close(audio_hal_t *ah)
+audio_return_t _voice_pcm_close_all(audio_hal_t *ah)
{
audio_return_t audio_ret = AUDIO_RET_OK;
AUDIO_LOG_ERROR("failed to _pcm_close() for voice pcm out, ret(0x%x)", audio_ret);
else {
ah->device.voice_pcm.out = NULL;
- AUDIO_LOG_INFO("voice pcm_out handle close success");
+ AUDIO_LOG_INFO("voice pcm out handle close success");
}
}
if (ah->device.voice_pcm.in) {
AUDIO_LOG_ERROR("failed to _pcm_close() for voice pcm in, ret(0x%x)", audio_ret);
else {
ah->device.voice_pcm.in = NULL;
- AUDIO_LOG_INFO("voice pcm_in handle close success");
+ AUDIO_LOG_INFO("voice pcm in handle close success");
}
}
return audio_ret;
}
-audio_return_t _bt_pcm_close(audio_hal_t *ah)
+audio_return_t _bt_pcm_close_all(audio_hal_t *ah)
{
audio_return_t audio_ret = AUDIO_RET_OK;
AUDIO_LOG_ERROR("failed to _pcm_close() for bt pcm out, ret(0x%x)", audio_ret);
else {
ah->device.bt_pcm.out = NULL;
- AUDIO_LOG_INFO("bt pcm_out handle close success");
+ AUDIO_LOG_INFO("bt pcm out handle close success");
}
}
if (ah->device.bt_pcm.in) {
AUDIO_LOG_ERROR("failed to _pcm_close() for bt pcm in, ret(0x%x)", audio_ret);
else {
ah->device.bt_pcm.in = NULL;
- AUDIO_LOG_INFO("voice pcm_in handle close success");
+ AUDIO_LOG_INFO("bt pcm in handle close success");
}
}
return audio_ret;
}
-audio_return_t _reset_pcm_devices(audio_hal_t *ah)
+void _reset_pcm_devices(audio_hal_t *ah)
{
- audio_return_t audio_ret = AUDIO_RET_OK;
-
- AUDIO_RETURN_VAL_IF_FAIL(ah, AUDIO_ERR_PARAMETER);
+ AUDIO_RETURN_IF_FAIL(ah);
- if (ah->device.voice_pcm.out) {
- if (!(audio_ret = _pcm_close(ah->device.voice_pcm.out))) {
- ah->device.voice_pcm.out = NULL;
- AUDIO_LOG_INFO("voice pcm out handle close success");
- }
- }
- if (ah->device.voice_pcm.in) {
- if (!(audio_ret = _pcm_close(ah->device.voice_pcm.in))) {
- ah->device.voice_pcm.in = NULL;
- AUDIO_LOG_INFO("voice pcm in handle close success");
- }
- }
- if (ah->device.bt_pcm.out) {
- if (!(audio_ret = _pcm_close(ah->device.bt_pcm.out))) {
- ah->device.bt_pcm.out = NULL;
- AUDIO_LOG_INFO("bt pcm out handle close success");
- }
- }
- if (ah->device.bt_pcm.in) {
- if (!(audio_ret = _pcm_close(ah->device.bt_pcm.in))) {
- ah->device.bt_pcm.in = NULL;
- AUDIO_LOG_INFO("bt pcm in handle close success");
- }
- }
-
- return audio_ret;
+ _voice_pcm_close_all(ah);
+ _bt_pcm_close_all(ah);
}
audio_return_t _pcm_open(void **pcm_handle, uint32_t direction, void *sample_spec, uint32_t period_size, uint32_t periods)
#include <stdbool.h>
/* PCM */
-audio_return_t _voice_pcm_open(audio_hal_t *ah);
-audio_return_t _voice_pcm_close(audio_hal_t *ah);
-audio_return_t _bt_pcm_open(audio_hal_t *ah);
-audio_return_t _bt_pcm_close(audio_hal_t *ah);
+audio_return_t _voice_pcm_open_all(audio_hal_t *ah);
+audio_return_t _voice_pcm_close_all(audio_hal_t *ah);
+audio_return_t _bt_pcm_open_all(audio_hal_t *ah);
+audio_return_t _bt_pcm_close_all(audio_hal_t *ah);
bool _is_voice_pcm_opened_all(audio_hal_t *ah);
bool _is_bt_pcm_opened_all(audio_hal_t *ah);
-audio_return_t _reset_pcm_devices(audio_hal_t *ah);
+void _reset_pcm_devices(audio_hal_t *ah);
audio_return_t _pcm_open(void **pcm_handle, uint32_t direction, void *sample_spec, uint32_t period_size, uint32_t periods);
audio_return_t _pcm_start(void *pcm_handle);
audio_return_t _pcm_stop(void *pcm_handle);
return device;
}
-static void __reset_voice_devices_info(audio_hal_t *ah)
-{
- AUDIO_RETURN_IF_FAIL(ah);
-
- AUDIO_LOG_INFO("reset voice device info");
-#if 0
- if (ah->device.init_call_devices) {
- free(ah->device.init_call_devices);
- ah->device.init_call_devices = NULL;
- ah->device.num_of_call_devices = 0;
- }
-#endif
-
- return;
-}
-
static audio_return_t __set_devices(audio_hal_t *ah, const char *verb, device_info_t *devices, uint32_t num_of_devices)
{
audio_return_t audio_ret = AUDIO_RET_OK;
AUDIO_RETURN_VAL_IF_FAIL(route_info, AUDIO_ERR_PARAMETER);
if (ah->device.mode != VERB_NORMAL) {
- if (ah->device.mode == VERB_VOICECALL) {
- __reset_voice_devices_info(ah);
- }
_reset_pcm_devices(ah);
ah->device.mode = VERB_NORMAL;
}
AUDIO_LOG_INFO("voice pcm device is already opened, skip it");
return audio_ret;
}
- if ((audio_ret = _voice_pcm_open(ah))) {
+ if ((audio_ret = _voice_pcm_open_all(ah))) {
AUDIO_LOG_ERROR("Failed to open voice pcm device: error = 0x%x", audio_ret);
return audio_ret;
}
return audio_ret;
}
- if ((audio_ret = _bt_pcm_open(ah))) {
+ if ((audio_ret = _bt_pcm_open_all(ah))) {
+ AUDIO_LOG_ERROR("Failed to open bt pcm device: error = 0x%x", audio_ret);
+ return audio_ret;
+ }
+ }
+
+ return audio_ret;
+}
+
+static audio_return_t __update_route_voice_information(audio_hal_t *ah, device_info_t *devices, int32_t num_of_devices)
+{
+ audio_return_t audio_ret = AUDIO_RET_OK;
+ const char *verb = mode_to_verb_str[VERB_NORMAL];
+
+ AUDIO_RETURN_VAL_IF_FAIL(ah, AUDIO_ERR_PARAMETER);
+ AUDIO_RETURN_VAL_IF_FAIL(devices, AUDIO_ERR_PARAMETER);
+
+ AUDIO_LOG_INFO("update_route_voice_information++");
+
+ audio_ret = __set_devices(ah, verb, devices, num_of_devices);
+ if (audio_ret) {
+ AUDIO_LOG_ERROR("Failed to set devices: error = 0x%x", audio_ret);
+ return audio_ret;
+ }
+
+ if (ah->device.mode != VERB_NORMAL) {
+ ah->device.mode = VERB_NORMAL;
+ _reset_pcm_devices(ah);
+ }
+ /* if this request is for BT SCO device */
+ if (ah->device.active_out & AUDIO_DEVICE_OUT_BT_SCO) {
+ if (_is_bt_pcm_opened_all(ah)) {
+ AUDIO_LOG_INFO("bt pcm device is already opened, skip it");
+ return audio_ret;
+ }
+
+ if ((audio_ret = _bt_pcm_open_all(ah))) {
AUDIO_LOG_ERROR("Failed to open bt pcm device: error = 0x%x", audio_ret);
return audio_ret;
}
}
if (ah->device.mode == VERB_VOICECALL) {
- if ((audio_ret = _bt_pcm_close(ah)))
+ if ((audio_ret = _bt_pcm_close_all(ah)))
AUDIO_LOG_ERROR("failed to _bt_pcm_close(), ret(0x%x)", audio_ret);
- if ((audio_ret = _voice_pcm_close(ah)))
+ if ((audio_ret = _voice_pcm_close_all(ah)))
AUDIO_LOG_ERROR("failed to _voice_pcm_close(), ret(0x%x)", audio_ret);
if (!ah->device.active_in && !ah->device.active_out)
ah->device.mode = VERB_NORMAL;
- __reset_voice_devices_info(ah);
} else if (ah->device.mode == VERB_NORMAL) {
if (direction == AUDIO_DIRECTION_IN) {
/* voice-recognition case */
- if ((audio_ret = _bt_pcm_close(ah)))
+ if ((audio_ret = _bt_pcm_close_all(ah)))
AUDIO_LOG_ERROR("failed to _bt_pcm_close(), ret(0x%x)", audio_ret);
}
}
if ((audio_ret = __update_route_voice_recognition(ah, devices, info->num_of_devices)))
AUDIO_LOG_WARN("update voice-recognition route return 0x%x", audio_ret);
+ } else if (!strncmp("voice-information", info->role, MAX_NAME_LEN)) {
+ if ((audio_ret = __update_route_voice_information(ah, devices, info->num_of_devices)))
+ AUDIO_LOG_WARN("update voice-information route return 0x%x", audio_ret);
+
} else if (!strncmp("reset", info->role, MAX_NAME_LEN)) {
if ((audio_ret = __update_route_reset(ah, devices->direction)))
AUDIO_LOG_WARN("update reset return 0x%x", audio_ret);
} else {
- /* need to prepare for "alarm","notification","emergency","voice-information","ringtone" */
+ /* need to prepare for "alarm","notification","emergency","ringtone" */
if ((audio_ret = __update_route_ap_playback_capture(ah, info)))
AUDIO_LOG_WARN("update playback route return 0x%x", audio_ret);
}