static char* g_engine_name = NULL;
static int g_engine_update_status = 0;
+static Ecore_Thread* g_reprepare_thread = NULL;
+
static char* g_pkgmgr_status = NULL;
static pkgmgr_client* g_pkgmgr = NULL;
static Ecore_Thread* g_pkgmgr_thread = NULL;
{
SLOG(LOG_INFO, TAG_TTSC, "[DEBUG] start reprepare thread. engine update status(%d)", g_engine_update_status);
- tts_client_s* client = (tts_client_s*)data;
- /* check handle */
- if (NULL == client || false == tts_client_is_valid(client->tts)) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Handle is not valid.");
- return;
- }
-
int cnt = 0;
while (!g_engine_update_status && cnt < 20) {
SLOG(LOG_WARN, TAG_TTSC, "[WARNING] wait for starting update");
- /* Checking handle which can be destroyed on other thread */
- if (false == tts_client_is_valid(client->tts)) {
- SLOG(LOG_INFO, TAG_TTSC, "[INFO] client is already destroyed");
- return;
- }
usleep(50000);
cnt++;
/* Checking thread is canceled or not */
- if (ecore_thread_check(client->thread)) {
+ if (ecore_thread_check(thread)) {
SLOG(LOG_WARN, TAG_TTSC, "[WARNING] client thread is canceled. Exit");
return;
}
SLOG(LOG_INFO, TAG_TTSC, "[DEBUG] update status(%d)", g_engine_update_status);
while (g_engine_update_status && (NULL != g_pkgmgr)) {
- /* Checking handle which can be destroyed on other thread */
- if (false == tts_client_is_valid(client->tts)) {
- SLOG(LOG_INFO, TAG_TTSC, "[INFO] client is already destroyed");
- return;
- }
-
usleep(200000);
/* Checking thread is canceled or not */
- if (ecore_thread_check(client->thread)) {
+ if (ecore_thread_check(thread)) {
SLOG(LOG_WARN, TAG_TTSC, "[WARNING] client thread is canceled. Exit");
return;
}
SLOG(LOG_INFO, TAG_TTSC, "[INFO] finish updating. request to prepare");
- if (0 != tts_core_prepare(client)) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to prepare");
- }
-
return;
}
{
SLOG(LOG_INFO, TAG_TTSC, "[INFO] end reprepare thread");
- tts_client_s* client = (tts_client_s*)data;
- /* check handle */
- if (NULL == client || false == tts_client_is_valid(client->tts)) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Handle is not valid.");
+ GList* clients = tts_client_get_client_list();
+ if (NULL == clients) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to get client list");
return;
}
- client->thread = NULL;
+ GList *iter = NULL;
+ if (g_list_length(clients) > 0) {
+ iter = g_list_first(clients);
+
+ while (NULL != iter) {
+ tts_client_s* client = iter->data;
+ if (NULL != client && tts_client_is_valid(client->tts)) {
+ tts_core_prepare(client);
+ }
+
+ iter = g_list_next(iter);
+ }
+ }
+
+ g_list_free(clients);
+ g_reprepare_thread = NULL;
}
static void __cancel_reprepare_thread(void* data, Ecore_Thread* thread)
{
SLOG(LOG_INFO, TAG_TTSC, "[INFO] cancel reprepare thread");
-
- tts_client_s* client = (tts_client_s*)data;
- /* check handle */
- if (NULL == client || false == tts_client_is_valid(client->tts)) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Handle is not valid.");
- return;
- }
-
- client->thread = NULL;
+ g_reprepare_thread = NULL;
}
-static inline void __run_client_reprepare_thread(tts_client_s* client)
+static inline void __run_client_reprepare_thread()
{
- if (NULL == client->thread) {
+ if (NULL == g_reprepare_thread) {
SLOG(LOG_INFO, TAG_TTSC, "[INFO] ecore thread run: start_reprepare_thread");
- client->thread = ecore_thread_run(__start_reprepare_thread, __end_reprepare_thread, __cancel_reprepare_thread, client);
+ g_reprepare_thread = ecore_thread_run(__start_reprepare_thread, __end_reprepare_thread, __cancel_reprepare_thread, NULL);
} else {
SLOG(LOG_INFO, TAG_TTSC, "[INFO] Reprepare thread is already running");
}
if (g_engine_update_status) {
/* suyeon wait engine update */
SLOG(LOG_INFO, TAG_TTSC, "[INFO] cannot prepare due to engine update");
- __run_client_reprepare_thread(client);
+ __run_client_reprepare_thread();
return TTS_ERROR_INVALID_STATE;
}
}
/* check whether engine is updating or not */
if (g_engine_update_status) {
SLOG(LOG_ERROR, TAG_TTSC, "[DEBUG] cannot prepare due to engine update");
- __run_client_reprepare_thread(client);
+ __run_client_reprepare_thread();
return EINA_FALSE;
}
}
int tts_core_deinitialize()
{
+ if (NULL != g_reprepare_thread && EINA_FALSE == ecore_thread_check(g_reprepare_thread)) {
+ SLOG(LOG_INFO, TAG_TTSC, "[INFO] Cancel reprepare thread");
+ ecore_thread_cancel(g_reprepare_thread);
+ }
+
if (NULL != g_pkgmgr_thread) {
SLOG(LOG_INFO, TAG_TTSC, "[INFO] Cancel pkgmgr thread");
g_is_thread_canceled = true;
return TTS_ERROR_NONE;
}
-int tts_core_reprepare(tts_client_s* client)
+int tts_core_reprepare()
{
/* check handle */
- if (NULL == client || false == tts_client_is_valid(client->tts)) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Handle is not valid.");
- return TTS_ERROR_INVALID_PARAMETER;
+ GList* clients = tts_client_get_client_list();
+ if (NULL == clients) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to get client list");
+ return TTS_ERROR_OPERATION_FAILED;
}
- client->current_state = TTS_STATE_CREATED;
- client->reason = 0;
- __run_client_reprepare_thread(client);
+ GList *iter = NULL;
+ if (g_list_length(clients) > 0) {
+ iter = g_list_first(clients);
+
+ while (NULL != iter) {
+ tts_client_s* client = iter->data;
+ if (NULL != client && tts_client_is_valid(client->tts)) {
+ client->current_state = TTS_STATE_CREATED;
+ client->reason = TTS_ERROR_NONE;
+ }
+
+ iter = g_list_next(iter);
+ }
+ }
+
+ g_list_free(clients);
+ __run_client_reprepare_thread();
return TTS_ERROR_NONE;
}