return TTS_ERROR_NONE;
}
+int tts_prepare_sync(tts_h tts)
+{
+ if (0 != __tts_get_feature_enabled()) {
+ return TTS_ERROR_NOT_SUPPORTED;
+ }
+
+ SLOG(LOG_INFO, TAG_TTSC, "@@@ Prepare TTS");
+
+ tts_client_s* client = tts_client_get(tts);
+
+ /* check handle */
+ if (NULL == client) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not available");
+ SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
+ return TTS_ERROR_INVALID_PARAMETER;
+ }
+
+ /* check state */
+ if (client->current_state != TTS_STATE_CREATED) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Invalid State: Current state is not 'CREATED'");
+ SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
+ return TTS_ERROR_INVALID_STATE;
+ }
+
+ int cnt = 0;
+ while (EINA_TRUE == __tts_connect_daemon(NULL) && TTS_CONNECTION_RETRY_COUNT > cnt) {
+ cnt++;
+ }
+
+ SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
+
+ if (TTS_CONNECTION_RETRY_COUNT == cnt) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to connect daemon");
+ return TTS_ERROR_OPERATION_FAILED;
+ }
+
+ return TTS_ERROR_NONE;
+}
+
int tts_unprepare(tts_h tts)
{
if (0 != __tts_get_feature_enabled()) {
g_screen_reader = (bool)screen_reader;
}
+ bool is_prepared = false;
if (!(false == g_screen_reader && TTS_MODE_SCREEN_READER == client->mode)) {
do {
ret = tts_dbus_request_finalize(client->uid);
if (0 != ret) {
- if (TTS_ERROR_TIMED_OUT != ret) {
+ if (TTS_ERROR_INVALID_PARAMETER == ret && false == is_prepared) {
+ if (0 == tts_prepare_sync(tts)) {
+ is_prepared = true;
+ SLOG(LOG_INFO, TAG_TTSC, "[INFO] Success tts_prepare_sync");
+ }
+ } else if (TTS_ERROR_TIMED_OUT != ret) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] result : %s", __tts_get_error_code(ret));
break;
} else {
/* do request */
int ret = -1;
int count = 0;
+ bool is_prepared = false;
while (0 != ret) {
ret = tts_dbus_request_add_text(client->uid, text, temp, voice_type, speed, client->current_utt_id, client->credential);
if (0 != ret) {
- if (TTS_ERROR_TIMED_OUT != ret) {
+ if (TTS_ERROR_INVALID_PARAMETER == ret && false == is_prepared) {
+ if (0 == tts_prepare_sync(tts)) {
+ is_prepared = true;
+ SLOG(LOG_INFO, TAG_TTSC, "[INFO] Success tts_prepare_sync");
+ }
+ } else if (TTS_ERROR_TIMED_OUT != ret) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] result : %s", __tts_get_error_code(ret));
break;
} else {
int ret = -1;
int count = 0;
+ bool is_prepared = false;
while (0 != ret) {
ret = tts_dbus_request_play(client->uid, client->credential);
if (0 != ret) {
- if (TTS_ERROR_TIMED_OUT != ret) {
+ if (TTS_ERROR_INVALID_PARAMETER == ret && false == is_prepared) {
+ if (0 == tts_prepare_sync(tts)) {
+ is_prepared = true;
+ SLOG(LOG_INFO, TAG_TTSC, "[INFO] Success tts_prepare_sync");
+ }
+ } else if (TTS_ERROR_TIMED_OUT != ret) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] result : %s", __tts_get_error_code(ret));
break;
} else {
int ret = -1;
int count = 0;
+ bool is_prepared = false;
while (0 != ret) {
ret = tts_dbus_request_play(client->uid, client->credential);
if (0 != ret) {
- if (TTS_ERROR_TIMED_OUT != ret) {
+ if (TTS_ERROR_INVALID_PARAMETER == ret && false == is_prepared) {
+ if (0 == tts_prepare_sync(tts)) {
+ is_prepared = true;
+ SLOG(LOG_INFO, TAG_TTSC, "[INFO] Success tts_prepare_sync");
+ }
+ } else if (TTS_ERROR_TIMED_OUT != ret) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] result : %s", __tts_get_error_code(ret));
return ret;
} else {
int ret = -1;
int count = 0;
+ bool is_prepared = false;
while (0 != ret) {
ret = tts_dbus_request_stop(client->uid);
if (0 != ret) {
- if (TTS_ERROR_TIMED_OUT != ret) {
+ if (TTS_ERROR_INVALID_PARAMETER == ret && false == is_prepared) {
+ if (0 == tts_prepare_sync(tts)) {
+ is_prepared = true;
+ SLOG(LOG_INFO, TAG_TTSC, "[INFO] Success tts_prepare_sync");
+ }
+ } else if (TTS_ERROR_TIMED_OUT != ret) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] result : %s", __tts_get_error_code(ret));
break;
} else {
int ret = -1;
int count = 0;
+ bool is_prepared = false;
while (0 != ret) {
ret = tts_dbus_request_stop(client->uid);
if (0 != ret) {
- if (TTS_ERROR_TIMED_OUT != ret) {
+ if (TTS_ERROR_INVALID_PARAMETER == ret && false == is_prepared) {
+ if (0 == tts_prepare_sync(tts)) {
+ is_prepared = true;
+ SLOG(LOG_INFO, TAG_TTSC, "[INFO] Success tts_prepare_sync");
+ }
+ } else if (TTS_ERROR_TIMED_OUT != ret) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] result : %s", __tts_get_error_code(ret));
return ret;
} else {
int ret = -1;
int count = 0;
+ bool is_prepared = false;
while (0 != ret) {
ret = tts_dbus_request_pause(client->uid);
if (0 != ret) {
- if (TTS_ERROR_TIMED_OUT != ret) {
+ if (TTS_ERROR_INVALID_PARAMETER == ret && false == is_prepared) {
+ if (0 == tts_prepare_sync(tts)) {
+ is_prepared = true;
+ SLOG(LOG_INFO, TAG_TTSC, "[INFO] Success tts_prepare_sync");
+ }
+ } else if (TTS_ERROR_TIMED_OUT != ret) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] result : %s", __tts_get_error_code(ret));
break;
} else {
int ret = -1;
int count = 0;
+ bool is_prepared = false;
while (0 != ret) {
ret = tts_dbus_request_pause(client->uid);
if (0 != ret) {
- if (TTS_ERROR_TIMED_OUT != ret) {
+ if (TTS_ERROR_INVALID_PARAMETER == ret && false == is_prepared) {
+ if (0 == tts_prepare_sync(tts)) {
+ is_prepared = true;
+ SLOG(LOG_INFO, TAG_TTSC, "[INFO] Success tts_prepare_sync");
+ }
+ } else if (TTS_ERROR_TIMED_OUT != ret) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] result : %s", __tts_get_error_code(ret));
return ret;
} else {
int ret = -1;
int count = 0;
+ bool is_prepared = false;
while (0 != ret) {
ret = tts_dbus_request_set_private_data(client->uid, key, data);
if (0 != ret) {
- if (TTS_ERROR_TIMED_OUT != ret) {
+ if (TTS_ERROR_INVALID_PARAMETER == ret && false == is_prepared) {
+ if (0 == tts_prepare_sync(tts)) {
+ is_prepared = true;
+ SLOG(LOG_INFO, TAG_TTSC, "[INFO] Success tts_prepare_sync");
+ }
+ } else if (TTS_ERROR_TIMED_OUT != ret) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] result : %s", __tts_get_error_code(ret));
return ret;
} else {
int ret = -1;
int count = 0;
+ bool is_prepared = false;
while (0 != ret) {
ret = tts_dbus_request_get_private_data(client->uid, key, data);
if (0 != ret) {
- if (TTS_ERROR_TIMED_OUT != ret) {
+ if (TTS_ERROR_INVALID_PARAMETER == ret && false == is_prepared) {
+ if (0 == tts_prepare_sync(tts)) {
+ is_prepared = true;
+ SLOG(LOG_INFO, TAG_TTSC, "[INFO] Success tts_prepare_sync");
+ }
+ } else if (TTS_ERROR_TIMED_OUT != ret) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] result : %s", __tts_get_error_code(ret));
return ret;
} else {
int ret = -1;
int count = 0;
+ bool is_prepared = false;
while (0 != ret) {
ret = tts_dbus_request_add_pcm(client->uid, event, data, data_size, audio_type, rate);
if (0 != ret) {
- if (TTS_ERROR_TIMED_OUT != ret) {
+ if (TTS_ERROR_INVALID_PARAMETER == ret && false == is_prepared) {
+ if (0 == tts_prepare_sync(tts)) {
+ is_prepared = true;
+ SLOG(LOG_INFO, TAG_TTSC, "[INFO] Success tts_prepare_sync");
+ }
+ } else if (TTS_ERROR_TIMED_OUT != ret) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] result : %s", __tts_get_error_code(ret));
return ret;
} else {
int ret = -1;
int count = 0;
+ bool is_prepared = false;
while (0 != ret) {
ret = tts_dbus_request_play_pcm(client->uid);
if (0 != ret) {
- if (TTS_ERROR_TIMED_OUT != ret) {
+ if (TTS_ERROR_INVALID_PARAMETER == ret && false == is_prepared) {
+ if (0 == tts_prepare_sync(tts)) {
+ is_prepared = true;
+ SLOG(LOG_INFO, TAG_TTSC, "[INFO] Success tts_prepare_sync");
+ }
+ } else if (TTS_ERROR_TIMED_OUT != ret) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] result : %s", __tts_get_error_code(ret));
return ret;
} else {
int ret = -1;
int count = 0;
+ bool is_prepared = false;
while (0 != ret) {
ret = tts_dbus_request_stop_pcm(client->uid);
if (0 != ret) {
- if (TTS_ERROR_TIMED_OUT != ret) {
+ if (TTS_ERROR_INVALID_PARAMETER == ret && false == is_prepared) {
+ if (0 == tts_prepare_sync(tts)) {
+ is_prepared = true;
+ SLOG(LOG_INFO, TAG_TTSC, "[INFO] Success tts_prepare_sync");
+ }
+ } else if (TTS_ERROR_TIMED_OUT != ret) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] result : %s", __tts_get_error_code(ret));
return ret;
} else {