return NULL;
}
-bool tts_client_is_valid(tts_h tts)
+bool tts_client_is_valid(int uid)
{
- tts_client_s* client = tts_client_get(tts);
- if (NULL == client) {
+ if (NULL == tts_client_get_by_uid(uid)) {
SLOG(LOG_WARN, TAG_TTSC, "[WARNING] A handle is not valid");
return false;
}
+
return true;
}
void tts_client_set_state_changed_cb(tts_client_s* client, tts_state_changed_cb callback, void* user_data)
{
- if (NULL == client || false == tts_client_is_valid(client->tts)) {
+ if (NULL == client || false == tts_client_is_valid(client->uid)) {
return;
}
void tts_client_set_utterance_started_cb(tts_client_s* client, tts_utterance_started_cb callback, void* user_data)
{
- if (NULL == client || false == tts_client_is_valid(client->tts)) {
+ if (NULL == client || false == tts_client_is_valid(client->uid)) {
return;
}
__set_utterance_started_cb(client, callback, user_data);
void tts_client_set_utterance_completed_cb(tts_client_s* client, tts_utterance_completed_cb callback, void* user_data)
{
- if (NULL == client || false == tts_client_is_valid(client->tts)) {
+ if (NULL == client || false == tts_client_is_valid(client->uid)) {
return;
}
__set_utterance_completed_cb(client, callback, user_data);
void tts_client_set_error_cb(tts_client_s* client, tts_error_cb callback, void* user_data)
{
- if (NULL == client || false == tts_client_is_valid(client->tts)) {
+ if (NULL == client || false == tts_client_is_valid(client->uid)) {
return;
}
void tts_client_set_default_voice_changed_cb(tts_client_s* client, tts_default_voice_changed_cb callback, void* user_data)
{
- if (NULL == client || false == tts_client_is_valid(client->tts)) {
+ if (NULL == client || false == tts_client_is_valid(client->uid)) {
return;
}
__set_default_voice_changed_cb(client, callback, user_data);
void tts_client_set_engine_changed_cb(tts_client_s* client, tts_engine_changed_cb callback, void* user_data)
{
- if (NULL == client || false == tts_client_is_valid(client->tts)) {
+ if (NULL == client || false == tts_client_is_valid(client->uid)) {
return;
}
__set_engine_changed_cb(client, callback, user_data);
void tts_client_set_supported_voice_cb(tts_client_s* client, tts_supported_voice_cb callback, void* user_data)
{
- if (NULL == client || false == tts_client_is_valid(client->tts)) {
+ if (NULL == client || false == tts_client_is_valid(client->uid)) {
return;
}
__set_supported_voice_cb(client, callback, user_data);
void tts_client_unset_all_cb(tts_client_s* client)
{
- if (NULL == client || false == tts_client_is_valid(client->tts)) {
+ if (NULL == client || false == tts_client_is_valid(client->uid)) {
return;
}
static Eina_Bool __notify_error_timer_cb(void *data)
{
- tts_client_s* client = (tts_client_s*)data;
+ int uid = (int)data;
+ tts_client_s* client = tts_client_get_by_uid(uid);
/* check handle */
- if (NULL == client || false == tts_client_is_valid(client->tts)) {
+ if (NULL == client) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Handle is not valid.");
} else {
__client_error_cb(client, client->utt_id, client->reason);
static Eina_Bool __notify_state_timer_cb(void *data)
{
- tts_client_s* client = (tts_client_s*)data;
+ int uid = (int)data;
+ tts_client_s* client = tts_client_get_by_uid(uid);
/* check handle */
- if (NULL == client || false == tts_client_is_valid(client->tts)) {
+ if (NULL == client) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Handle is not valid.");
} else {
__client_state_changed_cb(client, client->before_state, client->current_state);
while (NULL != iter) {
tts_client_s* client = iter->data;
- if (NULL != client && tts_client_is_valid(client->tts)) {
+ if (NULL != client) {
tts_core_prepare(client);
}
static Eina_Bool __prepare_cb(void *data)
{
- tts_client_s* client = (tts_client_s*)data;
+ int uid = (int)data;
+ tts_client_s* client = tts_client_get_by_uid(uid);
/* check handle */
- if (NULL == client || false == tts_client_is_valid(client->tts)) {
+ if (NULL == client) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Handle is not valid.");
- client->hello_timer = NULL;
return EINA_FALSE;
}
static Eina_Bool __prepare_first_cb(void *data)
{
/* send first hello message */
- tts_client_s* client = (tts_client_s*)data;
+ int uid = (int)data;
+ tts_client_s* client = tts_client_get_by_uid(uid);
/* check handle */
- if (NULL == client || false == tts_client_is_valid(client->tts)) {
+ if (NULL == client) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Handle is not valid.");
- client->hello_timer = NULL;
return EINA_FALSE;
}
static Eina_Bool __prepare_sync_cb(tts_client_s* client)
{
- if (NULL == client || false == tts_client_is_valid(client->tts)) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Handle is not valid.");
- client->hello_timer = NULL;
- return EINA_FALSE;
- }
-
// TODO: make function duplicated block
bool is_launched = __is_engine_launched(client->mode);
SLOG(LOG_INFO, TAG_TTSC, "[INFO] tts engine is launched(%d)", is_launched);
}
// TODO: make function duplicated block
- /* check handle */
- if (false == tts_client_is_valid(client->tts)) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid");
- return EINA_FALSE;
- }
-
client->before_state = client->current_state;
client->current_state = TTS_STATE_READY;
__client_state_changed_cb(client, client->before_state, client->current_state);
int tts_core_notify_state_changed(tts_client_s* client, tts_state_e before_state, tts_state_e current_state)
{
/* check handle */
- if (NULL == client || false == tts_client_is_valid(client->tts)) {
+ if (NULL == client || false == tts_client_is_valid(client->uid)) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Handle is not valid.");
return TTS_ERROR_INVALID_PARAMETER;
}
int tts_core_notify_state_changed_async(tts_client_s* client, tts_state_e before_state, tts_state_e current_state)
{
/* check handle */
- if (NULL == client || false == tts_client_is_valid(client->tts)) {
+ if (NULL == client || false == tts_client_is_valid(client->uid)) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Handle is not valid.");
return TTS_ERROR_INVALID_PARAMETER;
}
if (NULL != client->notify_state_timer) {
ecore_timer_del(client->notify_state_timer);
}
- client->notify_state_timer = ecore_timer_add(0, __notify_state_timer_cb, (void*)client);
+ client->notify_state_timer = ecore_timer_add(0, __notify_state_timer_cb, (void*)client->uid);
} else {
SLOG(LOG_WARN, TAG_TTSC, "No registered callback(state changed)");
}
int tts_core_notify_utt_started(tts_client_s* client, int utt_id)
{
/* check handle */
- if (NULL == client || false == tts_client_is_valid(client->tts)) {
+ if (NULL == client || false == tts_client_is_valid(client->uid)) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Handle is not valid.");
return TTS_ERROR_INVALID_PARAMETER;
}
int tts_core_notify_utt_completeted(tts_client_s* client, int utt_id)
{
/* check handle */
- if (NULL == client || false == tts_client_is_valid(client->tts)) {
+ if (NULL == client || false == tts_client_is_valid(client->uid)) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Handle is not valid.");
return TTS_ERROR_INVALID_PARAMETER;
}
int tts_core_notify_error(tts_client_s* client, int utt_id, tts_error_e reason)
{
/* check handle */
- if (NULL == client || false == tts_client_is_valid(client->tts)) {
+ if (NULL == client || false == tts_client_is_valid(client->uid)) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Handle is not valid.");
return TTS_ERROR_INVALID_PARAMETER;
}
int tts_core_notify_error_async(tts_client_s* client, int utt_id, tts_error_e reason)
{
/* check handle */
- if (NULL == client || false == tts_client_is_valid(client->tts)) {
+ if (NULL == client || false == tts_client_is_valid(client->uid)) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Handle is not valid.");
return TTS_ERROR_INVALID_PARAMETER;
}
if (NULL != client->notify_error_timer) {
ecore_timer_del(client->notify_error_timer);
}
- client->notify_error_timer = ecore_timer_add(0, __notify_error_timer_cb, (void*)client);
+ client->notify_error_timer = ecore_timer_add(0, __notify_error_timer_cb, (void*)client->uid);
} else {
SLOG(LOG_WARN, TAG_TTSC, "No registered callback(error)");
}
int tts_core_notify_default_voice_changed(tts_client_s* client, const char* before_lang, int before_voice_type, const char* language, int voice_type)
{
/* check handle */
- if (NULL == client || false == tts_client_is_valid(client->tts)) {
+ if (NULL == client || false == tts_client_is_valid(client->uid)) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Handle is not valid.");
return TTS_ERROR_INVALID_PARAMETER;
}
int tts_core_notify_engine_changed(tts_client_s* client, const char* engine_id, const char* language, int voice_type, bool need_credential)
{
/* check handle */
- if (NULL == client || false == tts_client_is_valid(client->tts)) {
+ if (NULL == client || false == tts_client_is_valid(client->uid)) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Handle is not valid.");
return TTS_ERROR_INVALID_PARAMETER;
}
int tts_core_notify_supported_voice(tts_client_s* client, const char* language, int voice_type)
{
/* check handle */
- if (NULL == client || false == tts_client_is_valid(client->tts)) {
+ if (NULL == client || false == tts_client_is_valid(client->uid)) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Handle is not valid.");
return TTS_ERROR_INVALID_PARAMETER;
}
int tts_core_prepare(tts_client_s* client)
{
/* check handle */
- if (NULL == client || false == tts_client_is_valid(client->tts)) {
+ if (NULL == client || false == tts_client_is_valid(client->uid)) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Handle is not valid.");
return TTS_ERROR_INVALID_PARAMETER;
}
SLOG(LOG_ERROR, TAG_TTSC, "Register timer for __prepare_first_cb");
ecore_thread_main_loop_begin();
- client->hello_timer = ecore_timer_add(0.0, __prepare_first_cb, (void*)client);
+ client->hello_timer = ecore_timer_add(0.0, __prepare_first_cb, (void*)client->uid);
ecore_thread_main_loop_end();
} else {
LOGD("Client is already trying to prepare");
int tts_core_prepare_sync(tts_client_s* client)
{
/* check handle */
- if (NULL == client || false == tts_client_is_valid(client->tts)) {
+ if (NULL == client || false == tts_client_is_valid(client->uid)) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Handle is not valid.");
return TTS_ERROR_INVALID_PARAMETER;
}
int tts_core_unprepare(tts_client_s* client, bool is_screen_reader_on)
{
/* check handle */
- if (NULL == client || false == tts_client_is_valid(client->tts)) {
+ if (NULL == client || false == tts_client_is_valid(client->uid)) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Handle is not valid.");
return TTS_ERROR_INVALID_PARAMETER;
}
while (NULL != iter) {
tts_client_s* client = iter->data;
- if (NULL != client && tts_client_is_valid(client->tts)) {
+ if (NULL != client && tts_client_is_valid(client->uid)) {
client->current_state = TTS_STATE_CREATED;
client->reason = TTS_ERROR_NONE;
}