return TTS_ERROR_INVALID_PARAMETER;
}
+ // TODO: fix state check, because set_private_data runs only ready state
tts_state_e current_state = tts_client_get_current_state(client);
if (TTS_STATE_CREATED != current_state && TTS_STATE_READY != current_state) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] The current state is invalid");
return TTS_ERROR_OPERATION_FAILED;
}
- ret = tts_set_private_data(tts, key, appid);
+ ret = tts_core_set_private_data(client, key, appid);
if (0 != ret) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to set private data, ret(%d), pid(%d), appid(%s)", ret, pid, appid);
free(key);
return TTS_ERROR_INVALID_PARAMETER;
}
- // TODO: move into tts_core
- int uid = tts_client_get_uid(client);
- int ret = -1;
- int count = 0;
- bool is_prepared = false;
- while (0 != ret) {
- ret = tts_ipc_request_set_private_data(uid, key, data);
- if (0 != ret) {
- //LCOV_EXCL_START
- if (TTS_ERROR_INVALID_PARAMETER == ret && false == is_prepared) {
- tts_client_set_current_state(client, TTS_STATE_CREATED);
- if (0 == tts_core_prepare_sync(client)) {
- 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 {
- SLOG(LOG_WARN, TAG_TTSC, "[WARNING] retry : %s", __tts_get_error_code(ret));
- usleep(10000);
- count++;
- if (TTS_RETRY_COUNT == count) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to request");
- return ret;
- }
- }
- //LCOV_EXCL_STOP
- }
+ int ret = tts_core_set_private_data(client, key, data);
+ if (TTS_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to request set private data. ret(%s)", __tts_get_error_code(ret));
+ return ret;
}
SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
return TTS_ERROR_INVALID_STATE;
}
- // TODO: move into tts_core
- int uid = tts_client_get_uid(client);
- int ret = -1;
- int count = 0;
- bool is_prepared = false;
- while (0 != ret) {
- ret = tts_ipc_request_get_private_data(uid, key, data);
- if (0 != ret) {
- //LCOV_EXCL_START
- if (TTS_ERROR_INVALID_PARAMETER == ret && false == is_prepared) {
- tts_client_set_current_state(client, TTS_STATE_CREATED);
- if (0 == tts_core_prepare_sync(client)) {
- 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 {
- SLOG(LOG_WARN, TAG_TTSC, "[WARNING] retry : %s", __tts_get_error_code(ret));
- usleep(10000);
- count++;
- if (TTS_RETRY_COUNT == count) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to request");
- return ret;
- }
- }
- //LCOV_EXCL_STOP
- }
- }
-
- if (0 == strncmp(*data, "NULL", strlen(*data))) {
- free(*data);
- *data = NULL;
+ int ret = tts_core_get_private_data(client, key, data);
+ if (TTS_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to request get private data. ret(%s)", __tts_get_error_code(ret));
+ return ret;
}
SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
return 0;
}
-//LCOV_EXCL_START
-//LCOV_EXCL_STOP
-
int tts_set_state_changed_cb(tts_h tts, tts_state_changed_cb callback, void* user_data)
{
if (0 != __tts_get_feature_enabled()) {
SLOG(LOG_INFO, TAG_TTSC, "[INFO] Success tts_dbus_request_stop_pcm");
return tts_core_set_current_state(client, TTS_STATE_READY);
}
+
+int tts_core_set_private_data(tts_client_s* client, const char* key, const char* data)
+{
+ if (false == tts_client_is_valid_client(client)) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Client is not valid.");
+ return TTS_ERROR_INVALID_PARAMETER;
+ }
+
+ int uid = tts_client_get_uid(client);
+ int ret = -1;
+ int count = 0;
+ bool is_prepared = false;
+ while (0 != ret) {
+ ret = tts_ipc_request_set_private_data(uid, key, data);
+ if (0 != ret) {
+ //LCOV_EXCL_START
+ if (TTS_ERROR_INVALID_PARAMETER == ret && false == is_prepared) {
+ tts_client_set_current_state(client, TTS_STATE_CREATED);
+ if (0 == tts_core_prepare_sync(client)) {
+ 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 {
+ SLOG(LOG_WARN, TAG_TTSC, "[WARNING] retry : %s", __tts_get_error_code(ret));
+ usleep(10000);
+ count++;
+ if (TTS_RETRY_COUNT == count) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to request");
+ return ret;
+ }
+ }
+ //LCOV_EXCL_STOP
+ }
+ }
+
+ if (TTS_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to request");
+ return ret;
+ }
+
+ SLOG(LOG_INFO, TAG_TTSC, "[INFO] Success tts_dbus_request_set_private_data");
+ return TTS_ERROR_NONE;
+}
+
+int tts_core_get_private_data(tts_client_s* client, const char* key, char** data)
+{
+ if (false == tts_client_is_valid_client(client)) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Client is not valid.");
+ return TTS_ERROR_INVALID_PARAMETER;
+ }
+
+ int uid = tts_client_get_uid(client);
+ int ret = -1;
+ int count = 0;
+ bool is_prepared = false;
+ while (0 != ret) {
+ ret = tts_ipc_request_get_private_data(uid, key, data);
+ if (0 != ret) {
+ //LCOV_EXCL_START
+ if (TTS_ERROR_INVALID_PARAMETER == ret && false == is_prepared) {
+ tts_client_set_current_state(client, TTS_STATE_CREATED);
+ if (0 == tts_core_prepare_sync(client)) {
+ 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 {
+ SLOG(LOG_WARN, TAG_TTSC, "[WARNING] retry : %s", __tts_get_error_code(ret));
+ usleep(10000);
+ count++;
+ if (TTS_RETRY_COUNT == count) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to request");
+ return ret;
+ }
+ }
+ //LCOV_EXCL_STOP
+ }
+ }
+
+ if (TTS_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to request");
+ return ret;
+ }
+
+ if (0 == strncmp(*data, "NULL", strlen(*data))) {
+ free(*data);
+ *data = NULL;
+ }
+
+ SLOG(LOG_INFO, TAG_TTSC, "[INFO] Success tts_dbus_request_get_private_data");
+ return TTS_ERROR_NONE;
+}