rpc_port_proxy_tts_h handle = NULL;
uintptr_t ptr_uid = uid;
- if (0 != rpc_port_proxy_tts_create(engine_app_id, &rpc_callback, (void*)ptr_uid, &handle)) {
+ if (RPC_PORT_ERROR_NONE != rpc_port_proxy_tts_create(engine_app_id, &rpc_callback, (void*)ptr_uid, &handle)) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to create proxy");
return NULL;
}
tts_tidl_info_s* info = __get_tidl_info_s(uid);
RETVM_IF(NULL == info, TTS_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info");
- if (0 != rpc_port_proxy_tts_destroy(info->rpc_h)) {
+ if (RPC_PORT_ERROR_NONE != rpc_port_proxy_tts_destroy(info->rpc_h)) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to disconnect");
return TTS_ERROR_OPERATION_FAILED;
}
int ret = __create_notify_callback_handle(info);
if (TTS_ERROR_NONE != ret) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to create callback handle. ret(%d)", ret);
- return TTS_ERROR_OPERATION_FAILED;
+ return ret;
}
rpc_port_proxy_tts_invoke_register_cb(info->rpc_h, pid, info->uid, info->notify_cb_h);
if (NULL == info->engine_app_id || 0 != strncmp(info->engine_app_id, engine_app_id, TTS_ENGINE_APPID_LEN)) {
SLOG(LOG_ERROR, TAG_TTSC, "[TIDL] tts engine is changed from (%s) to (%s)", info->engine_app_id, engine_app_id);
- if (0 != rpc_port_proxy_tts_destroy(info->rpc_h)) {
+ if (RPC_PORT_ERROR_NONE != rpc_port_proxy_tts_destroy(info->rpc_h)) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to destroy old rpc_port");
return TTS_ERROR_OPERATION_FAILED;
}
return TTS_ERROR_OPERATION_FAILED;
}
+static int __convert_unhandled_error(int ret)
+{
+ if (RPC_PORT_ERROR_IO_ERROR == ret || RPC_PORT_ERROR_OUT_OF_MEMORY == ret) {
+ return TTS_ERROR_OPERATION_FAILED;
+ }
+
+ return ret;
+}
+
static int __invoke_register_callback_sync(int pid, tts_tidl_info_s* info)
{
if (info->register_callback_invoked) {
return TTS_ERROR_NONE;
}
- int ret = RPC_PORT_ERROR_NONE;
+ int ret = TTS_ERROR_NONE;
ret = __create_notify_callback_handle(info);
- if (RPC_PORT_ERROR_NONE != ret) {
+ if (TTS_ERROR_NONE != ret) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to create callback handle. ret(%d/%s)", ret, get_error_message(ret));
- return TTS_ERROR_OPERATION_FAILED;
+ return ret;
}
ret = rpc_port_proxy_tts_invoke_register_cb_sync(info->rpc_h, pid, info->uid, info->notify_cb_h);
- if (RPC_PORT_ERROR_NONE != ret) {
+ int exception = get_last_result();
+ if (RPC_PORT_ERROR_NONE != exception) {
+ ret = __convert_unhandled_error(exception);
+ }
+
+ if (TTS_ERROR_NONE != ret) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to register callback. ret(%d/%s)", ret, get_error_message(ret));
- return TTS_ERROR_OPERATION_FAILED;
+ return ret;
}
info->register_callback_invoked = true;
return TTS_ERROR_NONE;
}
-static int __covert_unhandled_error(int ret)
-{
- if (RPC_PORT_ERROR_IO_ERROR == ret || RPC_PORT_ERROR_OUT_OF_MEMORY == ret) {
- return TTS_ERROR_OPERATION_FAILED;
- }
-
- return ret;
-}
-
int tts_tidl_request_initialize(unsigned int uid, bool* credential_needed)
{
SLOG(LOG_DEBUG, TAG_TTSC, "[TIDL] tts_tidl_request_initialize");
bool temp;
int ret = rpc_port_proxy_tts_invoke_initialize(info->rpc_h, client->pid, uid, &temp);
- if (RPC_PORT_ERROR_NONE != ret) {
+ int exception = get_last_result();
+ if (RPC_PORT_ERROR_NONE != exception) {
+ ret = __convert_unhandled_error(exception);
+ }
+
+ if (TTS_ERROR_NONE != ret) {
SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts initialize : Fail to invoke message");
- return __covert_unhandled_error(ret);
+ return ret;
}
*credential_needed = temp;
int ret = rpc_port_proxy_tts_invoke_finalize(info->rpc_h, uid);
- if (RPC_PORT_ERROR_NONE != ret) {
+ int exception = get_last_result();
+ if (RPC_PORT_ERROR_NONE != exception) {
+ ret = __convert_unhandled_error(exception);
+ }
+
+ if (TTS_ERROR_NONE != ret) {
SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts initialize : Fail to invoke message");
- return __covert_unhandled_error(ret);
+ return ret;
}
tts_client_set_start_listening(uid, false);
const char *not_null_credential = NULL == credential ? "NULL" : credential;
int ret = rpc_port_proxy_tts_invoke_add_text(info->rpc_h, uid, text, lang, vctype, speed, uttid, not_null_credential);
- if (RPC_PORT_ERROR_NONE != ret) {
+ int exception = get_last_result();
+ if (RPC_PORT_ERROR_NONE != exception) {
+ ret = __convert_unhandled_error(exception);
+ }
+
+ if (TTS_ERROR_NONE != ret) {
SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request add text : Fail to invoke message");
- return __covert_unhandled_error(ret);
+ return ret;
}
return TTS_ERROR_NONE;
int ret = rpc_port_proxy_tts_invoke_set_private(info->rpc_h, uid, key, data);
- if (RPC_PORT_ERROR_NONE != ret) {
+ int exception = get_last_result();
+ if (RPC_PORT_ERROR_NONE != exception) {
+ ret = __convert_unhandled_error(exception);
+ }
+
+ if (TTS_ERROR_NONE != ret) {
SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request set private data : Fail to invoke message");
- return __covert_unhandled_error(ret);
+ return ret;
}
return TTS_ERROR_NONE;
RETVM_IF(!info->connected, TTS_ERROR_OPERATION_FAILED, "[ERROR] Not Connected");
-
char *tmp = NULL;
int ret = rpc_port_proxy_tts_invoke_get_private(info->rpc_h, uid, key, &tmp);
- if (RPC_PORT_ERROR_NONE != ret) {
+ int exception = get_last_result();
+ if (RPC_PORT_ERROR_NONE != exception) {
+ ret = __convert_unhandled_error(exception);
+ }
+
+ if (TTS_ERROR_NONE != ret) {
SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request get private data : Fail to invoke message");
free(tmp);
- return __covert_unhandled_error(ret);
+ return ret;
}
- SLOG(LOG_DEBUG, TAG_TTSC, "<<<<");
*data = tmp;
+ SLOG(LOG_DEBUG, TAG_TTSC, "<<<<");
return TTS_ERROR_NONE;
}
const char *not_null_credential = NULL == credential ? "NULL" : credential;
int ret = rpc_port_proxy_tts_invoke_play(info->rpc_h, uid, not_null_credential);
- if (RPC_PORT_ERROR_NONE != ret) {
+ int exception = get_last_result();
+ if (RPC_PORT_ERROR_NONE != exception) {
+ ret = __convert_unhandled_error(exception);
+ }
+
+ if (TTS_ERROR_NONE != ret) {
SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request play : Fail to invoke message");
- return __covert_unhandled_error(ret);
+ return ret;
}
SLOG(LOG_DEBUG, TAG_TTSC, "<<<<");
RETVM_IF(!info->connected, TTS_ERROR_OPERATION_FAILED, "[ERROR] Not Connected");
int ret = rpc_port_proxy_tts_invoke_stop(info->rpc_h, uid);
- if (RPC_PORT_ERROR_NONE != ret) {
+ int exception = get_last_result();
+ if (RPC_PORT_ERROR_NONE != exception) {
+ ret = __convert_unhandled_error(exception);
+ }
+
+ if (TTS_ERROR_NONE != ret) {
SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request stop : Fail to invoke message");
- return __covert_unhandled_error(ret);
+ return ret;
}
SLOG(LOG_DEBUG, TAG_TTSC, "<<<<");
RETVM_IF(!info->connected, TTS_ERROR_OPERATION_FAILED, "[ERROR] Not Connected");
int ret = rpc_port_proxy_tts_invoke_pause(info->rpc_h, uid);
- if (RPC_PORT_ERROR_NONE != ret) {
+ int exception = get_last_result();
+ if (RPC_PORT_ERROR_NONE != exception) {
+ ret = __convert_unhandled_error(exception);
+ }
+
+ if (TTS_ERROR_NONE != ret) {
SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request pause : Fail to invoke message(%d)", ret);
- return __covert_unhandled_error(ret);
+ return ret;
}
SLOG(LOG_DEBUG, TAG_TTSC, "<<<<");
RETVM_IF(!info->connected, TTS_ERROR_OPERATION_FAILED, "[ERROR] Not Connected");
int ret = rpc_port_proxy_tts_invoke_play_pcm(info->rpc_h, uid);
- if (RPC_PORT_ERROR_NONE != ret) {
+ int exception = get_last_result();
+ if (RPC_PORT_ERROR_NONE != exception) {
+ ret = __convert_unhandled_error(exception);
+ }
+
+ if (TTS_ERROR_NONE != ret) {
SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request play pcm : Fail to invoke message(%d)", ret);
- return __covert_unhandled_error(ret);
+ return ret;
}
SLOG(LOG_DEBUG, TAG_TTSC, "<<<<");
RETVM_IF(!info->connected, TTS_ERROR_OPERATION_FAILED, "[ERROR] Not Connected");
int ret = rpc_port_proxy_tts_invoke_stop_pcm(info->rpc_h, uid);
- if (RPC_PORT_ERROR_NONE != ret) {
+ int exception = get_last_result();
+ if (RPC_PORT_ERROR_NONE != exception) {
+ ret = __convert_unhandled_error(exception);
+ }
+
+ if (TTS_ERROR_NONE != ret) {
SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request pause pcm : Fail to invoke message(%d)", ret);
- return __covert_unhandled_error(ret);
+ return ret;
}
SLOG(LOG_DEBUG, TAG_TTSC, "<<<<");
int ret = rpc_port_proxy_tts_invoke_add_pcm(info->rpc_h, uid, event, pcm_data, data_size, audio_type, rate);
rpc_port_proxy_array_char_destroy(pcm_data);
- if (RPC_PORT_ERROR_NONE != ret) {
+ int exception = get_last_result();
+ if (RPC_PORT_ERROR_NONE != exception) {
+ ret = __convert_unhandled_error(exception);
+ }
+
+ if (TTS_ERROR_NONE != ret) {
SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request pause pcm : Fail to invoke message(%d)", ret);
- return __covert_unhandled_error(ret);
+ return ret;
}
SLOG(LOG_DEBUG, TAG_TTSC, "<<<<");
RETVM_IF(!info->connected, TTS_ERROR_OPERATION_FAILED, "[ERROR] Not Connected");
int ret = rpc_port_proxy_tts_invoke_set_mode(info->rpc_h, uid, mode);
- if (RPC_PORT_ERROR_NONE != ret) {
+ int exception = get_last_result();
+ if (RPC_PORT_ERROR_NONE != exception) {
+ ret = __convert_unhandled_error(exception);
+ }
+
+ if (TTS_ERROR_NONE != ret) {
SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request set private data : Fail to invoke message(%d)", ret);
- return __covert_unhandled_error(ret);
+ return ret;
}
return TTS_ERROR_NONE;