return audio_ret;
}
+static audio_return_t __save_route_infos(audio_hal_t *ah, device_info_t *devices, int32_t num_of_devices)
+{
+ int i = 0;
+
+ AUDIO_RETURN_VAL_IF_FAIL(ah, AUDIO_ERR_PARAMETER);
+ AUDIO_RETURN_VAL_IF_FAIL(devices, AUDIO_ERR_PARAMETER);
+
+ for (i = 0; i < MAX_DIRECTION; i++) {
+ if (!ah->saved_route_infos[i]) {
+ ah->saved_route_infos[i] = malloc(sizeof(audio_route_info_t));
+ memset(ah->saved_route_infos[i], 0, sizeof(audio_route_info_t));
+
+ ah->saved_route_infos[i]->device_infos = malloc(sizeof(device_info_t));
+ memcpy(ah->saved_route_infos[i]->device_infos, devices, sizeof(device_info_t));
+
+ ah->saved_route_infos[i]->num_of_devices = num_of_devices;
+
+ AUDIO_LOG_INFO("SAVE route infos[%d]: device_infos->type[%s],id[%u]",
+ i, ah->saved_route_infos[i]->device_infos->type, ah->saved_route_infos[i]->device_infos->id);
+ return AUDIO_RET_OK;
+ }
+ }
+
+ AUDIO_LOG_ERROR("could not find empty slot to save route infos");
+ return AUDIO_ERR_INTERNAL;
+}
+
+static void __reset_saved_route_infos(void *audio_handle)
+{
+ audio_hal_t *ah = (audio_hal_t *)audio_handle;
+ int i = 0;
+
+ AUDIO_RETURN_IF_FAIL(ah);
+
+ for (i = 0; i < MAX_DIRECTION; i++) {
+ if (ah->saved_route_infos[i]) {
+ if (ah->saved_route_infos[i]->device_infos)
+ free(ah->saved_route_infos[i]->device_infos);
+ free(ah->saved_route_infos[i]);
+ ah->saved_route_infos[i] = NULL;
+ AUDIO_LOG_INFO("reset saved route infos[%d] well", i);
+ }
+ }
+}
+
static audio_return_t __update_route_ap_playback_capture(audio_hal_t *ah, audio_route_info_t *route_info)
{
audio_return_t audio_ret = AUDIO_RET_OK;
AUDIO_LOG_INFO("update_route_voicecall++");
+ if (!strncmp(devices[0].type, "bt-sco", MAX_NAME_LEN))
+ if (!ah->device.bt_sco_ready)
+ return __save_route_infos(ah, devices, num_of_devices);
+
if ((audio_ret = __set_devices(ah, verb, devices, num_of_devices))) {
AUDIO_LOG_ERROR("Failed to set devices: error = 0x%x", audio_ret);
return audio_ret;
}
}
+ __reset_saved_route_infos(ah);
+
if (active_devices[0] == NULL) {
AUDIO_LOG_DEBUG("active device is NULL, no need to update.");
return AUDIO_RET_OK;
/* reset bandwidth information */
ah->device.bt_wideband = false;
ah->call_wideband = false;
+ ah->device.bt_sco_ready = false;
return audio_ret;
}
-audio_return_t _audio_update_route_voicecall(audio_hal_t *ah, device_info_t *devices, int32_t num_of_devices)
-{
- return __update_route_voicecall(ah, devices, num_of_devices);
-}
-
audio_return_t _audio_routing_init(audio_hal_t *ah)
{
audio_return_t audio_ret = AUDIO_RET_OK;
ah->device.bt_wideband = (option->value > 0) ? true : false;
} else if (!strncmp("call-wideband", option->name, MAX_NAME_LEN)) {
ah->call_wideband = (option->value > 0) ? true : false;
+ } else if (!strncmp("bt-sco-ready", option->name, MAX_NAME_LEN)) {
+ ah->device.bt_sco_ready = (option->value > 0) ? true : false;
+ if (ah->device.bt_sco_ready) {
+ int i = 0;
+ for (i = 0; i < MAX_DIRECTION; i++) {
+ if (ah->saved_route_infos[i]) {
+ if ((audio_ret = __update_route_voicecall(ah, ah->saved_route_infos[i]->device_infos, ah->saved_route_infos[i]->num_of_devices)))
+ AUDIO_LOG_WARN("update voicecall route from SAVED return 0x%x", audio_ret);
+ }
+ }
+ }
+ __reset_saved_route_infos(ah);
} else {
AUDIO_LOG_ERROR("undefined route option");
audio_ret = AUDIO_ERR_UNDEFINED;
}
return audio_ret;
-}
+}
\ No newline at end of file