return TTS_CONFIG_ERROR_NONE;
}
+
+int tts_config_mgr_get_instant_reprepare_client(unsigned int *uid)
+{
+ struct buxton_client *bux_cli = NULL;
+ int ret = buxton_open(&bux_cli, NULL, NULL);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_TTSCONFIG, "[BUXTON2] buxton_open failed!! (%d)", ret);
+ return TTS_CONFIG_ERROR_OPERATION_FAILED;
+ }
+
+ struct buxton_layer *bux_layer = buxton_create_layer("system");
+ if (NULL == bux_layer) {
+ SLOG(LOG_ERROR, TAG_TTSCONFIG, "[BUXTON2] buxton_create_layer FAIL");
+ buxton_close(bux_cli);
+ return TTS_CONFIG_ERROR_OPERATION_FAILED;
+ }
+
+ struct buxton_value *bux_val = NULL;
+ ret = buxton_get_value_sync(bux_cli, bux_layer, TTS_VCONF_INSTANT_REPREPARE_CLIENT, &bux_val);
+ if (0 != ret || NULL == bux_val) {
+ SLOG(LOG_ERROR, TAG_TTSCONFIG, "[BUXTON2] buxton_get_value_sync failed!! (%d)", ret);
+ buxton_free_layer(bux_layer);
+ buxton_close(bux_cli);
+ return TTS_CONFIG_ERROR_OPERATION_FAILED;
+ }
+
+ unsigned int specified_uid = TTS_INVALID_UID;
+ ret = buxton_value_get_uint32(bux_val, &specified_uid);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_TTSCONFIG, "[BUXTON2] buxton_value_get_uint32 failed!! (%d)", ret);
+ ret = TTS_CONFIG_ERROR_OPERATION_FAILED;
+ } else {
+ SLOG(LOG_DEBUG, TAG_TTSCONFIG, "[BUXTON2] buxton_value_get_uint32: ret(%d), key(%s), uid(%u)", ret, TTS_VCONF_INSTANT_REPREPARE_CLIENT, specified_uid);
+ *uid = specified_uid;
+ ret = TTS_CONFIG_ERROR_NONE;
+ }
+
+ buxton_value_free(bux_val);
+ buxton_free_layer(bux_layer);
+ buxton_close(bux_cli);
+
+ return ret;
+}
+
+int tts_config_mgr_set_instant_reprepare_client(const unsigned int uid)
+{
+ struct buxton_client *bux_cli = NULL;
+ int ret = buxton_open(&bux_cli, NULL, NULL);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_TTSCONFIG, "[BUXTON2] buxton_open failed!! (%d)", ret);
+ return TTS_CONFIG_ERROR_OPERATION_FAILED;
+ }
+
+ struct buxton_layer *bux_layer = buxton_create_layer("system");
+ if (NULL == bux_layer) {
+ SLOG(LOG_ERROR, TAG_TTSCONFIG, "[BUXTON2] buxton_create_layer FAIL");
+ buxton_close(bux_cli);
+ return TTS_CONFIG_ERROR_OPERATION_FAILED;
+ }
+
+ struct buxton_value *bux_val = buxton_value_create_uint32(uid);
+ if (NULL == bux_val) {
+ SLOG(LOG_ERROR, TAG_TTSCONFIG, "[BUXTON2] buxton_value_create_uint32 FAIL");
+ buxton_free_layer(bux_layer);
+ buxton_close(bux_cli);
+ return TTS_CONFIG_ERROR_OPERATION_FAILED;
+ }
+
+ SLOG(LOG_DEBUG, TAG_TTSCONFIG, "[BUXTON2] layer: %s", buxton_layer_get_name(bux_layer));
+ ret = buxton_set_value_sync(bux_cli, bux_layer, TTS_VCONF_INSTANT_REPREPARE_CLIENT, bux_val);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_TTSCONFIG, "[BUXTON2] buxton_set_value_sync failed!! (%d)", ret);
+ ret = TTS_CONFIG_ERROR_OPERATION_FAILED;
+ } else {
+ SLOG(LOG_DEBUG, TAG_TTSCONFIG, "[BUXTON2] buxton_set_value_sync: ret(%d), key(%s), uid(%u)", ret, TTS_VCONF_INSTANT_REPREPARE_CLIENT, uid);
+ ret = TTS_CONFIG_ERROR_NONE;
+ }
+
+ buxton_value_free(bux_val);
+ buxton_free_layer(bux_layer);
+ buxton_close(bux_cli);
+
+ return ret;
+}
bool tts_config_check_default_voice_is_valid(const char* language, int type);
-char* tts_config_get_message_path(int mode, int pid);
-
int tts_config_mgr_get_max_text_size(unsigned int* size);
+int tts_config_mgr_get_instant_reprepare_client(unsigned int *uid);
+
+int tts_config_mgr_set_instant_reprepare_client(const unsigned int uid);
+
#ifdef __cplusplus
}
#define TTS_PLAYING_STATUS_KEY "memory/tts/engine/voice-guide-playing"
+#define TTS_VCONF_INSTANT_REPREPARE_CLIENT "db/voice/tts/instant-reprepare-client"
+
/******************************************************************************************
* Defines for log tag
return 0;
}
+
+int ttsd_config_get_instant_reprepare_client(unsigned int *uid)
+{
+ if (NULL == uid)
+ return TTSD_ERROR_INVALID_PARAMETER;
+
+ int ret = tts_config_mgr_get_instant_reprepare_client(uid);
+ if (TTS_CONFIG_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, tts_tag(), "[Config ERROR] Fail to get uid of instatly reprepared client. ret(%d)", ret);
+ return TTSD_ERROR_OPERATION_FAILED;
+ }
+
+ return TTSD_ERROR_NONE;
+}
+
+int ttsd_config_set_instant_reprepare_client(const unsigned int uid)
+{
+ int ret = tts_config_mgr_set_instant_reprepare_client(uid);
+ if (TTS_CONFIG_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, tts_tag(), "[Config ERROR] Fail to set uid of instatly reprepared client. ret(%d)", ret);
+ return TTSD_ERROR_OPERATION_FAILED;
+ }
+
+ return TTSD_ERROR_NONE;
+}
int ttsd_config_save_error(unsigned int uid, int uttid, const char* lang, int vctype, const char* text,
const char* func, int line, const char* message);
+int ttsd_config_get_instant_reprepare_client(unsigned int *uid);
+
+int ttsd_config_set_instant_reprepare_client(const unsigned int uid);
+
#ifdef __cplusplus
}
#endif
return 0;
}
+unsigned int ttsd_data_get_first_client_uid()
+{
+ unique_lock<mutex> lock(g_app_data_mutex);
+ if (g_app_list.empty()) {
+ SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] There is no valid client");
+ return TTS_INVALID_UID;
+ }
+
+ return g_app_list[0].uid;
+}
+
bool ttsd_data_is_uttid_valid(unsigned int uid, int uttid)
{
lock_guard<mutex> lock(g_app_data_mutex);
int ttsd_data_foreach_clients(ttsd_data_get_client_cb callback, void* user_data);
+unsigned int ttsd_data_get_first_client_uid();
+
bool ttsd_data_is_uttid_valid(unsigned int uid, int uttid);
int ttsd_data_get_same_pid_client_count(int pid);
if (0 != ret) {
SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] ttsd Hello : server initialize, ret(%d)", ret);
}
- if (false == is_credential_needed) {
- credential_needed = 0;
- } else {
- credential_needed = 1;
- }
+ ttsd_server_update_instant_reprepare_client();
+
+ credential_needed = is_credential_needed ? 1 : 0;
} else {
SLOG(LOG_INFO, tts_tag(), "[IN] ttsd hello : already initialized. pid(%d), uid(%u)", pid, uid);
ret = TTS_ERROR_ALREADY_INITIALIZED;
} else {
SECURE_SLOG(LOG_DEBUG, tts_tag(), "[IN] tts initialize : pid(%d), uid(%u), mode(%d)", pid, uid, mode);
ret = ttsd_server_initialize(pid, uid, (ttsd_mode_e)mode, registered_event_mask, TTS_IPC_METHOD_DBUS, &service_state, &credential_needed);
+ ttsd_server_update_instant_reprepare_client();
}
DBusMessage* reply;
ret = TTSD_ERROR_OPERATION_FAILED;
} else {
SECURE_SLOG(LOG_DEBUG, tts_tag(), "[IN] tts finalize : uid(%u)", uid);
- ret = ttsd_server_finalize(uid);
+ ret = ttsd_server_finalize(uid);
+ ttsd_server_update_instant_reprepare_client();
}
DBusMessage* reply;
return TTSD_ERROR_NONE;
}
+int ttsd_server_update_instant_reprepare_client()
+{
+ SLOG(LOG_INFO, tts_tag(), "[Server] Update instant reprepare client");
+ unsigned int instant_reprepare_uid = TTS_INVALID_UID;
+ ttsd_config_get_instant_reprepare_client(&instant_reprepare_uid);
+
+ if (0 <= ttsd_data_is_client(instant_reprepare_uid)) {
+ SLOG(LOG_INFO, tts_tag(), "[Server] Uid(%u) is valid. Still no need to changee the value", instant_reprepare_uid);
+ return TTSD_ERROR_NONE;
+ }
+
+ unsigned int new_instant_reprepare_uid = ttsd_data_get_first_client_uid();
+ int ret = ttsd_config_set_instant_reprepare_client(new_instant_reprepare_uid);
+ if (TTSD_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, tts_tag(), "[Server] Fail to set UID(%u) of instant reprepare client", instant_reprepare_uid);
+ return TTSD_ERROR_OPERATION_FAILED;
+ }
+ SLOG(LOG_INFO, tts_tag(), "[Server] Update UID(%u) of instant reprepare client", instant_reprepare_uid);
+
+ return TTSD_ERROR_NONE;
+}
+
static bool __is_connected_to_network()
{
/* Check network */
int ttsd_server_finalize(unsigned int uid);
+int ttsd_server_update_instant_reprepare_client();
+
int ttsd_server_get_support_voices(unsigned int uid, GList** voice_list);
int ttsd_server_get_current_voice(unsigned int uid, char** language, int* voice_type);
if (0 != ttsd_server_finalize(uid)) {
return;
}
+ ttsd_server_update_instant_reprepare_client();
pthread_mutex_lock(&g_tidl_proxy_infos_mutex);
tts_tidl_proxy_info_s* info = __get_tidl_proxy_info_s(uid);
if (0 != ret) {
SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] ttsd Hello : server initialize, ret(%d)", ret);
}
+ ttsd_server_update_instant_reprepare_client();
credential_needed = is_credential_needed ? 1 : 0;
} else {
if (0 != ttsd_server_initialize(pid, u_uid, mode, registered_event_mask, TTS_IPC_METHOD_TIDL, &tmp_service_state, credential_needed)) {
return TTSD_ERROR_OPERATION_FAILED;
}
+ ttsd_server_update_instant_reprepare_client();
*service_state = (int)tmp_service_state;
SLOG(LOG_ERROR, tts_tag(), "[OUT] tts initialize service_state(%d), credential_needed(%d)", tmp_service_state, *credential_needed);
SLOG(LOG_ERROR, tts_tag(), "[ERROR] TTS FINALIZE (%u) fail (%d/%s) <<<<<", u_uid, ret, get_error_message(ret));
return ret;
}
+ ttsd_server_update_instant_reprepare_client();
pthread_mutex_lock(&g_tidl_proxy_infos_mutex);
tts_tidl_proxy_info_s* info = __get_tidl_proxy_info_s(u_uid);