summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDongyeol Lee <dy3.lee@samsung.com>2012-08-21 17:37:12 +0900
committerDongyeol Lee <dy3.lee@samsung.com>2012-08-21 17:37:12 +0900
commitaf44daf564960ed74bc1f6b1be5d6842abdce321 (patch)
treedf4ba2f6a1bffd00458f195ab5d7b37b8d5e3f3b
parent53d1f6701452b22c2b902e7de38b4081b35a8dd3 (diff)
downloadtts-master.tar.gz
tts-master.tar.bz2
tts-master.zip
-rw-r--r--client/tts.c469
-rw-r--r--client/tts.h134
-rw-r--r--client/tts_client.c9
-rw-r--r--client/tts_client.h11
-rw-r--r--client/tts_dbus.c102
-rw-r--r--client/tts_dbus.h2
-rw-r--r--client/tts_main.h2
-rw-r--r--client/tts_setting.c131
-rw-r--r--client/tts_setting.h28
-rw-r--r--client/tts_setting_dbus.c4
-rw-r--r--client/tts_setting_dbus.h2
-rw-r--r--common/tts_defs.h19
-rw-r--r--debian/changelog294
-rw-r--r--debian/copyright12
-rw-r--r--debian/libtts.install.in1
-rw-r--r--[-rwxr-xr-x]debian/rules0
-rw-r--r--packaging/tts.spec3
-rw-r--r--server/CMakeLists.txt4
-rw-r--r--server/ttsd.conf3
-rw-r--r--server/ttsd_config.c261
-rw-r--r--server/ttsd_config.h36
-rw-r--r--server/ttsd_data.cpp117
-rw-r--r--server/ttsd_data.h42
-rw-r--r--server/ttsd_dbus.c139
-rw-r--r--server/ttsd_dbus.h8
-rw-r--r--server/ttsd_dbus_server.c60
-rw-r--r--server/ttsd_dbus_server.h8
-rw-r--r--server/ttsd_engine_agent.c56
-rw-r--r--server/ttsd_main.c4
-rw-r--r--server/ttsd_main.h2
-rw-r--r--server/ttsd_network.c6
-rw-r--r--server/ttsd_player.cpp65
-rw-r--r--server/ttsd_server.cpp388
-rw-r--r--server/ttsd_server.h11
34 files changed, 1577 insertions, 856 deletions
diff --git a/client/tts.c b/client/tts.c
index 9c1d5e7..e4ccab3 100644
--- a/client/tts.c
+++ b/client/tts.c
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+* Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -13,21 +13,23 @@
#include <sys/wait.h>
+#include <Ecore.h>
#include "tts_main.h"
#include "tts_client.h"
#include "tts_dbus.h"
#define MAX_TEXT_COUNT 1000
-#define CONNECTION_RETRY_COUNT 2
+
+static bool g_is_daemon_started = false;
/* Function definition */
-int __tts_check_tts_daemon();
+static int __tts_check_tts_daemon();
+static Eina_Bool __tts_notify_state_changed(void *data);
+static Eina_Bool __tts_notify_error(void *data);
int tts_create(tts_h* tts)
{
- int ret = 0;
-
SLOG(LOG_DEBUG, TAG_TTSC, "===== Create TTS");
/* check param */
@@ -47,11 +49,6 @@ int tts_create(tts_h* tts)
}
}
- /* Send hello */
- if (0 != tts_dbus_request_hello()) {
- __tts_check_tts_daemon();
- }
-
if (0 != tts_client_new(tts)) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to create client!!!!!");
SLOG(LOG_DEBUG, TAG_TTSC, "=====");
@@ -59,34 +56,6 @@ int tts_create(tts_h* tts)
return TTS_ERROR_OUT_OF_MEMORY;
}
- /* do request initialize */
- int i = 1;
- while(1) {
- ret = tts_dbus_request_initialize((*tts)->handle);
-
- if (TTS_ERROR_ENGINE_NOT_FOUND == ret) {
- tts_client_destroy(*tts);
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Engine not found");
- SLOG(LOG_DEBUG, TAG_TTSC, "=====");
- SLOG(LOG_DEBUG, TAG_TTSC, " ");
- return ret;
- } else if (TTS_ERROR_NONE != ret) {
- usleep(1);
- if (i == CONNECTION_RETRY_COUNT) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to connection");
- SLOG(LOG_DEBUG, TAG_TTSC, "=====");
- SLOG(LOG_DEBUG, TAG_TTSC, " ");
- return TTS_ERROR_TIMED_OUT;
- }
- i++;
- } else {
- /* success to connect tts-daemon */
- break;
- }
- }
-
- SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] uid(%d)", (*tts)->handle);
-
SLOG(LOG_DEBUG, TAG_TTSC, "=====");
SLOG(LOG_DEBUG, TAG_TTSC, " ");
@@ -114,18 +83,27 @@ int tts_destroy(tts_h tts)
return TTS_ERROR_INVALID_PARAMETER;
}
- /* Request Finalize */
- int ret = tts_dbus_request_finalize(client->uid);
- if (0 != ret) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to request finalize ");
- }
-
- /* Free resources */
- tts_client_destroy(tts);
-
+ int ret = -1;
+
+ /* check state */
+ switch (client->current_state) {
+ case TTS_STATE_PAUSED:
+ case TTS_STATE_PLAYING:
+ case TTS_STATE_READY:
+ /* Request Finalize */
+ ret = tts_dbus_request_finalize(client->uid);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to request finalize");
+ }
+ case TTS_STATE_CREATED:
+ /* Free resources */
+ tts_client_destroy(tts);
+ break;
+ }
+
if (0 == tts_client_get_size()) {
if (0 != tts_dbus_close_connection()) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to close connection\n ");
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to close connection");
}
}
@@ -135,6 +113,137 @@ int tts_destroy(tts_h tts)
return TTS_ERROR_NONE;
}
+static Eina_Bool __tts_connect_daemon(void *data)
+{
+ SLOG(LOG_DEBUG, TAG_TTSC, "===== Connect daemon");
+
+ tts_h tts = (tts_h)data;
+
+ tts_client_s* client = tts_client_get(tts);
+
+ /* check handle */
+ if (NULL == client) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid");
+ SLOG(LOG_DEBUG, TAG_TTSC, "=====");
+ SLOG(LOG_DEBUG, TAG_TTSC, " ");
+ return EINA_FALSE;
+ }
+
+ /* Send hello */
+ if (0 != tts_dbus_request_hello()) {
+ if (false == g_is_daemon_started) {
+ g_is_daemon_started = true;
+ __tts_check_tts_daemon();
+ }
+ return EINA_TRUE;
+ }
+
+ /* do request initialize */
+ int ret = -1;
+
+ ret = tts_dbus_request_initialize(client->uid);
+
+ if (TTS_ERROR_ENGINE_NOT_FOUND == ret) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Engine not found");
+
+ client->reason = TTS_ERROR_ENGINE_NOT_FOUND;
+ client->utt_id = -1;
+
+ ecore_timer_add(0, __tts_notify_error, (void*)client->tts);
+ return EINA_FALSE;
+
+ } else if (TTS_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to connection");
+
+ client->reason = TTS_ERROR_TIMED_OUT;
+ client->utt_id = -1;
+
+ ecore_timer_add(0, __tts_notify_error, (void*)client->tts);
+ return EINA_FALSE;
+ } else {
+ /* success to connect tts-daemon */
+ }
+
+ client->before_state = client->current_state;
+ client->current_state = TTS_STATE_READY;
+
+ ecore_timer_add(0, __tts_notify_state_changed, (void*)client->tts);
+
+ SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] uid(%d)", client->uid);
+
+ SLOG(LOG_DEBUG, TAG_TTSC, "=====");
+ SLOG(LOG_DEBUG, TAG_TTSC, " ");
+
+ return EINA_FALSE;
+}
+
+
+int tts_prepare(tts_h tts)
+{
+ SLOG(LOG_DEBUG, 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, "=====");
+ 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, "=====");
+ SLOG(LOG_DEBUG, TAG_TTSC, " ");
+ return TTS_ERROR_INVALID_STATE;
+ }
+
+ ecore_timer_add(0, __tts_connect_daemon, (void*)tts);
+
+ SLOG(LOG_DEBUG, TAG_TTSC, "=====");
+ SLOG(LOG_DEBUG, TAG_TTSC, " ");
+
+ return TTS_ERROR_NONE;
+}
+
+int tts_unprepare(tts_h tts)
+{
+ SLOG(LOG_DEBUG, TAG_TTSC, "===== Unprepare 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");
+ return TTS_ERROR_INVALID_PARAMETER;
+ }
+
+ /* check state */
+ if (client->current_state != TTS_STATE_READY) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Invalid State: Current state is not 'READY'");
+ SLOG(LOG_DEBUG, TAG_TTSC, "=====");
+ SLOG(LOG_DEBUG, TAG_TTSC, " ");
+ return TTS_ERROR_INVALID_STATE;
+ }
+
+ int ret = tts_dbus_request_finalize(client->uid);
+ if (0 != ret) {
+ SLOG(LOG_WARN, TAG_TTSC, "[ERROR] Fail to request finalize");
+ }
+
+ client->before_state = client->current_state;
+ client->current_state = TTS_STATE_CREATED;
+
+ ecore_timer_add(0, __tts_notify_state_changed, (void*)tts);
+
+ SLOG(LOG_DEBUG, TAG_TTSC, "=====");
+ SLOG(LOG_DEBUG, TAG_TTSC, " ");
+
+ return TTS_ERROR_NONE;
+}
+
int tts_foreach_supported_voices(tts_h tts, tts_supported_voice_cb callback, void* user_data)
{
SLOG(LOG_DEBUG, TAG_TTSC, "===== Foreach supported voices");
@@ -258,6 +367,7 @@ int tts_get_state(tts_h tts, tts_state_e* state)
*state = client->current_state;
switch(*state) {
+ case TTS_STATE_CREATED: SLOG(LOG_DEBUG, TAG_TTSC, "Current state is 'Created'"); break;
case TTS_STATE_READY: SLOG(LOG_DEBUG, TAG_TTSC, "Current state is 'Ready'"); break;
case TTS_STATE_PLAYING: SLOG(LOG_DEBUG, TAG_TTSC, "Current state is 'Playing'"); break;
case TTS_STATE_PAUSED: SLOG(LOG_DEBUG, TAG_TTSC, "Current state is 'Paused'"); break;
@@ -286,6 +396,11 @@ int tts_add_text(tts_h tts, const char* text, const char* language, tts_voice_ty
return TTS_ERROR_INVALID_PARAMETER;
}
+ if (TTS_STATE_CREATED == client->current_state) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Current state is 'CREATED'.");
+ return TTS_ERROR_INVALID_STATE;
+ }
+
/* change default language value */
char* temp = NULL;
@@ -322,7 +437,7 @@ int tts_play(tts_h tts)
SLOG(LOG_DEBUG, TAG_TTSC, "===== Play tts");
if (NULL == tts) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input handle is null");
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input handle is null.");
SLOG(LOG_DEBUG, TAG_TTSC, "=====");
SLOG(LOG_DEBUG, TAG_TTSC, " ");
return TTS_ERROR_INVALID_PARAMETER;
@@ -331,29 +446,35 @@ int tts_play(tts_h tts)
tts_client_s* client = tts_client_get(tts);
if (NULL == client) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid");
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid.");
SLOG(LOG_DEBUG, TAG_TTSC, "=====");
SLOG(LOG_DEBUG, TAG_TTSC, " ");
return TTS_ERROR_INVALID_PARAMETER;
}
- if (TTS_STATE_PLAYING == client->current_state) {
- SLOG(LOG_ERROR, TAG_TTSC, "Current state is 'playing'. This request should be skipped.\n");
+ if (TTS_STATE_PLAYING == client->current_state || TTS_STATE_CREATED == client->current_state) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] The current state is invalid.");
return TTS_ERROR_INVALID_STATE;
}
int ret = 0;
ret = tts_dbus_request_play(client->uid);
if (0 != ret) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] result : %d", ret);
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Request play : result(%d)", ret);
SLOG(LOG_DEBUG, TAG_TTSC, "=====");
SLOG(LOG_DEBUG, TAG_TTSC, " ");
return ret;
}
- /* change state */
+ client->before_state = client->current_state;
client->current_state = TTS_STATE_PLAYING;
+ if (NULL != client->state_changed_cb) {
+ ecore_timer_add(0, __tts_notify_state_changed, (void*)tts);
+ } else {
+ SLOG(LOG_WARN, TAG_TTSC, "[WARNING] State changed callback is null");
+ }
+
SLOG(LOG_DEBUG, TAG_TTSC, "=====");
SLOG(LOG_DEBUG, TAG_TTSC, " ");
@@ -381,8 +502,10 @@ int tts_stop(tts_h tts)
return TTS_ERROR_INVALID_PARAMETER;
}
- SLOG(LOG_DEBUG, TAG_TTSC, "change state to ready\n");
- client->current_state = TTS_STATE_READY;
+ if (TTS_STATE_CREATED == client->current_state) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Current state is 'CREATED'.");
+ return TTS_ERROR_INVALID_STATE;
+ }
int ret = 0;
ret = tts_dbus_request_stop(client->uid);
@@ -393,6 +516,15 @@ int tts_stop(tts_h tts)
return ret;
}
+ client->before_state = client->current_state;
+ client->current_state = TTS_STATE_READY;
+
+ if (NULL != client->state_changed_cb) {
+ ecore_timer_add(0, __tts_notify_state_changed, (void*)tts);
+ } else {
+ SLOG(LOG_WARN, TAG_TTSC, "[WARNING] State changed callback is null");
+ }
+
SLOG(LOG_DEBUG, TAG_TTSC, "=====");
SLOG(LOG_DEBUG, TAG_TTSC, " ");
@@ -421,7 +553,7 @@ int tts_pause(tts_h tts)
}
if (TTS_STATE_PLAYING != client->current_state) {
- SLOG(LOG_ERROR, TAG_TTSC, "Error : Current state is NOT 'playing'. So this request should be not running.\n");
+ SLOG(LOG_ERROR, TAG_TTSC, "[Error] The Current state is NOT 'playing'. So this request should be not running.");
SLOG(LOG_DEBUG, TAG_TTSC, "=====");
SLOG(LOG_DEBUG, TAG_TTSC, " ");
return TTS_ERROR_INVALID_STATE;
@@ -430,20 +562,51 @@ int tts_pause(tts_h tts)
int ret = 0;
ret = tts_dbus_request_pause(client->uid);
if (0 != ret) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] result : %d", ret);
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Request pause : result(%d)", ret);
SLOG(LOG_DEBUG, TAG_TTSC, "=====");
SLOG(LOG_DEBUG, TAG_TTSC, " ");
return ret;
}
+ client->before_state = client->current_state;
client->current_state = TTS_STATE_PAUSED;
+ if (NULL != client->state_changed_cb) {
+ ecore_timer_add(0, __tts_notify_state_changed, (void*)tts);
+ } else {
+ SLOG(LOG_WARN, TAG_TTSC, "[WARNING] State changed callback is null");
+ }
+
SLOG(LOG_DEBUG, TAG_TTSC, "=====");
SLOG(LOG_DEBUG, TAG_TTSC, " ");
return TTS_ERROR_NONE;
}
+static Eina_Bool __tts_notify_error(void *data)
+{
+ tts_h tts = (tts_h)data;
+
+ tts_client_s* client = tts_client_get(tts);
+
+ /* check handle */
+ if (NULL == client) {
+ SLOG(LOG_WARN, TAG_TTSC, "Fail to notify error : A handle is not valid");
+ return EINA_FALSE;
+ }
+
+ if (NULL != client->error_cb) {
+ SLOG(LOG_DEBUG, TAG_TTSC, "Call callback function of error");
+ tts_client_use_callback(client);
+ client->error_cb(client->tts, client->utt_id, client->reason, client->error_user_data );
+ tts_client_not_use_callback(client);
+ } else {
+ SLOG(LOG_WARN, TAG_TTSC, "No registered callback function of error \n");
+ }
+
+ return EINA_FALSE;
+}
+
int __tts_cb_error(int uid, tts_error_e reason, int utt_id)
{
tts_client_s* client = tts_client_get_by_uid(uid);
@@ -453,12 +616,12 @@ int __tts_cb_error(int uid, tts_error_e reason, int utt_id)
return TTS_ERROR_INVALID_PARAMETER;
}
+ client->utt_id = utt_id;
+ client->reason = reason;
+
/* call callback function */
if (NULL != client->error_cb) {
- SLOG(LOG_DEBUG, TAG_TTSC, "Call callback function of error");
- tts_client_use_callback(client);
- client->error_cb(client->tts, utt_id, reason, client->error_user_data );
- tts_client_not_use_callback(client);
+ ecore_timer_add(0, __tts_notify_error, client->tts);
} else {
SLOG(LOG_WARN, TAG_TTSC, "No registered callback function of error \n");
}
@@ -466,38 +629,79 @@ int __tts_cb_error(int uid, tts_error_e reason, int utt_id)
return 0;
}
-int __tts_cb_interrupt(int uid, tts_interrupted_code_e code)
+static Eina_Bool __tts_notify_state_changed(void *data)
{
- tts_client_s* client = tts_client_get_by_uid(uid);
+ tts_h tts = (tts_h)data;
+
+ tts_client_s* client = tts_client_get(tts);
+ /* check handle */
if (NULL == client) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid");
- return TTS_ERROR_INVALID_PARAMETER;
+ SLOG(LOG_WARN, TAG_TTSC, "Fail to notify error : A handle is not valid");
+ return EINA_FALSE;
}
- /* change state by interrupt code */
- if (TTS_INTERRUPTED_PAUSED == code) {
- SLOG(LOG_DEBUG, TAG_TTSC, "change state to ready");
- client->current_state = TTS_STATE_PAUSED;
- } else if (TTS_INTERRUPTED_STOPPED == code) {
- SLOG(LOG_DEBUG, TAG_TTSC, "change state to ready");
- client->current_state = TTS_STATE_READY;
+ if (NULL != client->state_changed_cb) {
+ tts_client_use_callback(client);
+ client->state_changed_cb(client->tts, client->before_state, client->current_state, client->state_changed_user_data);
+ tts_client_not_use_callback(client);
+ SLOG(LOG_DEBUG, TAG_TTSC, "State changed callback is called");
} else {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Interrupt code is not available");
+ SLOG(LOG_WARN, TAG_TTSC, "[WARNING] State changed callback is null");
+ }
+
+ return EINA_FALSE;
+}
+
+int __tts_cb_set_state(int uid, int state)
+{
+ tts_client_s* client = tts_client_get_by_uid(uid);
+ if( NULL == client ) {
+ SLOG(LOG_ERROR, TAG_TTSC, "Handle not found");
return -1;
}
- /* call callback function */
- if (NULL != client->interrupted_cb) {
- SLOG(LOG_DEBUG, TAG_TTSC, "Call callback function of stopped \n");
+ tts_state_e state_from_daemon = (tts_state_e)state;
+
+ if (client->current_state == state_from_daemon) {
+ SLOG(LOG_DEBUG, TAG_TTSC, "Current state has already been %d", client->current_state);
+ return 0;
+ }
+
+ if (NULL != client->state_changed_cb) {
+ ecore_timer_add(0, __tts_notify_state_changed, client->tts);
+ } else {
+ SLOG(LOG_WARN, TAG_TTSC, "[WARNING] State changed callback is null");
+ }
+
+ client->before_state = client->current_state;
+ client->current_state = state_from_daemon;
+
+ return 0;
+}
+
+static Eina_Bool __tts_notify_utt_started(void *data)
+{
+ tts_h tts = (tts_h)data;
+
+ tts_client_s* client = tts_client_get(tts);
+
+ /* check handle */
+ if (NULL == client) {
+ SLOG(LOG_WARN, TAG_TTSC, "[WARNING] Fail to notify utt started : A handle is not valid");
+ return EINA_FALSE;
+ }
+
+ if (NULL != client->utt_started_cb) {
+ SLOG(LOG_DEBUG, TAG_TTSC, "Call callback function of utterance started \n");
tts_client_use_callback(client);
- client->interrupted_cb(client->tts, code, client->interrupted_user_data);
+ client->utt_started_cb(client->tts, client->utt_id, client->utt_started_user_data);
tts_client_not_use_callback(client);
} else {
- SLOG(LOG_WARN, TAG_TTSC, "No registered callback function of stopped \n");
+ SLOG(LOG_WARN, TAG_TTSC, "No registered callback function of utterance started \n");
}
- return 0;
+ return EINA_FALSE;
}
int __tts_cb_utt_started(int uid, int utt_id)
@@ -511,12 +715,11 @@ int __tts_cb_utt_started(int uid, int utt_id)
SLOG(LOG_DEBUG, TAG_TTSC, "utterance started : uttid(%d) \n", utt_id);
+ client->utt_id = utt_id;
+
/* call callback function */
if (NULL != client->utt_started_cb) {
- SLOG(LOG_DEBUG, TAG_TTSC, "Call callback function of utterance started \n");
- tts_client_use_callback(client);
- client->utt_started_cb(client->tts, utt_id, client->utt_started_user_data);
- tts_client_not_use_callback(client);
+ ecore_timer_add(0, __tts_notify_utt_started, client->tts);
} else {
SLOG(LOG_WARN, TAG_TTSC, "No registered callback function of utterance started \n");
}
@@ -524,6 +727,30 @@ int __tts_cb_utt_started(int uid, int utt_id)
return 0;
}
+static Eina_Bool __tts_notify_utt_completed(void *data)
+{
+ tts_h tts = (tts_h)data;
+
+ tts_client_s* client = tts_client_get(tts);
+
+ /* check handle */
+ if (NULL == client) {
+ SLOG(LOG_WARN, TAG_TTSC, "[WARNING] Fail to notify utt completed : A handle is not valid");
+ return EINA_FALSE;
+ }
+
+ if (NULL != client->utt_completeted_cb) {
+ SLOG(LOG_DEBUG, TAG_TTSC, "Call callback function of utterance completed \n");
+ tts_client_use_callback(client);
+ client->utt_completeted_cb(client->tts, client->utt_id, client->utt_completed_user_data);
+ tts_client_not_use_callback(client);
+ } else {
+ SLOG(LOG_WARN, TAG_TTSC, "No registered callback function of utterance completed \n");
+ }
+
+ return EINA_FALSE;
+}
+
int __tts_cb_utt_completed(int uid, int utt_id)
{
tts_client_s* client = tts_client_get_by_uid(uid);
@@ -535,12 +762,11 @@ int __tts_cb_utt_completed(int uid, int utt_id)
SLOG(LOG_DEBUG, TAG_TTSC, "utterance completed : uttid(%d) \n", utt_id);
+ client->utt_id = utt_id;
+
/* call callback function */
if (NULL != client->utt_completeted_cb) {
- SLOG(LOG_DEBUG, TAG_TTSC, "Call callback function of utterance completed \n");
- tts_client_use_callback(client);
- client->utt_completeted_cb(client->tts, utt_id, client->utt_completed_user_data);
- tts_client_not_use_callback(client);
+ ecore_timer_add(0, __tts_notify_utt_completed, client->tts);
} else {
SLOG(LOG_WARN, TAG_TTSC, "No registered callback function of utterance completed \n");
}
@@ -548,56 +774,56 @@ int __tts_cb_utt_completed(int uid, int utt_id)
return 0;
}
-int tts_set_interrupted_cb(tts_h tts, tts_interrupted_cb callback, void* user_data)
+int tts_set_state_changed_cb(tts_h tts, tts_state_changed_cb callback, void* user_data)
{
if (NULL == tts || NULL == callback) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Set interrupted cb : Input parameter is null");
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Set state changed cb : Input parameter is null");
return TTS_ERROR_INVALID_PARAMETER;
}
tts_client_s* client = tts_client_get(tts);
if (NULL == client) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Set interrupted cb : A handle is not valid");
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Set state changed cb : A handle is not valid");
return TTS_ERROR_INVALID_PARAMETER;
}
- if (TTS_STATE_READY != client->current_state) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Set interrupted cb : Current state is not 'ready'.");
+ if (TTS_STATE_CREATED != client->current_state) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Set state changed cb : Current state is not 'Created'.");
return TTS_ERROR_INVALID_STATE;
}
- client->interrupted_cb = callback;
- client->interrupted_user_data = user_data;
+ client->state_changed_cb = callback;
+ client->state_changed_user_data = user_data;
- SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Set interrupted cb");
+ SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Set state changed cb");
return 0;
}
-int tts_unset_interrupted_cb(tts_h tts)
+int tts_unset_state_changed_cb(tts_h tts)
{
if (NULL == tts) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Unset interrupted cb : Input parameter is null");
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Unset state changed cb : Input parameter is null");
return TTS_ERROR_INVALID_PARAMETER;
}
tts_client_s* client = tts_client_get(tts);
if (NULL == client) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Unset interrupted cb : A handle is not valid");
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Unset state changed cb : A handle is not valid");
return TTS_ERROR_INVALID_PARAMETER;
}
- if (TTS_STATE_READY != client->current_state) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Unset interrupted cb : Current state is not 'ready'.");
+ if (TTS_STATE_CREATED != client->current_state) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Unset state changed cb : Current state is not 'Created'.");
return TTS_ERROR_INVALID_STATE;
}
- client->interrupted_cb = NULL;
- client->interrupted_user_data = NULL;
+ client->state_changed_cb = NULL;
+ client->state_changed_user_data = NULL;
- SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Unset interrupted cb");
+ SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Unset state changed cb");
return 0;
}
@@ -616,8 +842,8 @@ int tts_set_utterance_started_cb(tts_h tts, tts_utterance_started_cb callback, v
return TTS_ERROR_INVALID_PARAMETER;
}
- if (TTS_STATE_READY != client->current_state) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Set utt started cb : Current state is not 'ready'.");
+ if (TTS_STATE_CREATED != client->current_state) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Set utt started cb : Current state is not 'Created'.");
return TTS_ERROR_INVALID_STATE;
}
@@ -643,8 +869,8 @@ int tts_unset_utterance_started_cb(tts_h tts)
return TTS_ERROR_INVALID_PARAMETER;
}
- if (TTS_STATE_READY != client->current_state) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Unset utt started cb : Current state is not 'ready'.");
+ if (TTS_STATE_CREATED != client->current_state) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Unset utt started cb : Current state is not 'Created'.");
return TTS_ERROR_INVALID_STATE;
}
@@ -670,8 +896,8 @@ int tts_set_utterance_completed_cb(tts_h tts, tts_utterance_completed_cb callbac
return TTS_ERROR_INVALID_PARAMETER;
}
- if (TTS_STATE_READY != client->current_state) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Set utt completed cb : Current state is not 'ready'.");
+ if (TTS_STATE_CREATED != client->current_state) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Set utt completed cb : Current state is not 'Created'.");
return TTS_ERROR_INVALID_STATE;
}
@@ -697,8 +923,8 @@ int tts_unset_utterance_completed_cb(tts_h tts)
return TTS_ERROR_INVALID_PARAMETER;
}
- if (TTS_STATE_READY != client->current_state) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Unset utt completed cb : Current state is not 'ready'.");
+ if (TTS_STATE_CREATED != client->current_state) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Unset utt completed cb : Current state is not 'Created'.");
return TTS_ERROR_INVALID_STATE;
}
@@ -723,8 +949,8 @@ int tts_set_error_cb(tts_h tts, tts_error_cb callback, void* user_data)
return TTS_ERROR_INVALID_PARAMETER;
}
- if (TTS_STATE_READY != client->current_state) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Set error cb : Current state is not 'ready'.");
+ if (TTS_STATE_CREATED != client->current_state) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Set error cb : Current state is not 'Created'.");
return TTS_ERROR_INVALID_STATE;
}
@@ -750,8 +976,8 @@ int tts_unset_error_cb(tts_h tts)
return TTS_ERROR_INVALID_PARAMETER;
}
- if (TTS_STATE_READY != client->current_state) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Unset error cb : Current state is not 'ready'.");
+ if (TTS_STATE_CREATED != client->current_state) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Unset error cb : Current state is not 'Created'.");
return TTS_ERROR_INVALID_STATE;
}
@@ -773,7 +999,7 @@ static bool _tts_is_alive()
memset(cmd, '\0', sizeof(char) * 256);
if ((fp = popen("ps -eo \"cmd\"", "r")) == NULL) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] popen error \n");
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] popen error");
return FALSE;
}
@@ -783,7 +1009,7 @@ static bool _tts_is_alive()
if (0 == strncmp(cmd, "[tts-daemon]", strlen("[tts-daemon]")) ||
0 == strncmp(cmd, "tts-daemon", strlen("tts-daemon")) ||
0 == strncmp(cmd, "/usr/bin/tts-daemon", strlen("/usr/bin/tts-daemon"))) {
- SLOG(LOG_DEBUG, TAG_TTSC, "tts-daemon is ALIVE !! \n");
+ SLOG(LOG_DEBUG, TAG_TTSC, "tts-daemon is ALIVE !!");
fclose(fp);
return TRUE;
}
@@ -791,7 +1017,7 @@ static bool _tts_is_alive()
fclose(fp);
- SLOG(LOG_DEBUG, TAG_TTSC, "THERE IS NO tts-daemon !! \n");
+ SLOG(LOG_DEBUG, TAG_TTSC, "THERE IS NO tts-daemon !!");
return FALSE;
}
@@ -813,7 +1039,7 @@ static void __my_sig_child(int signo, siginfo_t *info, void *data)
return;
}
-int __tts_check_tts_daemon()
+static int __tts_check_tts_daemon()
{
if (TRUE == _tts_is_alive())
return 0;
@@ -836,7 +1062,7 @@ int __tts_check_tts_daemon()
switch(pid) {
case -1:
- SLOG(LOG_ERROR, TAG_TTSC, "fail to create TTS-DAEMON \n");
+ SLOG(LOG_ERROR, TAG_TTSC, "Fail to create tts-daemon");
break;
case 0:
@@ -848,7 +1074,6 @@ int __tts_check_tts_daemon()
break;
default:
- sleep(1);
break;
}
diff --git a/client/tts.h b/client/tts.h
index 084f956..4a51bdb 100644
--- a/client/tts.h
+++ b/client/tts.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
@@ -50,42 +50,35 @@ typedef enum {
* @brief Enumerations of speaking speed.
*/
typedef enum {
- TTS_SPEED_AUTO, /**< Speed from settings */
- TTS_SPEED_VERY_SLOW, /**< Very slow */
- TTS_SPEED_SLOW, /**< Slow */
- TTS_SPEED_NORMAL, /**< Normal */
- TTS_SPEED_FAST, /**< Fast */
- TTS_SPEED_VERY_FAST /**< Very fast */
+ TTS_SPEED_AUTO, /**< Speed from settings */
+ TTS_SPEED_VERY_SLOW, /**< Very slow */
+ TTS_SPEED_SLOW, /**< Slow */
+ TTS_SPEED_NORMAL, /**< Normal */
+ TTS_SPEED_FAST, /**< Fast */
+ TTS_SPEED_VERY_FAST /**< Very fast */
} tts_speed_e;
/**
* @brief Enumerations of voice type.
*/
typedef enum {
- TTS_VOICE_TYPE_AUTO, /**< Voice type from settings or auto selection based language */
- TTS_VOICE_TYPE_MALE, /**< Male */
- TTS_VOICE_TYPE_FEMALE, /**< Female */
- TTS_VOICE_TYPE_CHILD, /**< Child */
- TTS_VOICE_TYPE_USER1, /**< Engine defined */
- TTS_VOICE_TYPE_USER2, /**< Engine defined */
- TTS_VOICE_TYPE_USER3 /**< Engine defined */
+ TTS_VOICE_TYPE_AUTO, /**< Voice type from settings or auto selection based language */
+ TTS_VOICE_TYPE_MALE, /**< Male */
+ TTS_VOICE_TYPE_FEMALE, /**< Female */
+ TTS_VOICE_TYPE_CHILD, /**< Child */
+ TTS_VOICE_TYPE_USER1, /**< Engine defined */
+ TTS_VOICE_TYPE_USER2, /**< Engine defined */
+ TTS_VOICE_TYPE_USER3 /**< Engine defined */
} tts_voice_type_e;
/**
-* @brief Enumerations of interrupted code.
-*/
-typedef enum {
- TTS_INTERRUPTED_PAUSED = 0, /**< The current state be changed #TTS_STATE_PAUSED by the daemon */
- TTS_INTERRUPTED_STOPPED /**< The current state be changed #TTS_STATE_READY by the daemon */
-} tts_interrupted_code_e;
-
-/**
* @brief Enumerations of state.
*/
typedef enum {
- TTS_STATE_READY = 0, /**< 'READY' state */
- TTS_STATE_PLAYING, /**< 'PLAYING' state */
- TTS_STATE_PAUSED /**< 'PAUSED' state*/
+ TTS_STATE_CREATED = 0, /**< 'CREATED' state */
+ TTS_STATE_READY, /**< 'READY' state */
+ TTS_STATE_PLAYING, /**< 'PLAYING' state */
+ TTS_STATE_PAUSED /**< 'PAUSED' state*/
}tts_state_e;
/**
@@ -95,22 +88,22 @@ typedef struct tts_s *tts_h;
/**
-* @brief Called when the TTS state has changed by the daemon.
+* @brief Called when the state of TTS is changed.
*
* @details If the daemon must stop player because of changing engine and
* the daemon must pause player because of other requests, this callback function is called.
*
* @param[in] tts The handle for TTS
-* @param[in] code The interrupt type
-* @param[in] user_data The user data passed from the the callback registration function
+* @param[in] previous A previous state
+* @param[in] current A current state
+* @param[in] user_data The user data passed from the callback registration function.
*
-* @pre An application registers this callback using tts_set_interrupted_cb() to detect interrupts.
-* @post If this function is called, the TTS state will be #TTS_STATE_READY or #TTS_STATE_PAUSED.
+* @pre An application registers this callback using tts_set_state_changed_cb() to detect changing state.
*
-* @see tts_set_interrupted_cb()
-* @see tts_unset_interrupted_cb()
+* @see tts_set_state_changed_cb()
+* @see tts_unset_state_changed_cb()
*/
-typedef void (*tts_interrupted_cb)(tts_h tts, tts_interrupted_code_e code, void* user_data);
+typedef void (*tts_state_changed_cb)(tts_h tts, tts_state_e previous, tts_state_e current, void* user_data);
/**
* @brief Called when utterance has started.
@@ -177,17 +170,15 @@ typedef void (*tts_error_cb)(tts_h tts, int utt_id, tts_error_e reason, void* us
*/
typedef bool(*tts_supported_voice_cb)(tts_h tts, const char* language, tts_voice_type_e voice_type, void* user_data);
+
/**
-* @brief Creates a handle for TTS and connects the daemon.
+* @brief Creates a handle for TTS.
*
* @param[out] tts The handle for TTS
*
* @return 0 on success, otherwise a negative error value
* @retval #TTS_ERROR_NONE Successful
-* @retval #TTS_ERROR_TIMED_OUT The daemon is blocked or do not exist
-* @retval #TTS_ERROR_ENGINE_NOT_FOUND No available engine \n Engine should be installed
* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #TTS_ERROR_OUT_OF_MEMORY Out of memory
*
* @see tts_destroy()
*/
@@ -207,6 +198,40 @@ int tts_create(tts_h* tts);
int tts_destroy(tts_h tts);
/**
+* @brief Connects the daemon asynchronously.
+*
+* @param[in] tts The handle for TTS
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #TTS_ERROR_NONE Successful
+* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #TTS_ERROR_INVALID_STATE Invalid state
+*
+* @pre The state should be #TTS_STATE_CREATED.
+* @post If this function is called, the TTS state will be #TTS_STATE_READY.
+*
+* @see tts_unprepare()
+*/
+int tts_prepare(tts_h tts);
+
+/**
+* @brief Disconnects the daemon.
+*
+* @param[in] tts The handle for TTS
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #TTS_ERROR_NONE Successful
+* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #STT_ERROR_INVALID_STATE Invalid state
+*
+* @pre The state should be #TTS_STATE_READY.
+* @post If this function is called, the TTS state will be #TTS_STATE_CREATED.
+*
+* @see tts_prepare()
+*/
+int tts_unprepare(tts_h tts);
+
+/**
* @brief Retrieves all supported voices of the current engine using callback function.
*
* @param[in] tts The handle for TTS
@@ -217,6 +242,8 @@ int tts_destroy(tts_h tts);
* @retval #TTS_ERROR_NONE Successful
* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #TTS_ERROR_OPERATION_FAILED Operation failure
+*
+* @pre The state should be #TTS_STATE_READY.
* @post This function invokes tts_supported_voice_cb() repeatedly for getting voices.
*
* @see tts_get_default_voice()
@@ -240,6 +267,8 @@ int tts_foreach_supported_voices(tts_h tts, tts_supported_voice_cb callback, voi
* @retval #TTS_ERROR_OUT_OF_MEMORY Out of memory
* @retval #TTS_ERROR_OPERATION_FAILED Operation failure
*
+* @pre The state should be #TTS_STATE_READY.
+*
* @see tts_foreach_supported_voices()
*/
int tts_get_default_voice(tts_h tts, char** language, tts_voice_type_e* voice_type);
@@ -255,6 +284,8 @@ int tts_get_default_voice(tts_h tts, char** language, tts_voice_type_e* voice_ty
* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #TTS_ERROR_OPERATION_FAILED Operation failure
*
+* @pre The state should be #TTS_STATE_READY.
+*
* @see tts_add_text()
*/
int tts_get_max_text_count(tts_h tts, int* count);
@@ -293,6 +324,7 @@ int tts_get_state(tts_h tts, tts_state_e* state);
* @retval #TTS_ERROR_OUT_OF_MEMORY Out of memory
* @retval #TTS_ERROR_OPERATION_FAILED Operation failure
*
+* @pre The state should be #TTS_STATE_READY, #TTS_STATE_PLAYING or #TTS_STATE_PAUSED.
* @see tts_get_max_text_count()
*/
int tts_add_text(tts_h tts, const char* text, const char* language, tts_voice_type_e voice_type, tts_speed_e speed, int* utt_id);
@@ -363,7 +395,7 @@ int tts_stop(tts_h tts);
int tts_pause(tts_h tts);
/**
-* @brief Registers a callback function for detecting player interrupted.
+* @brief Registers a callback function to be called when TTS state changes.
*
* @param[in] tts The handle for TTS
* @param[in] callback The callback function to register
@@ -373,10 +405,12 @@ int tts_pause(tts_h tts);
* @retval #TTS_ERROR_NONE Successful
* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
*
-* @see tts_interrupted_cb()
-* @see tts_unset_interrupted_cb()
+* @pre The state should be #TTS_STATE_CREATED.
+*
+* @see tts_state_changed_cb()
+* @see tts_unset_state_changed_cb()
*/
-int tts_set_interrupted_cb(tts_h tts, tts_interrupted_cb callback, void* user_data);
+int tts_set_state_changed_cb(tts_h tts, tts_state_changed_cb callback, void* user_data);
/**
* @brief Unregisters the callback function.
@@ -387,9 +421,11 @@ int tts_set_interrupted_cb(tts_h tts, tts_interrupted_cb callback, void* user_da
* @retval #TTS_ERROR_NONE Successful
* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
*
-* @see tts_set_interrupted_cb()
+* @pre The state should be #TTS_STATE_CREATED.
+*
+* @see tts_set_state_changed_cb()
*/
-int tts_unset_interrupted_cb(tts_h tts);
+int tts_unset_state_changed_cb(tts_h tts);
/**
* @brief Registers a callback function for detecting utterance started.
@@ -402,6 +438,8 @@ int tts_unset_interrupted_cb(tts_h tts);
* @retval #TTS_ERROR_NONE Successful
* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
*
+* @pre The state should be #TTS_STATE_CREATED.
+*
* @see tts_utterance_started_cb()
* @see tts_unset_utterance_started_cb()
*/
@@ -416,6 +454,8 @@ int tts_set_utterance_started_cb(tts_h tts, tts_utterance_started_cb callback, v
* @retval #TTS_ERROR_NONE Successful
* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
*
+* @pre The state should be #TTS_STATE_CREATED.
+*
* @see tts_set_utterance_started_cb()
*/
int tts_unset_utterance_started_cb(tts_h tts);
@@ -431,6 +471,8 @@ int tts_unset_utterance_started_cb(tts_h tts);
* @retval #TTS_ERROR_NONE Successful
* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
*
+* @pre The state should be #TTS_STATE_CREATED.
+*
* @see tts_utterance_completed_cb()
* @see tts_unset_utterance_completed_cb()
*/
@@ -445,6 +487,8 @@ int tts_set_utterance_completed_cb(tts_h tts, tts_utterance_completed_cb callbac
* @retval #TTS_ERROR_NONE Successful
* @retval #TTS_ERROR_OUT_OF_MEMORY Out of memory
*
+* @pre The state should be #TTS_STATE_CREATED.
+*
* @see tts_set_utterance_completed_cb()
*/
int tts_unset_utterance_completed_cb(tts_h tts);
@@ -460,6 +504,8 @@ int tts_unset_utterance_completed_cb(tts_h tts);
* @retval #TTS_ERROR_NONE Successful
* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
*
+* @pre The state should be #TTS_STATE_CREATED.
+*
* @see tts_error_cb()
* @see tts_unset_error_cb()
*/
@@ -474,6 +520,8 @@ int tts_set_error_cb(tts_h tts, tts_error_cb callback, void* user_data);
* @retval #TTS_ERROR_NONE Successful
* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
*
+* @pre The state should be #TTS_STATE_CREATED.
+*
* @see tts_set_error_cb()
*/
int tts_unset_error_cb(tts_h tts);
diff --git a/client/tts_client.c b/client/tts_client.c
index 5b348fc..7179b2a 100644
--- a/client/tts_client.c
+++ b/client/tts_client.c
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+* Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -48,8 +48,8 @@ int tts_client_new(tts_h* tts)
client->uid = temp->handle;
client->current_utt_id = 0;
- client->interrupted_cb = NULL;
- client->interrupted_user_data = NULL;
+ client->state_changed_cb = NULL;
+ client->state_changed_user_data = NULL;
client->utt_started_cb = NULL;
client->utt_started_user_data = NULL;
@@ -59,7 +59,8 @@ int tts_client_new(tts_h* tts)
client->error_cb = NULL;
client->error_user_data = NULL;
- client->current_state = TTS_STATE_READY;
+ client->before_state = TTS_STATE_CREATED;
+ client->current_state = TTS_STATE_CREATED;
client->cb_ref_count = 0;
diff --git a/client/tts_client.h b/client/tts_client.h
index 494327e..f1c4740 100644
--- a/client/tts_client.h
+++ b/client/tts_client.h
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+* Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -31,8 +31,8 @@ typedef struct {
int current_utt_id;
/* callback info */
- tts_interrupted_cb interrupted_cb;
- void* interrupted_user_data;
+ tts_state_changed_cb state_changed_cb;
+ void* state_changed_user_data;
tts_utterance_started_cb utt_started_cb;
void* utt_started_user_data;
tts_utterance_completed_cb utt_completeted_cb;
@@ -41,10 +41,15 @@ typedef struct {
void* error_user_data;
/* state */
+ tts_state_e before_state;
tts_state_e current_state;
/* semaphore */
int cb_ref_count;
+
+ /* callback data */
+ int utt_id;
+ int reason;
}tts_client_s;
int tts_client_new(tts_h* tts);
diff --git a/client/tts_dbus.c b/client/tts_dbus.c
index d0c6538..e5115ca 100644
--- a/client/tts_dbus.c
+++ b/client/tts_dbus.c
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+* Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -16,7 +16,9 @@
#include "tts_main.h"
#include "tts_dbus.h"
#include "tts_defs.h"
+#include "tts_client.h"
+#define INIT_WAITING_TIME 5000
#define WAITING_TIME 1000
static Ecore_Fd_Handler* g_fd_handler = NULL;
@@ -26,7 +28,7 @@ static DBusConnection* g_conn = NULL;
extern int __tts_cb_error(int uid, tts_error_e reason, int utt_id);
-extern int __tts_cb_interrupt(int uid, tts_interrupted_code_e code);
+extern int __tts_cb_set_state(int uid, int state);
extern int __tts_cb_utt_started(int uid, int utt_id);
@@ -58,7 +60,47 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle
snprintf(if_name, 64, "%s%d", TTS_CLIENT_SERVICE_INTERFACE, getpid());
/* check if the message is a signal from the correct interface and with the correct name */
- if (dbus_message_is_method_call(msg, if_name, TTS_METHOD_UTTERANCE_STARTED)) {
+ if (dbus_message_is_method_call(msg, if_name, TTSD_METHOD_HELLO)) {
+ SLOG(LOG_DEBUG, TAG_TTSC, "===== Get Hello");
+ int uid = 0;
+ int response = -1;
+
+ dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID);
+
+ if (uid > 0) {
+ SLOG(LOG_DEBUG, TAG_TTSC, "<<<< tts get hello : uid(%d) \n", uid);
+
+ /* check uid */
+ tts_client_s* client = tts_client_get_by_uid(uid);
+ if (NULL != client)
+ response = 1;
+ else
+ response = 0;
+ } else {
+ SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts get hello : invalid uid \n");
+ }
+
+ reply = dbus_message_new_method_return(msg);
+
+ if (NULL != reply) {
+ dbus_message_append_args(reply, DBUS_TYPE_INT32, &response, DBUS_TYPE_INVALID);
+
+ if (!dbus_connection_send(conn, reply, NULL))
+ SLOG(LOG_ERROR, TAG_TTSC, ">>>> tts get hello : fail to send reply");
+ else
+ SLOG(LOG_DEBUG, TAG_TTSC, ">>>> tts get hello : result(%d)", response);
+
+ dbus_connection_flush(conn);
+ dbus_message_unref(reply);
+ } else {
+ SLOG(LOG_ERROR, TAG_TTSC, ">>>> tts get hello : fail to create reply message");
+ }
+
+ SLOG(LOG_DEBUG, TAG_TTSC, "=====");
+ SLOG(LOG_DEBUG, TAG_TTSC, " ");
+ } /* TTSD_METHOD_HELLO */
+
+ else if (dbus_message_is_method_call(msg, if_name, TTSD_METHOD_UTTERANCE_STARTED)) {
SLOG(LOG_DEBUG, TAG_TTSC, "===== Get utterance started");
int uid, uttid;
dbus_message_get_args(msg, &err,
@@ -70,19 +112,15 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle
SLOG(LOG_ERROR, TAG_TTSC, "<<<< Get Utterance started - Get arguments error (%s)\n", err.message);
dbus_error_free(&err);
} else {
- SLOG(LOG_DEBUG, TAG_TTSC, "<<<< Get Utterance started signal : uid(%d), uttid(%d) \n", uid, uttid);
+ SLOG(LOG_DEBUG, TAG_TTSC, "<<<< Get Utterance started message : uid(%d), uttid(%d) \n", uid, uttid);
__tts_cb_utt_started(uid, uttid);
}
- reply = dbus_message_new_method_return(msg);
- dbus_connection_send(conn, reply, NULL);
- dbus_connection_flush(conn);
- dbus_message_unref(reply);
SLOG(LOG_DEBUG, TAG_TTSC, "=====");
SLOG(LOG_DEBUG, TAG_TTSC, " ");
}/* TTS_SIGNAL_UTTERANCE_STARTED */
- else if (dbus_message_is_method_call(msg, if_name, TTS_METHOD_UTTERANCE_COMPLETED)) {
+ else if (dbus_message_is_method_call(msg, if_name, TTSD_METHOD_UTTERANCE_COMPLETED)) {
SLOG(LOG_DEBUG, TAG_TTSC, "===== Get utterance completed");
int uid, uttid;
dbus_message_get_args(msg, &err,
@@ -94,46 +132,36 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle
SLOG(LOG_ERROR, TAG_TTSC, "<<<< Get Utterance completed - Get arguments error (%s)\n", err.message);
dbus_error_free(&err);
} else {
- SLOG(LOG_DEBUG, TAG_TTSC, "<<<< Get Utterance completed signal : uid(%d), uttid(%d) \n", uid, uttid);
+ SLOG(LOG_DEBUG, TAG_TTSC, "<<<< Get Utterance completed message : uid(%d), uttid(%d) \n", uid, uttid);
__tts_cb_utt_completed(uid, uttid);
}
- reply = dbus_message_new_method_return(msg);
- dbus_connection_send(conn, reply, NULL);
- dbus_connection_flush(conn);
- dbus_message_unref(reply);
-
SLOG(LOG_DEBUG, TAG_TTSC, "=====");
SLOG(LOG_DEBUG, TAG_TTSC, " ");
}/* TTS_SIGNAL_UTTERANCE_COMPLETED */
- else if (dbus_message_is_method_call(msg, if_name, TTS_METHOD_INTERRUPT)) {
- SLOG(LOG_DEBUG, TAG_TTSC, "===== Get interrupt callback");
+ else if (dbus_message_is_method_call(msg, if_name, TTSD_METHOD_SET_STATE)) {
+ SLOG(LOG_DEBUG, TAG_TTSC, "===== Get state changed callback");
int uid;
- int code;
+ int state;
dbus_message_get_args(msg, &err,
DBUS_TYPE_INT32, &uid,
- DBUS_TYPE_INT32, &code,
+ DBUS_TYPE_INT32, &state,
DBUS_TYPE_INVALID);
if (dbus_error_is_set(&err)) {
- SLOG(LOG_ERROR, TAG_TTSC, "<<<< Get Stop signal - Get arguments error (%s)\n", err.message);
+ SLOG(LOG_ERROR, TAG_TTSC, "<<<< Get state change - Get arguments error (%s)", err.message);
dbus_error_free(&err);
} else {
- SLOG(LOG_DEBUG, TAG_TTSC, "<<<< Get Interrupt signal : uid(%d) , interrupt code(%d)\n", uid, code);
- __tts_cb_interrupt(uid, (tts_interrupted_code_e)code);
+ SLOG(LOG_DEBUG, TAG_TTSC, "<<<< Get state change : uid(%d) , state(%d)", uid, state);
+ __tts_cb_set_state(uid, state);
}
- reply = dbus_message_new_method_return(msg);
- dbus_connection_send(conn, reply, NULL);
- dbus_connection_flush(conn);
- dbus_message_unref(reply);
-
SLOG(LOG_DEBUG, TAG_TTSC, "=====");
SLOG(LOG_DEBUG, TAG_TTSC, " ");
- } /* TTS_SIGNAL_INTERRUPT */
+ } /* TTSD_METHOD_SET_STATE */
- else if (dbus_message_is_method_call(msg, if_name, TTS_METHOD_ERROR)) {
+ else if (dbus_message_is_method_call(msg, if_name, TTSD_METHOD_ERROR)) {
SLOG(LOG_DEBUG, TAG_TTSC, "===== Get error callback");
int uid;
@@ -154,11 +182,6 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle
__tts_cb_error(uid, reason, uttid);
}
- reply = dbus_message_new_method_return(msg);
- dbus_connection_send(conn, reply, NULL);
- dbus_connection_flush(conn);
- dbus_message_unref(reply);
-
SLOG(LOG_DEBUG, TAG_TTSC, "=====");
SLOG(LOG_DEBUG, TAG_TTSC, " ");
}/* TTS_SIGNAL_ERROR */
@@ -234,7 +257,7 @@ int tts_dbus_open_connection()
int fd = 0;
dbus_connection_get_unix_fd(g_conn, &fd);
- g_fd_handler = ecore_main_fd_handler_add(fd, ECORE_FD_READ | ECORE_FD_ERROR | ECORE_FD_WRITE, (Ecore_Fd_Cb)listener_event_callback, g_conn, NULL, NULL);
+ g_fd_handler = ecore_main_fd_handler_add(fd, ECORE_FD_READ, (Ecore_Fd_Cb)listener_event_callback, g_conn, NULL, NULL);
if (NULL == g_fd_handler) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to get fd handler from ecore \n");
@@ -250,6 +273,8 @@ int tts_dbus_close_connection()
DBusError err;
dbus_error_init(&err);
+ ecore_main_fd_handler_del(g_fd_handler);
+
int pid = getpid();
char service_name[64];
@@ -259,7 +284,8 @@ int tts_dbus_close_connection()
dbus_bus_release_name (g_conn, service_name, &err);
dbus_connection_close(g_conn);
-
+
+ g_fd_handler = NULL;
g_conn = NULL;
return 0;
@@ -309,7 +335,7 @@ int tts_dbus_request_hello()
DBusMessage* result_msg = NULL;
int result = 0;
- result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 500, &err);
+ result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, WAITING_TIME, &err);
dbus_message_unref(msg);
@@ -359,7 +385,7 @@ int tts_dbus_request_initialize(int uid)
DBusMessage* result_msg;
int result = TTS_ERROR_OPERATION_FAILED;
- result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, WAITING_TIME, &err);
+ result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, INIT_WAITING_TIME, &err);
dbus_message_unref(msg);
if (dbus_error_is_set(&err))
diff --git a/client/tts_dbus.h b/client/tts_dbus.h
index 89ce20e..73ab1e6 100644
--- a/client/tts_dbus.h
+++ b/client/tts_dbus.h
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+* Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
diff --git a/client/tts_main.h b/client/tts_main.h
index 9198a80..5f07ccc 100644
--- a/client/tts_main.h
+++ b/client/tts_main.h
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+* Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
diff --git a/client/tts_setting.c b/client/tts_setting.c
index 86a38e3..5afadba 100644
--- a/client/tts_setting.c
+++ b/client/tts_setting.c
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+* Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -13,24 +13,73 @@
#include <sys/wait.h>
+#include <Ecore.h>
#include "tts_main.h"
#include "tts_setting.h"
#include "tts_setting_dbus.h"
-#define CONNECTION_RETRY_COUNT 2
-
-static bool g_is_setting_initialized = false;
+static bool g_is_daemon_started = false;
static int __check_tts_daemon();
+static tts_setting_state_e g_state = TTS_SETTING_STATE_NONE;
+
+static tts_setting_initialized_cb g_initialized_cb;
+static void* g_user_data;
+
+static int g_reason;
/* API Implementation */
+static Eina_Bool __tts_setting_initialized(void *data)
+{
+ g_initialized_cb(g_state, g_reason, g_user_data);
+
+ return EINA_FALSE;
+}
+
+static Eina_Bool __tts_setting_connect_daemon(void *data)
+{
+ /* Send hello */
+ if (0 != tts_setting_dbus_request_hello()) {
+ if (false == g_is_daemon_started) {
+ g_is_daemon_started = true;
+ __check_tts_daemon();
+ }
+ return EINA_TRUE;
+ }
+
+ SLOG(LOG_DEBUG, TAG_TTSC, "===== Connect daemon");
+
+ /* do request initialize */
+ int ret = -1;
+
+ ret = tts_setting_dbus_request_initialize();
+
+ if (TTS_SETTING_ERROR_ENGINE_NOT_FOUND == ret) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Engine not found");
+ } else if (TTS_SETTING_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to connection : %d", ret);
+ } else {
+ /* success to connect tts-daemon */
+ g_state = TTS_SETTING_STATE_READY;
+ }
+
+ g_reason = ret;
+
+ ecore_timer_add(0, __tts_setting_initialized, NULL);
+
+ SLOG(LOG_DEBUG, TAG_TTSC, "=====");
+ SLOG(LOG_DEBUG, TAG_TTSC, " ");
+
+ return EINA_FALSE;
+}
+
int tts_setting_initialize()
{
SLOG(LOG_DEBUG, TAG_TTSC, "===== Initialize TTS Setting");
- if (true == g_is_setting_initialized) {
+ if (TTS_SETTING_STATE_READY == g_state) {
SLOG(LOG_WARN, TAG_TTSC, "[WARNING] TTS Setting has already been initialized. \n");
SLOG(LOG_DEBUG, TAG_TTSC, "=====");
SLOG(LOG_DEBUG, TAG_TTSC, " ");
@@ -43,7 +92,7 @@ int tts_setting_initialize()
SLOG(LOG_DEBUG, TAG_TTSC, " ");
return TTS_SETTING_ERROR_OPERATION_FAILED;
}
-
+
/* Send hello */
if (0 != tts_setting_dbus_request_hello()) {
__check_tts_daemon();
@@ -59,8 +108,8 @@ int tts_setting_initialize()
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Engine not found");
break;
} else if(ret) {
- usleep(1);
- if (i == CONNECTION_RETRY_COUNT) {
+ sleep(1);
+ if (i == 3) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Connection Time out");
ret = TTS_SETTING_ERROR_TIMED_OUT;
break;
@@ -73,7 +122,7 @@ int tts_setting_initialize()
}
if (TTS_SETTING_ERROR_NONE == ret) {
- g_is_setting_initialized = true;
+ g_state = TTS_SETTING_STATE_READY;
SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Initialize");
}
@@ -83,16 +132,45 @@ int tts_setting_initialize()
return ret;
}
+int tts_setting_initialize_async(tts_setting_initialized_cb callback, void* user_data)
+{
+ SLOG(LOG_DEBUG, TAG_TTSC, "===== Initialize TTS Setting");
+
+ if (TTS_SETTING_STATE_READY == g_state) {
+ SLOG(LOG_WARN, TAG_TTSC, "[WARNING] TTS Setting has already been initialized. \n");
+ SLOG(LOG_DEBUG, TAG_TTSC, "=====");
+ SLOG(LOG_DEBUG, TAG_TTSC, " ");
+ return TTS_SETTING_ERROR_NONE;
+ }
+
+ if( 0 != tts_setting_dbus_open_connection() ) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to open connection\n ");
+ SLOG(LOG_DEBUG, TAG_TTSC, "=====");
+ SLOG(LOG_DEBUG, TAG_TTSC, " ");
+ return TTS_SETTING_ERROR_OPERATION_FAILED;
+ }
+
+ g_initialized_cb = callback;
+ g_user_data = user_data;
+
+ ecore_timer_add(0, __tts_setting_connect_daemon, NULL);
+
+ SLOG(LOG_DEBUG, TAG_TTSC, "=====");
+ SLOG(LOG_DEBUG, TAG_TTSC, " ");
+
+ return TTS_SETTING_ERROR_NONE;
+}
+
int tts_setting_finalize()
{
SLOG(LOG_DEBUG, TAG_TTSC, "===== Finalize TTS Setting");
- if (false == g_is_setting_initialized) {
+ if (TTS_SETTING_STATE_NONE == g_state) {
SLOG(LOG_WARN, TAG_TTSC, "[WARNING] Not initialized");
SLOG(LOG_DEBUG, TAG_TTSC, "=====");
SLOG(LOG_DEBUG, TAG_TTSC, " ");
- return TTS_SETTING_ERROR_NONE;
+ return TTS_SETTING_ERROR_INVALID_STATE;
}
int ret = tts_setting_dbus_request_finalilze();
@@ -110,7 +188,7 @@ int tts_setting_finalize()
SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Finalize");
}
- g_is_setting_initialized = false;
+ g_state = TTS_SETTING_STATE_NONE;
SLOG(LOG_DEBUG, TAG_TTSC, "=====");
SLOG(LOG_DEBUG, TAG_TTSC, " ");
@@ -122,7 +200,7 @@ int tts_setting_foreach_supported_engines(tts_setting_supported_engine_cb callba
{
SLOG(LOG_DEBUG, TAG_TTSC, "===== Foreach supported engines");
- if (false == g_is_setting_initialized) {
+ if (TTS_SETTING_STATE_NONE == g_state) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Not initialized");
SLOG(LOG_DEBUG, TAG_TTSC, "=====");
SLOG(LOG_DEBUG, TAG_TTSC, " ");
@@ -153,7 +231,7 @@ int tts_setting_get_engine(char** engine_id)
{
SLOG(LOG_DEBUG, TAG_TTSC, "===== Get current engine");
- if (false == g_is_setting_initialized) {
+ if (TTS_SETTING_STATE_NONE == g_state) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Not initialized");
SLOG(LOG_DEBUG, TAG_TTSC, "=====");
SLOG(LOG_DEBUG, TAG_TTSC, " ");
@@ -184,7 +262,7 @@ int tts_setting_set_engine(const char* engine_id)
{
SLOG(LOG_DEBUG, TAG_TTSC, "===== Set current engine");
- if (false == g_is_setting_initialized) {
+ if (TTS_SETTING_STATE_NONE == g_state) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Not initialized");
SLOG(LOG_DEBUG, TAG_TTSC, "=====");
SLOG(LOG_DEBUG, TAG_TTSC, " ");
@@ -215,7 +293,7 @@ int tts_setting_foreach_surpported_voices(tts_setting_supported_voice_cb callbac
{
SLOG(LOG_DEBUG, TAG_TTSC, "===== Foreach supported voices");
- if (false == g_is_setting_initialized) {
+ if (TTS_SETTING_STATE_NONE == g_state) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Not initialized");
SLOG(LOG_DEBUG, TAG_TTSC, "=====");
SLOG(LOG_DEBUG, TAG_TTSC, " ");
@@ -247,7 +325,7 @@ int tts_setting_get_default_voice(char** language, tts_setting_voice_type_e* voi
{
SLOG(LOG_DEBUG, TAG_TTSC, "===== Get default voice");
- if (false == g_is_setting_initialized) {
+ if (TTS_SETTING_STATE_NONE == g_state) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Not initialized");
SLOG(LOG_DEBUG, TAG_TTSC, "=====");
SLOG(LOG_DEBUG, TAG_TTSC, " ");
@@ -278,7 +356,7 @@ int tts_setting_set_default_voice(const char* language, tts_setting_voice_type_e
{
SLOG(LOG_DEBUG, TAG_TTSC, "===== Set default voice");
- if (false == g_is_setting_initialized) {
+ if (TTS_SETTING_STATE_NONE == g_state) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Not initialized");
SLOG(LOG_DEBUG, TAG_TTSC, "=====");
SLOG(LOG_DEBUG, TAG_TTSC, " ");
@@ -292,7 +370,7 @@ int tts_setting_set_default_voice(const char* language, tts_setting_voice_type_e
return TTS_SETTING_ERROR_INVALID_PARAMETER;
}
- if (voice_type < TTS_SETTING_VOICE_TYPE_MALE && TTS_SETTING_VOICE_TYPE_USER3 < voice_type ) {
+ if (voice_type < TTS_SETTING_VOICE_TYPE_MALE || TTS_SETTING_VOICE_TYPE_USER3 < voice_type ) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Invalid voice type");
SLOG(LOG_DEBUG, TAG_TTSC, "=====");
SLOG(LOG_DEBUG, TAG_TTSC, " ");
@@ -309,7 +387,7 @@ int tts_setting_set_default_voice(const char* language, tts_setting_voice_type_e
SLOG(LOG_DEBUG, TAG_TTSC, "=====");
SLOG(LOG_DEBUG, TAG_TTSC, " ");
- return TTS_SETTING_ERROR_NONE;
+ return ret;
}
@@ -317,7 +395,7 @@ int tts_setting_get_default_speed(tts_setting_speed_e* speed)
{
SLOG(LOG_DEBUG, TAG_TTSC, "===== Get default speed");
- if (!g_is_setting_initialized) {
+ if (TTS_SETTING_STATE_NONE == g_state) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Not initialized");
SLOG(LOG_DEBUG, TAG_TTSC, "=====");
SLOG(LOG_DEBUG, TAG_TTSC, " ");
@@ -354,14 +432,14 @@ int tts_setting_set_default_speed(tts_setting_speed_e speed)
{
SLOG(LOG_DEBUG, TAG_TTSC, "===== Set default speed");
- if (!g_is_setting_initialized) {
+ if (TTS_SETTING_STATE_NONE == g_state) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Not initialized");
SLOG(LOG_DEBUG, TAG_TTSC, "=====");
SLOG(LOG_DEBUG, TAG_TTSC, " ");
return TTS_SETTING_ERROR_INVALID_STATE;
}
- if (speed < TTS_SETTING_SPEED_VERY_SLOW && TTS_SETTING_SPEED_VERY_FAST < speed ) {
+ if (speed < TTS_SETTING_SPEED_VERY_SLOW || TTS_SETTING_SPEED_VERY_FAST < speed) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Invalid speed");
SLOG(LOG_DEBUG, TAG_TTSC, "=====");
SLOG(LOG_DEBUG, TAG_TTSC, " ");
@@ -385,7 +463,7 @@ int tts_setting_foreach_engine_settings(tts_setting_engine_setting_cb callback,
{
SLOG(LOG_DEBUG, TAG_TTSC, "===== Foreach engine setting");
- if (!g_is_setting_initialized) {
+ if (TTS_SETTING_STATE_NONE == g_state) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Not initialized");
SLOG(LOG_DEBUG, TAG_TTSC, "=====");
SLOG(LOG_DEBUG, TAG_TTSC, " ");
@@ -416,7 +494,7 @@ int tts_setting_set_engine_setting(const char* key, const char* value)
{
SLOG(LOG_DEBUG, TAG_TTSC, "===== Set engine setting");
- if (!g_is_setting_initialized) {
+ if (TTS_SETTING_STATE_NONE == g_state) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Not initialized");
SLOG(LOG_DEBUG, TAG_TTSC, "=====");
SLOG(LOG_DEBUG, TAG_TTSC, " ");
@@ -457,7 +535,7 @@ static bool __tts_is_alive()
fp = popen("ps", "r");
if (NULL == fp) {
- SLOG(LOG_DEBUG, TAG_TTSC, "[TTS SETTING ERROR] popen error \n");
+ SLOG(LOG_DEBUG, TAG_TTSC, "[TTS SETTING ERROR] popen error");
return FALSE;
}
@@ -532,7 +610,6 @@ static int __check_tts_daemon()
break;
default:
- sleep(1);
break;
}
diff --git a/client/tts_setting.h b/client/tts_setting.h
index 06e2219..f734af0 100644
--- a/client/tts_setting.h
+++ b/client/tts_setting.h
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+* Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -67,6 +67,14 @@ typedef enum {
TTS_SETTING_VOICE_TYPE_USER3 /**< Engine defined */
} tts_setting_voice_type_e;
+/**
+* @brief Enumerations of setting state.
+*/
+typedef enum {
+ TTS_SETTING_STATE_NONE = 0,
+ TTS_SETTING_STATE_READY
+} tts_setting_state_e;
+
/**
* @brief Called to get a engine information.
*
@@ -114,9 +122,21 @@ typedef bool(*tts_setting_supported_voice_cb)(const char* engine_id, const char*
*/
typedef bool(*tts_setting_engine_setting_cb)(const char* engine_id, const char* key, const char* value, void* user_data);
+/**
+* @brief Called to initialize setting.
+*
+* @param[in] state Current state.
+* @param[in] reason Error reason.
+* @param[in] user_data User data passed from the tts_setting_initialize_async().
+*
+* @pre tts_setting_initialize_async() will invoke this callback.
+*
+* @see tts_setting_initialize_async()
+*/
+typedef void(*tts_setting_initialized_cb)(tts_setting_state_e state, tts_setting_error_e reason, void* user_data);
/**
-* @brief Initialize TTS setting and connect to tts-daemon.
+* @brief Initialize TTS setting and connect to tts-daemon asynchronously.
*
* @return 0 on success, otherwise a negative error value.
* @retval #TTS_SETTING_ERROR_NONE Success.
@@ -126,7 +146,9 @@ typedef bool(*tts_setting_engine_setting_cb)(const char* engine_id, const char*
*
* @see tts_setting_finalize()
*/
-int tts_setting_initialize(void);
+int tts_setting_initialize();
+
+int tts_setting_initialize_async(tts_setting_initialized_cb callback, void* user_data);
/**
* @brief finalize tts setting and disconnect to tts-daemon.
diff --git a/client/tts_setting_dbus.c b/client/tts_setting_dbus.c
index c8c57a5..a0eb8b9 100644
--- a/client/tts_setting_dbus.c
+++ b/client/tts_setting_dbus.c
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+* Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -82,6 +82,8 @@ int tts_setting_dbus_close_connection()
dbus_bus_release_name(g_conn, service_name, &err);
+ dbus_connection_close(g_conn);
+
g_conn = NULL;
return 0;
diff --git a/client/tts_setting_dbus.h b/client/tts_setting_dbus.h
index 3f979ac..90d47bc 100644
--- a/client/tts_setting_dbus.h
+++ b/client/tts_setting_dbus.h
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+* Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
diff --git a/common/tts_defs.h b/common/tts_defs.h
index eae80bb..6787947 100644
--- a/common/tts_defs.h
+++ b/common/tts_defs.h
@@ -50,11 +50,12 @@ extern "C" {
#define TTS_METHOD_STOP "tts_method_stop"
#define TTS_METHOD_PAUSE "tts_method_pause"
-#define TTS_METHOD_INTERRUPT "tts_method_interrupt"
-#define TTS_METHOD_UTTERANCE_STARTED "tts_method_utterance_started"
-#define TTS_METHOD_UTTERANCE_COMPLETED "tts_method_utterance_completed"
-#define TTS_METHOD_ERROR "tts_method_error"
-
+#define TTSD_METHOD_HELLO "ttsd_method_hello"
+#define TTSD_METHOD_UTTERANCE_STARTED "ttsd_method_utterance_started"
+#define TTSD_METHOD_UTTERANCE_COMPLETED "ttsd_method_utterance_completed"
+#define TTSD_METHOD_ERROR "ttsd_method_error"
+#define TTSD_METHOD_SET_STATE "ttsd_method_set_state"
+#define TTSD_METHOD_GET_STATE "ttsd_method_get_state"
/******************************************************************************************
* Message Definition for Setting
@@ -74,14 +75,6 @@ extern "C" {
#define TTS_SETTING_METHOD_GET_ENGINE_SETTING "tts_setting_method_get_engine_setting"
#define TTS_SETTING_METHOD_SET_ENGINE_SETTING "tts_setting_method_set_engine_setting"
-/******************************************************************************************
-* Message Definition for tts-daemon internal
-*******************************************************************************************/
-
-#define TTS_METHOD_NEXT_PLAY "tts_method_start_play"
-#define TTS_METHOD_NEXT_SYNTHESIS "tts_method_start_synthesis"
-
-
#ifdef __cplusplus
}
#endif
diff --git a/debian/changelog b/debian/changelog
index 5c6c90e..23903fa 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,8 +1,294 @@
-tts (0.1.1-1) unstable; urgency=low
+tts (0.1.1-37slp2+1) unstable; urgency=low
- * 1.0 release.
- * Git: pkgs/t/tts
- * Tag: tts_0.1.1-1
+ * Fix the bug of player BS
+ * Git: framework/uifw/voice/tts
+ * Tag: tts_0.1.1-37slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com> Thu, 16 Aug 2012 11:30:47 +0900
+
+tts (0.1.1-36slp2+1) unstable; urgency=low
+
+ * Update Setting API for async init
+ * Git: slp/pkgs/t/tts
+ * Tag: tts_0.1.1-36slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com> Mon, 06 Aug 2012 19:30:59 +0900
+
+tts (0.1.1-35slp2+1) unstable; urgency=low
+
+ * Remove fd write option of dbus in client lib
+ * Git: slp/pkgs/t/tts
+ * Tag: tts_0.1.1-35slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com> Tue, 31 Jul 2012 10:17:11 +0900
+
+tts (0.1.1-34slp2+1) unstable; urgency=low
+
+ * Fix the bug of setting client management
+ * Git: slp/pkgs/t/tts
+ * Tag: tts_0.1.1-34slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com> Tue, 24 Jul 2012 13:47:43 +0900
+
+tts (0.1.1-33slp2+1) unstable; urgency=low
+
+ * Update API for async init
+ * Git: slp/pkgs/t/tts
+ * Tag: tts_0.1.1-33slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com> Mon, 04 Jun 2012 19:48:29 +0900
+
+tts (0.1.1-32slp2+1) unstable; urgency=low
+
+ * Add config file
+ * Git: slp/pkgs/t/tts
+ * Tag: tts_0.1.1-32slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com> Thu, 24 May 2012 14:50:30 +0900
+
+tts (0.1.1-31slp2+1) unstable; urgency=low
+
+ * update config not to depend on VConf
+ * Git: slp/pkgs/t/tts
+ * Tag: tts_0.1.1-31slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com> Fri, 18 May 2012 18:56:19 +0900
+
+tts (0.1.1-30slp2+1) unstable; urgency=low
+
+ * fix bug about fork daemon
+ * Git: slp/pkgs/t/tts
+ * Tag: tts_0.1.1-30slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com> Mon, 26 Mar 2012 15:48:37 +0900
+
+tts (0.1.1-29slp2+1) unstable; urgency=low
+
+ * udpate changelog
+ * Git: slp/pkgs/t/tts
+ * Tag: tts_0.1.1-29slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com> Mon, 19 Mar 2012 19:20:22 +0900
+
+tts (0.1.1-28slp2+1) unstable; urgency=low
+
+ * udpate setting api
+ * Git: slp/pkgs/t/tts
+ * Tag: tts_0.1.1-28slp2+1
-- Dongyeol Lee <dy3.lee@samsung.com> Mon, 19 Mar 2012 11:37:32 +0900
+tts (0.1.1-27slp2+1) unstable; urgency=low
+
+ * fix IPC bug
+ * Git: slp/pkgs/t/tts
+ * Tag: tts_0.1.1-27slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com> Wed, 14 Mar 2012 16:14:08 +0900
+
+tts (0.1.1-26slp2+1) unstable; urgency=low
+
+ * beta release
+ * Git: slp/pkgs/t/tts
+ * Tag: tts_0.1.1-26slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com> Fri, 17 Feb 2012 17:42:12 +0900
+
+tts (0.1.1-25slp2+1) unstable; urgency=low
+
+ * fix player bug and update doxygen
+ * Git: slp/pkgs/t/tts
+ * Tag: tts_0.1.1-25slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com> Fri, 17 Feb 2012 10:45:28 +0900
+
+tts (0.1.1-24slp2+1) unstable; urgency=low
+
+ * update engine api
+ * Git: slp/pkgs/t/tts
+ * Tag: tts_0.1.1-24slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com> Thu, 05 Jan 2012 15:53:48 +0900
+
+tts (0.1.1-23slp2+1) unstable; urgency=low
+
+ * update changelog
+ * Git: slp/pkgs/t/tts
+ * Tag: tts_0.1.1-23slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com> Mon, 19 Dec 2011 13:50:50 +0900
+
+tts (0.1.1-22slp2+1) unstable; urgency=low
+
+ * code cleanup and update log
+ * Git: slp/pkgs/t/tts
+ * Tag: tts_0.1.1-22slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com> Fri, 16 Dec 2011 15:56:08 +0900
+
+tts (0.1.1-21slp2+1) unstable; urgency=low
+
+ * code cleanup and update log
+ * Git: 165.213.180.234:slp/pkgs/t/tts
+ * Tag: tts_0.1.1-21slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com> Tue, 06 Dec 2011 19:01:19 +0900
+
+tts (0.1.1-20slp2+1) unstable; urgency=low
+
+ * change boiler plate
+ * Git: 165.213.180.234:slp/pkgs/t/tts
+ * Tag: tts_0.1.1-20slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com> Fri, 02 Dec 2011 10:52:46 +0900
+
+tts (0.1.1-19slp2+1) unstable; urgency=low
+
+ * update for connman
+ * Git: 165.213.180.234:slp/pkgs/t/tts
+ * Tag: tts_0.1.1-19slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com> Tue, 29 Nov 2011 16:14:14 +0900
+
+tts (0.1.1-18slp2+1) unstable; urgency=low
+
+ * bug fix about unref message
+ * Git: 165.213.180.234:slp/pkgs/t/tts
+ * Tag: tts_0.1.1-18slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com> Wed, 23 Nov 2011 15:34:46 +0900
+
+tts (0.1.1-17slp2+1) unstable; urgency=low
+
+ * update API : change sync function and use add_text in 'Play' state
+ * Git: 165.213.180.234:slp/pkgs/t/tts
+ * Tag: tts_0.1.1-17slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com> Wed, 16 Nov 2011 11:28:03 +0900
+
+tts (0.1.1-16slp2+1) unstable; urgency=low
+
+ * update Setting API
+ * Git: 165.213.180.234:slp/pkgs/t/tts
+ * Tag: tts_0.1.1-16slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com> Tue, 01 Nov 2011 11:24:58 +0900
+
+tts (0.1.1-15slp2+1) unstable; urgency=low
+
+ * update API doxygen and fix bug about initial default voice
+ * Git: 165.213.180.234:slp/pkgs/t/tts
+ * Tag: tts_0.1.1-15slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com> Thu, 27 Oct 2011 11:06:49 +0900
+
+tts (0.1.1-14slp2+1) unstable; urgency=low
+
+ * change API for SDK release
+ * Git: 165.213.180.234:slp/pkgs/t/tts
+ * Tag: tts_0.1.1-14slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com> Fri, 21 Oct 2011 16:42:51 +0900
+
+tts (0.1.1-13slp2+1) unstable; urgency=low
+
+ * update API's new callback
+ * Git: 165.213.180.234:slp/pkgs/t/tts
+ * Tag: tts_0.1.1-13slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com> Thu, 20 Oct 2011 17:49:13 +0900
+
+tts (0.1.1-12slp2+1) unstable; urgency=low
+
+ * update new API for sdk release and change boilerplate
+ * Git: 165.213.180.234:slp/pkgs/t/tts
+ * Tag: tts_0.1.1-12slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com> Wed, 19 Oct 2011 16:31:50 +0900
+
+tts (0.1.1-11slp2+1) unstable; urgency=low
+
+ * update bug of prevent and remove dependency of gtk
+ * Git: 165.213.180.234:slp/pkgs/t/tts
+ * Tag: tts_0.1.1-11slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com> Wed, 07 Sep 2011 14:47:34 +0900
+
+tts (0.1.1-10slp2+1) unstable; urgency=low
+
+ * update build file
+ * Git: 165.213.180.234:slp/pkgs/t/tts
+ * Tag: tts_0.1.1-10slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com> Tue, 19 Jul 2011 16:15:13 +0900
+
+tts (0.1.1-9slp2+1) unstable; urgency=low
+
+ * update build file
+ * Git: 165.213.180.234:slp/pkgs/t/tts
+ * Tag: tts_0.1.1-9slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com> Mon, 18 Jul 2011 10:27:52 +0900
+
+tts (0.1.1-8slp2+1) unstable; urgency=low
+
+ * Change IPC and Code Cleanup
+ * Git: 165.213.180.234:slp/pkgs/t/tts
+ * Tag: tts_0.1.1-8slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com> Fri, 15 Jul 2011 18:01:31 +0900
+
+tts (0.1.1-7slp2+1) unstable; urgency=low
+
+ * support multi instance
+ * Git: 165.213.180.234:slp/pkgs/t/tts
+ * Tag: tts_0.1.1-7slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com> Fri, 24 Jun 2011 14:36:36 +0900
+
+tts (0.1.1-6slp2+1) unstable; urgency=low
+
+ * fix defect from prevent
+ * Git: 165.213.180.234:slp/pkgs/t/tts
+ * Tag: tts_0.1.1-6slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com> Tue, 07 Jun 2011 17:05:49 +0900
+
+tts (0.1.1-5slp2+1) unstable; urgency=low
+
+ * Git: 165.213.180.234:slp/pkgs/t/tts
+ * Tag: tts_0.1.1-5slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com> Mon, 23 May 2011 15:14:10 +0900
+
+tts (0.1.1-4slp2+1) unstable; urgency=low
+
+ * Change API - change error code
+ * Git: 165.213.180.234:slp/pkgs/t/tts
+ * Tag: tts_0.1.1-4slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com> Mon, 23 May 2011 09:00:57 +0900
+
+tts (0.1.1-3slp2+1) unstable; urgency=low
+
+ * change control file
+ * Git: 165.213.180.234:slp/pkgs/t/tts
+ * Tag: tts_0.1.1-3slp2+1
+
+ -- Jae-Yong Lee <jaeyong911.lee@samsung.com> Mon, 16 May 2011 10:45:01 +0900
+
+tts (0.1.1-2slp2+1) unstable; urgency=low
+
+ * Initial Release (change files to unix type).
+ * Git: 165.213.180.234:slp/pkgs/t/tts
+ * Tag: tts_0.1.1-2slp2+1
+
+ -- Jae-Yong Lee <jaeyong911.lee@samsung.com> Mon, 16 May 2011 10:11:02 +0900
+
+tts (0.1.1-1slp2+1) unstable; urgency=low
+
+ * Initial Release.
+ * Git: 165.213.180.234:slp/pkgs/t/tts
+ * Tag: tts_0.1.1-1slp2+1
+
+ -- Jae-Yong Lee <jaeyong911.lee@samsung.com> Fri, 13 May 2011 16:15:22 +0900
diff --git a/debian/copyright b/debian/copyright
deleted file mode 100644
index 0592e06..0000000
--- a/debian/copyright
+++ /dev/null
@@ -1,12 +0,0 @@
-Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-
diff --git a/debian/libtts.install.in b/debian/libtts.install.in
index 28666bf..dba0b31 100644
--- a/debian/libtts.install.in
+++ b/debian/libtts.install.in
@@ -1,2 +1,3 @@
@PREFIX@/lib/lib*.so*
@PREFIX@/bin/tts-daemon
+@PREFIX@/lib/voice/tts/1.0/ttsd.conf \ No newline at end of file
diff --git a/debian/rules b/debian/rules
index e7d3c58..e7d3c58 100755..100644
--- a/debian/rules
+++ b/debian/rules
diff --git a/packaging/tts.spec b/packaging/tts.spec
index 3331343..dd094da 100644
--- a/packaging/tts.spec
+++ b/packaging/tts.spec
@@ -4,7 +4,7 @@ Version: 0.1.1
Release: 1
Group: libs
License: Samsung
-Source0: tts-0.1.1.tar.gz
+Source0: %{name}-%{version}.tar.gz
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
BuildRequires: pkgconfig(glib-2.0)
@@ -55,6 +55,7 @@ rm -rf %{buildroot}
%files
%defattr(-,root,root,-)
%{_libdir}/lib*.so
+%{_libdir}/voice/tts/1.0/ttsd.conf
%{_bindir}/tts-daemon
diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt
index 0c4132f..63b5bd3 100644
--- a/server/CMakeLists.txt
+++ b/server/CMakeLists.txt
@@ -33,7 +33,7 @@ INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/../common")
## Dependent packages ##
INCLUDE(FindPkgConfig)
pkg_check_modules(pkgs REQUIRED
- mm-player mm-common vconf dbus-1
+ mm-player vconf mm-common dbus-1
dlog openssl
)
@@ -66,3 +66,5 @@ TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS})
## Install ##
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/ttsp.h DESTINATION include)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/ttsd.conf DESTINATION lib/voice/tts/1.0)
+
diff --git a/server/ttsd.conf b/server/ttsd.conf
new file mode 100644
index 0000000..3d23424
--- /dev/null
+++ b/server/ttsd.conf
@@ -0,0 +1,3 @@
+ENGINE_ID 27F277E9-BBC4-4dca-B553-D9884A3CDAA0
+VOICE en_US 2
+SPEED 3 \ No newline at end of file
diff --git a/server/ttsd_config.c b/server/ttsd_config.c
index 83dce1c..7f4ca59 100644
--- a/server/ttsd_config.c
+++ b/server/ttsd_config.c
@@ -11,212 +11,189 @@
* limitations under the License.
*/
-
-#include <vconf.h>
#include "ttsd_main.h"
#include "ttsd_config.h"
-/*
-* tts-daemon config
-*/
-int ttsd_config_get_char_type(const char* key, char** value)
-{
- if (NULL == key || NULL == value) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Config ERROR] Input parameter is NULL\n");
- return TTSD_ERROR_INVALID_PARAMETER;
- }
-
- *value = vconf_get_str(key);
- if (NULL == *value) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Config ERROR] fail to get char type from config : key(%s)\n", key);
- return -1;
- }
+#define CONFIG_FILE_PATH BASE_DIRECTORY_DOWNLOAD"ttsd.conf"
+#define CONFIG_DEFAULT BASE_DIRECTORY_DEFAULT"ttsd.conf"
+
+#define ENGINE_ID "ENGINE_ID"
+#define VOICE "VOICE"
+#define SPEED "SPEED"
- return 0;
-}
-int ttsd_config_set_char_type(const char* key, const char* value)
+static char* g_engine_id;
+static char* g_language;
+static int g_vc_type;
+static int g_speed;
+
+int __ttsd_config_save()
{
- if (NULL == key || NULL == value) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Config ERROR] Input parameter is NULL\n");
- return TTSD_ERROR_INVALID_PARAMETER;
- }
+ FILE* config_fp;
+ config_fp = fopen(CONFIG_FILE_PATH, "w+");
- if (0 != vconf_set_str(key, value)) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Config ERROR] fail to set char type \n");
+ if (NULL == config_fp) {
+ /* make file and file default */
+ SLOG(LOG_ERROR, TAG_TTSD, "[Config ERROR] Fail to load config (engine id)");
return -1;
}
- return 0;
-}
+ /* Write engine id */
+ fprintf(config_fp, "%s %s\n", ENGINE_ID, g_engine_id);
-int ttsd_config_get_bool_type(const char* key, bool* value)
-{
- if (NULL == key || NULL == value) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Config ERROR] Input parameter is NULL\n");
- return TTSD_ERROR_INVALID_PARAMETER;
- }
-
- int result ;
- if (0 != vconf_get_int(key, &result)) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Config ERROR] fail to get bool type config : key(%s)\n", key);
- return -1;
- }
+ /* Write voice */
+ fprintf(config_fp, "%s %s %d\n", VOICE, g_language, g_vc_type);
- *value = (bool) result;
+ /* Read speed */
+ fprintf(config_fp, "%s %d\n", SPEED, g_speed);
+
+ fclose(config_fp);
return 0;
}
-int ttsd_config_set_bool_type(const char* key, const bool value)
+
+int __ttsd_config_load()
{
- if (NULL == key) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Config ERROR] Input parameter is NULL\n");
- return TTSD_ERROR_INVALID_PARAMETER;
- }
-
- int result = (int)value;
- if (0 != vconf_set_int(key, result)) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Config ERROR] fail to set bool type config : key(%s)\n", key);
- return -1;
- }
+ FILE* config_fp;
+ char buf_id[256] = {0};
+ char buf_param[256] = {0};
+ int int_param = 0;
- return 0;
-}
+ config_fp = fopen(CONFIG_FILE_PATH, "r");
-int ttsd_config_get_int_type(const char* key, int* value)
-{
- if (NULL == key || NULL == value) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Config ERROR] Input parameter is NULL\n");
- return TTSD_ERROR_INVALID_PARAMETER;
- }
+ if (NULL == config_fp) {
+ SLOG(LOG_WARN, TAG_TTSD, "[Config WARNING] Not open file(%s)", CONFIG_FILE_PATH);
+
+ config_fp = fopen(CONFIG_DEFAULT, "r");
+ if (NULL == config_fp) {
+ SLOG(LOG_WARN, TAG_TTSD, "[Config WARNING] Not open original config file(%s)", CONFIG_FILE_PATH);
+ __ttsd_config_save();
+ return -1;
+ }
+ }
- if (0 != vconf_get_int(key, value)) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Config ERROR] fail to get bool type config : key(%s)\n", key);
+ /* Read engine id */
+ fscanf(config_fp, "%s %s", buf_id, buf_param);
+ if (0 == strncmp(ENGINE_ID, buf_id, strlen(ENGINE_ID))) {
+ g_engine_id = strdup(buf_param);
+ } else {
+ fclose(config_fp);
+ SLOG(LOG_WARN, TAG_TTSD, "[Config WARNING] Fail to load config (engine id)");
+ __ttsd_config_save();
return -1;
}
- return 0;
-}
-
-int ttsd_config_set_int_type(const char* key, const int value)
-{
- if (NULL == key) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Config ERROR] Input parameter is NULL\n");
- return TTSD_ERROR_INVALID_PARAMETER;
- }
+ /* Read voice */
+ fscanf(config_fp, "%s %s %d", buf_id, buf_param, &int_param);
+ if (0 == strncmp(VOICE, buf_id, strlen(VOICE))) {
+ g_language = strdup(buf_param);
+ g_vc_type = int_param;
+ } else {
+ fclose(config_fp);
+ SLOG(LOG_WARN, TAG_TTSD, "[Config WARNING] Fail to load config (voice)");
+ __ttsd_config_save();
+ return -1;
+ }
- if (0 != vconf_set_int(key, value)) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Config ERROR] fail to set int type config : key(%s)\n", key);
+ /* Read speed */
+ fscanf(config_fp, "%s %d", buf_id, &int_param);
+ if (0 == strncmp(SPEED, buf_id, strlen(SPEED))) {
+ g_speed = int_param;
+ } else {
+ fclose(config_fp);
+ SLOG(LOG_WARN, TAG_TTSD, "[Config WARNING] Fail to load config (speed)");
+ __ttsd_config_save();
return -1;
}
+ SLOG(LOG_DEBUG, TAG_TTSD, "[Config] Load config : engine(%s), voice(%s,%d), speed(%d)",
+ g_engine_id, g_language, g_vc_type, g_speed);
+
return 0;
}
-/*
-* interface for engine plug-in
-*/
-
-int config_make_key_for_engine(const char* engine_id, const char* key, char** out_key)
+int ttsd_config_initialize()
{
- int key_size = strlen(TTSD_CONFIG_PREFIX) + strlen(engine_id) + strlen(key) + 2; /* 2 is '/' and '\0' */
+ g_engine_id = NULL;
+ g_language = NULL;
+ g_vc_type = 1;
+ g_speed = 3;
- *out_key = (char*) g_malloc0( sizeof(char) * key_size);
-
- if (*out_key == NULL) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Config ERROR] Not enough memory!! \n");
- return -1;
- } else {
- snprintf(*out_key, key_size, "%s%s/%s", TTSD_CONFIG_PREFIX, engine_id, key );
- SLOG(LOG_DEBUG, TAG_TTSD, "[Config DEBUG] make key (%s) \n", *out_key);
- }
+ __ttsd_config_load();
return 0;
}
-int ttsd_config_set_persistent_data(const char* engine_id, const char* key, const char* value)
+int ttsd_config_finalize()
{
- char* vconf_key = NULL;
+ __ttsd_config_save();
+ return 0;
+}
- if (0 != config_make_key_for_engine(engine_id, key, &vconf_key)) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Config ERROR] fail config_make_key_for_engine()\n");
+int ttsd_config_get_default_engine(char** engine_id)
+{
+ if (NULL == engine_id)
return -1;
- }
- if (0 != vconf_set_str(vconf_key, value)) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Config ERROR] fail to set key, value\n");
-
- if(vconf_key != NULL)
- g_free(vconf_key);
+ *engine_id = strdup(g_engine_id);
+ return 0;
+}
+int ttsd_config_set_default_engine(const char* engine_id)
+{
+ if (NULL == engine_id)
return -1;
- }
-
- SLOG(LOG_DEBUG, TAG_TTSD, "[Config DEBUG] Set data : key(%s), value(%s) \n", vconf_key, value);
- if (vconf_key != NULL)
- g_free(vconf_key);
+ if (NULL != g_engine_id)
+ free(g_engine_id);
+ g_engine_id = strdup(engine_id);
+ __ttsd_config_save();
return 0;
}
-int ttsd_config_get_persistent_data(const char* engine_id, const char* key, char** value)
+int ttsd_config_get_default_voice(char** language, int* type)
{
- char* vconf_key = NULL;
-
- if (0 != config_make_key_for_engine(engine_id, key, &vconf_key)) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Config ERROR] fail config_make_key_for_engine()\n");
+ if (NULL == language || NULL == type)
return -1;
- }
- char* temp;
- temp = vconf_get_str(vconf_key);
- if (temp == NULL) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Config ERROR] fail to get value\n");
+ *language = strdup(g_language);
+ *type = g_vc_type;
- if(vconf_key != NULL)
- g_free(vconf_key);
+ return 0;
+}
+int ttsd_config_set_default_voice(const char* language, int type)
+{
+ if (NULL == language)
return -1;
- }
-
- *value = g_strdup(temp);
- SLOG(LOG_DEBUG, TAG_TTSD, "[Config DEBUG] Get data : key(%s), value(%s) \n", vconf_key, *value);
+ if (NULL != g_language)
+ free(g_language);
- if (NULL != vconf_key)
- g_free(vconf_key);
+ g_language = strdup(language);
+ g_vc_type = type;
- if (NULL != temp)
- g_free(temp);
+ __ttsd_config_save();
return 0;
}
-int ttsd_config_remove_persistent_data(const char* engine_id, const char* key)
+int ttsd_config_get_default_speed(int* speed)
{
- char* vconf_key = NULL;
- int result = 0;
-
- if (0 != config_make_key_for_engine(engine_id, key, &vconf_key)) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Config ERROR] fail config_make_key_for_engine()\n");
+ if (NULL == speed)
return -1;
- }
- if( NULL == vconf_key )
- return -1;
-
- if (0 != vconf_unset(vconf_key)) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Config ERROR] fail to remove key\n");
- result = -1;
- } else {
- SLOG(LOG_DEBUG, TAG_TTSD, "[Config DEBUG] Remove data : key(%s)", vconf_key);
- }
+ *speed = g_speed;
- if( vconf_key != NULL )
- g_free(vconf_key);
+ return 0;
+}
- return result;
+int ttsd_config_set_default_speed(int speed)
+{
+ g_speed = speed;
+ __ttsd_config_save();
+ return 0;
}
diff --git a/server/ttsd_config.h b/server/ttsd_config.h
index 45e9b89..01c0aa1 100644
--- a/server/ttsd_config.h
+++ b/server/ttsd_config.h
@@ -15,45 +15,25 @@
#ifndef __TTSD_CONFIG_H_
#define __TTSD_CONFIG_H_
-#include <stdbool.h>
-
#ifdef __cplusplus
extern "C" {
#endif
-#define TTSD_CONFIG_PREFIX "db/ttsd/"
-
-#define CONFIG_KEY_DEFAULT_ENGINE_ID TTSD_CONFIG_PREFIX"engine"
-#define CONFIG_KEY_DEFAULT_LANGUAGE TTSD_CONFIG_PREFIX"language"
-#define CONFIG_KEY_DEFAULT_VOICE_TYPE TTSD_CONFIG_PREFIX"vctype"
-#define CONFIG_KEY_DEFAULT_SPEED TTSD_CONFIG_PREFIX"speed"
-
-/*
-* tts-daemon config
-*/
-
-int ttsd_config_get_char_type(const char* key, char** value);
+int ttsd_config_initialize();
-int ttsd_config_set_char_type(const char* key, const char* value);
+int ttsd_config_finalize();
-int ttsd_config_get_bool_type(const char* key, bool* value);
+int ttsd_config_get_default_engine(char** engine_id);
-int ttsd_config_set_bool_type(const char* key, const bool value);
-
-int ttsd_config_get_int_type(const char* key, int* value);
-
-int ttsd_config_set_int_type(const char* key, const int value);
-
-/*
-* interface for engine plug-in
-*/
+int ttsd_config_set_default_engine(const char* engine_id);
-int ttsd_config_set_persistent_data(const char* engine_id, const char* key, const char* value);
+int ttsd_config_get_default_voice(char** language, int* type);
-int ttsd_config_get_persistent_data(const char* engine_id, const char* key, char** value);
+int ttsd_config_set_default_voice(const char* langauge, int type);
-int ttsd_config_remove_persistent_data(const char* engine_id, const char* key);
+int ttsd_config_get_default_speed(int* speed);
+int ttsd_config_set_default_speed(int speed);
#ifdef __cplusplus
}
diff --git a/server/ttsd_data.cpp b/server/ttsd_data.cpp
index 2d59d88..d031019 100644
--- a/server/ttsd_data.cpp
+++ b/server/ttsd_data.cpp
@@ -19,6 +19,8 @@ using namespace std;
static vector<app_data_s> g_app_list;
+static vector<setting_app_data_s> g_setting_list;
+
static bool g_mutex_state = false;
/*
@@ -40,10 +42,25 @@ int __data_show_list()
}
SLOG(LOG_DEBUG, TAG_TTSD, "-----------------------");
+
+ SLOG(LOG_DEBUG, TAG_TTSD, "----- setting client list -----");
+
+ vsize = g_setting_list.size();
+
+ for (int i=0; i<vsize; i++) {
+ SLOG(LOG_DEBUG, TAG_TTSD, "[%dth] pid(%d)", i, g_setting_list[i].pid );
+ }
+
+ if (0 == vsize) {
+ SLOG(LOG_DEBUG, TAG_TTSD, "No Setting Client");
+ }
+
+ SLOG(LOG_DEBUG, TAG_TTSD, "--------------------------------");
+
return TTSD_ERROR_NONE;
}
-int __data_show_sound_list(const int index)
+int __data_show_sound_list(int index)
{
SLOG(LOG_DEBUG, TAG_TTSD, "----- Sound list -----");
@@ -61,7 +78,7 @@ int __data_show_sound_list(const int index)
return TTSD_ERROR_NONE;
}
-int __data_show_text_list(const int index)
+int __data_show_text_list(int index)
{
SLOG(LOG_DEBUG, TAG_TTSD, "----- Text list -----");
@@ -85,7 +102,7 @@ int __data_show_text_list(const int index)
* ttsd data functions
*/
-int ttsd_data_new_client(const int pid, const int uid)
+int ttsd_data_new_client(int pid, int uid)
{
if( -1 != ttsd_data_is_client(uid) ) {
SLOG(LOG_ERROR, TAG_TTSD, "[DATA ERROR] ttsd_data_new_client() : uid is not valid (%d)\n", uid);
@@ -106,7 +123,7 @@ int ttsd_data_new_client(const int pid, const int uid)
return TTSD_ERROR_NONE;
}
-int ttsd_data_delete_client(const int uid)
+int ttsd_data_delete_client(int uid)
{
int index = 0;
@@ -130,7 +147,7 @@ int ttsd_data_delete_client(const int uid)
return TTSD_ERROR_NONE;
}
-int ttsd_data_is_client(const int uid)
+int ttsd_data_is_client(int uid)
{
int vsize = g_app_list.size();
@@ -145,10 +162,10 @@ int ttsd_data_is_client(const int uid)
int ttsd_data_get_client_count()
{
- return g_app_list.size();
+ return g_app_list.size() + g_setting_list.size();
}
-int ttsd_data_get_pid(const int uid)
+int ttsd_data_get_pid(int uid)
{
int index;
@@ -162,7 +179,7 @@ int ttsd_data_get_pid(const int uid)
return g_app_list[index].pid;
}
-int ttsd_data_get_speak_data_size(const int uid)
+int ttsd_data_get_speak_data_size(int uid)
{
int index = 0;
index = ttsd_data_is_client(uid);
@@ -176,7 +193,7 @@ int ttsd_data_get_speak_data_size(const int uid)
return size;
}
-int ttsd_data_add_speak_data(const int uid, const speak_data_s data)
+int ttsd_data_add_speak_data(int uid, speak_data_s data)
{
int index = 0;
index = ttsd_data_is_client(uid);
@@ -197,7 +214,7 @@ int ttsd_data_add_speak_data(const int uid, const speak_data_s data)
return TTSD_ERROR_NONE;
}
-int ttsd_data_get_speak_data(const int uid, speak_data_s* data)
+int ttsd_data_get_speak_data(int uid, speak_data_s* data)
{
int index = 0;
index = ttsd_data_is_client(uid);
@@ -227,7 +244,7 @@ int ttsd_data_get_speak_data(const int uid, speak_data_s* data)
return TTSD_ERROR_NONE;
}
-int ttsd_data_add_sound_data(const int uid, const sound_data_s data)
+int ttsd_data_add_sound_data(int uid, sound_data_s data)
{
int index = 0;
index = ttsd_data_is_client(uid);
@@ -245,7 +262,7 @@ int ttsd_data_add_sound_data(const int uid, const sound_data_s data)
return TTSD_ERROR_NONE;
}
-int ttsd_data_get_sound_data(const int uid, sound_data_s* data)
+int ttsd_data_get_sound_data(int uid, sound_data_s* data)
{
int index = 0;
index = ttsd_data_is_client(uid);
@@ -276,7 +293,7 @@ int ttsd_data_get_sound_data(const int uid, sound_data_s* data)
return TTSD_ERROR_NONE;
}
-int ttsd_data_get_sound_data_size(const int uid)
+int ttsd_data_get_sound_data_size(int uid)
{
int index = 0;
index = ttsd_data_is_client(uid);
@@ -289,7 +306,7 @@ int ttsd_data_get_sound_data_size(const int uid)
return g_app_list[index].m_wav_data.size();
}
-int ttsd_data_clear_data(const int uid)
+int ttsd_data_clear_data(int uid)
{
int index = 0;
@@ -332,7 +349,7 @@ int ttsd_data_clear_data(const int uid)
return TTSD_ERROR_NONE;
}
-int ttsd_data_get_client_state(const int uid, app_state_e* state)
+int ttsd_data_get_client_state(int uid, app_state_e* state)
{
int index = 0;
@@ -347,7 +364,7 @@ int ttsd_data_get_client_state(const int uid, app_state_e* state)
return TTSD_ERROR_NONE;
}
-int ttsd_data_set_client_state(const int uid, const app_state_e state)
+int ttsd_data_set_client_state(int uid, app_state_e state)
{
int index = 0;
@@ -431,3 +448,71 @@ bool ttsd_data_is_uttid_valid(int uid, int uttid)
return true;
}
+
+int ttsd_data_is_current_playing()
+{
+ int vsize = g_app_list.size();
+
+ for (int i=0; i<vsize; i++) {
+ if(g_app_list[i].state == APP_STATE_PLAYING) {
+ return g_app_list[i].uid;
+ }
+ }
+
+ return -1;
+}
+
+/*
+* setting data
+*/
+
+int ttsd_setting_data_add(int pid)
+{
+ if (-1 != ttsd_setting_data_is_setting(pid)) {
+ SLOG(LOG_ERROR, TAG_TTSD, "[DATA ERROR] pid(%d) is not valid", pid);
+ return TTSD_ERROR_INVALID_PARAMETER;
+ }
+
+ setting_app_data_s setting_app;
+ setting_app.pid = pid;
+
+ g_setting_list.insert(g_setting_list.end(), setting_app);
+
+#ifdef DATA_DEBUG
+ __data_show_list();
+#endif
+ return TTSD_ERROR_NONE;
+
+}
+
+int ttsd_setting_data_delete(int pid)
+{
+ int index = 0;
+
+ index = ttsd_setting_data_is_setting(pid);
+
+ if (index < 0) {
+ SLOG(LOG_ERROR, TAG_TTSD, "[DATA ERROR] uid is not valid (%d)", pid);
+ return -1;
+ }
+
+ g_setting_list.erase(g_setting_list.begin()+index);
+
+#ifdef DATA_DEBUG
+ __data_show_list();
+#endif
+ return TTSD_ERROR_NONE;
+}
+
+int ttsd_setting_data_is_setting(int pid)
+{
+ int vsize = g_setting_list.size();
+
+ for (int i=0; i<vsize; i++) {
+ if(g_setting_list[i].pid == pid) {
+ return i;
+ }
+ }
+
+ return -1;
+} \ No newline at end of file
diff --git a/server/ttsd_data.h b/server/ttsd_data.h
index d115db6..a30ab5e 100644
--- a/server/ttsd_data.h
+++ b/server/ttsd_data.h
@@ -25,7 +25,8 @@ extern "C" {
#endif
typedef enum {
- APP_STATE_READY = 0,
+ APP_STATE_CREATED = 0,
+ APP_STATE_READY,
APP_STATE_PLAYING,
APP_STATE_PAUSED
}app_state_e;
@@ -62,44 +63,55 @@ typedef struct
std::vector<sound_data_s> m_wav_data;
}app_data_s;
+typedef struct {
+ int pid;
+} setting_app_data_s;
-int ttsd_data_new_client(const int pid, const int uid);
+int ttsd_data_new_client(int pid, int uid);
-int ttsd_data_delete_client(const int uid);
+int ttsd_data_delete_client(int uid);
-int ttsd_data_is_client(const int uid);
+int ttsd_data_is_client(int uid);
int ttsd_data_get_client_count();
-int ttsd_data_get_pid(const int uid);
+int ttsd_data_get_pid(int uid);
-int ttsd_data_add_speak_data(const int uid, const speak_data_s data);
+int ttsd_data_add_speak_data(int uid, speak_data_s data);
-int ttsd_data_get_speak_data(const int uid, speak_data_s* data);
+int ttsd_data_get_speak_data(int uid, speak_data_s* data);
-int ttsd_data_get_speak_data_size(const int uid);
+int ttsd_data_get_speak_data_size(int uid);
-int ttsd_data_add_sound_data(const int uid, const sound_data_s data);
+int ttsd_data_add_sound_data(int uid, sound_data_s data);
-int ttsd_data_get_sound_data(const int uid, sound_data_s* data);
+int ttsd_data_get_sound_data(int uid, sound_data_s* data);
-int ttsd_data_get_sound_data_size(const int uid);
+int ttsd_data_get_sound_data_size(int uid);
-int ttsd_data_clear_data(const int uid);
+int ttsd_data_clear_data(int uid);
-int ttsd_data_get_client_state(const int pid, app_state_e* state);
+int ttsd_data_get_client_state(int pid, app_state_e* state);
-int ttsd_data_set_client_state(const int pid, const app_state_e state);
+int ttsd_data_set_client_state(int pid, app_state_e state);
int ttsd_data_get_current_playing();
-
typedef bool(*ttsd_data_get_client_cb)(int pid, int uid, app_state_e state, void* user_data);
int ttsd_data_foreach_clients(ttsd_data_get_client_cb callback, void* user_data);
bool ttsd_data_is_uttid_valid(int uid, int uttid);
+int ttsd_data_is_current_playing();
+
+
+int ttsd_setting_data_add(int pid);
+
+int ttsd_setting_data_delete(int pid);
+
+int ttsd_setting_data_is_setting(int pid);
+
#ifdef __cplusplus
}
#endif
diff --git a/server/ttsd_dbus.c b/server/ttsd_dbus.c
index a6fc673..199fa0c 100644
--- a/server/ttsd_dbus.c
+++ b/server/ttsd_dbus.c
@@ -23,7 +23,63 @@
static DBusConnection* g_conn;
-int ttsdc_send_message(int pid, int uid, int uttid, char *method)
+static int g_waiting_time = 3000;
+
+int ttsdc_send_hello(int pid, int uid)
+{
+ char service_name[64];
+ memset(service_name, 0, 64);
+ snprintf(service_name, 64, "%s%d", TTS_CLIENT_SERVICE_NAME, pid);
+
+ char target_if_name[64];
+ snprintf(target_if_name, sizeof(target_if_name), "%s%d", TTS_CLIENT_SERVICE_INTERFACE, pid);
+
+ DBusMessage* msg;
+
+ /* create a message & check for errors */
+ msg = dbus_message_new_method_call(
+ service_name,
+ TTS_CLIENT_SERVICE_OBJECT_PATH,
+ target_if_name,
+ TTSD_METHOD_HELLO);
+
+ if (NULL == msg) {
+ SLOG(LOG_ERROR, TAG_TTSD, "<<<< [Dbus ERROR] Fail to create hello message : uid(%d)", uid);
+ return -1;
+ } else {
+ SLOG(LOG_DEBUG, TAG_TTSD, "<<<< [Dbus] Send hello message : uid(%d)", uid);
+ }
+
+ dbus_message_append_args(msg, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID);
+
+ DBusError err;
+ dbus_error_init(&err);
+
+ DBusMessage* result_msg;
+ int result = -1;
+
+ result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
+ dbus_message_unref(msg);
+
+ if (NULL != result_msg) {
+ dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
+
+ if (dbus_error_is_set(&err)) {
+ SLOG(LOG_ERROR, TAG_TTSD, ">>>> [Dbus] Get arguments error (%s)", err.message);
+ dbus_error_free(&err);
+ result = -1;
+ }
+
+ dbus_message_unref(result_msg);
+ } else {
+ SLOG(LOG_DEBUG, TAG_TTSD, ">>>> [Dbus] Result message is NULL. Client is not available");
+ result = 0;
+ }
+
+ return result;
+}
+
+int ttsdc_send_message(int pid, int uid, int data, char *method)
{
char service_name[64];
memset(service_name, 0, 64);
@@ -44,15 +100,15 @@ int ttsdc_send_message(int pid, int uid, int uttid, char *method)
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_TTSD, "[Dbus ERROR] Fail to create message : type(%s), uid(%d)\n", method, uid);
return -1;
- }
+ }
- dbus_message_append_args(msg, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INT32, &uttid, DBUS_TYPE_INVALID);
+ dbus_message_append_args(msg, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INT32, &data, DBUS_TYPE_INVALID);
/* send the message and flush the connection */
if (!dbus_connection_send(g_conn, msg, NULL)) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Dbus ERROR] <<<< send message : Out Of Memory, type(%s), ifname(%s), uid(%d), uttid(%d)", method, target_if_name, uid, uttid);
+ SLOG(LOG_ERROR, TAG_TTSD, "[Dbus ERROR] <<<< send message : Out Of Memory, type(%s), ifname(%s), uid(%d), data(%d)", method, target_if_name, uid, data);
} else {
- SLOG(LOG_DEBUG, TAG_TTSD, "<<<< send message : type(%s), uid(%d), uttid(%d)", method, uid, uttid);
+ SLOG(LOG_DEBUG, TAG_TTSD, "<<<< send message : type(%s), uid(%d), data(%d)", method, uid, data);
dbus_connection_flush(g_conn);
}
@@ -64,17 +120,17 @@ int ttsdc_send_message(int pid, int uid, int uttid, char *method)
int ttsdc_send_utt_start_message(int pid, int uid, int uttid)
{
- return ttsdc_send_message(pid, uid, uttid, TTS_METHOD_UTTERANCE_STARTED);
+ return ttsdc_send_message(pid, uid, uttid, TTSD_METHOD_UTTERANCE_STARTED);
}
int ttsdc_send_utt_finish_message(int pid, int uid, int uttid)
{
- return ttsdc_send_message(pid, uid, uttid, TTS_METHOD_UTTERANCE_COMPLETED);
+ return ttsdc_send_message(pid, uid, uttid, TTSD_METHOD_UTTERANCE_COMPLETED);
}
-int ttsdc_send_interrupt_message(int pid, int uid, ttsd_interrupted_code_e code)
+int ttsdc_send_set_state_message(int pid, int uid, int state)
{
- return ttsdc_send_message(pid, uid, (int)code, TTS_METHOD_INTERRUPT);
+ return ttsdc_send_message(pid, uid, state, TTSD_METHOD_SET_STATE);
}
int ttsdc_send_error_message(int pid, int uid, int uttid, int reason)
@@ -92,7 +148,7 @@ int ttsdc_send_error_message(int pid, int uid, int uttid, int reason)
service_name,
TTS_CLIENT_SERVICE_OBJECT_PATH,
target_if_name,
- TTS_METHOD_ERROR);
+ TTSD_METHOD_ERROR);
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_TTSD, "[Dbus ERROR] Fail to create error message : uid(%d)\n", uid);
@@ -201,13 +257,6 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle
else if (dbus_message_is_method_call(msg, TTS_SERVER_SERVICE_INTERFACE, TTS_SETTING_METHOD_SET_ENGINE_SETTING) )
ttsd_dbus_server_setting_set_engine_setting(conn, msg);
-
-
- else if (dbus_message_is_method_call(msg, TTS_SERVER_SERVICE_INTERFACE, TTS_METHOD_NEXT_PLAY))
- ttsd_dbus_server_start_next_play(msg);
-
- else if (dbus_message_is_method_call(msg, TTS_SERVER_SERVICE_INTERFACE, TTS_METHOD_NEXT_SYNTHESIS))
- ttsd_dbus_server_start_next_synthesis(msg);
/* free the message */
@@ -297,59 +346,3 @@ int ttsd_dbus_close_connection()
return 0;
}
-
-int ttsd_send_start_next_play_message(int uid)
-{
- DBusMessage* msg;
-
- msg = dbus_message_new_method_call(
- TTS_SERVER_SERVICE_NAME,
- TTS_SERVER_SERVICE_OBJECT_PATH,
- TTS_SERVER_SERVICE_INTERFACE,
- TTS_METHOD_NEXT_PLAY);
-
- if (NULL == msg) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Dbus ERROR] >>>> Fail to make message for 'start next play'");
- return -1;
- }
-
- dbus_message_append_args(msg, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID);
-
- if (!dbus_connection_send(g_conn, msg, NULL)) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Dbus ERROR] >>>> Fail to send message for 'start next play'\n");
- return -1;
- }
-
- dbus_connection_flush(g_conn);
- dbus_message_unref(msg);
-
- return 0;
-}
-
-int ttsd_send_start_next_synthesis_message(int uid)
-{
- DBusMessage* msg;
-
- msg = dbus_message_new_method_call(
- TTS_SERVER_SERVICE_NAME,
- TTS_SERVER_SERVICE_OBJECT_PATH,
- TTS_SERVER_SERVICE_INTERFACE,
- TTS_METHOD_NEXT_SYNTHESIS);
-
- if (NULL == msg) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Dbus ERROR] >>>> Fail to make message for 'start next synthesis'\n");
- return -1;
- }
-
- dbus_message_append_args(msg, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID);
-
- if (!dbus_connection_send(g_conn, msg, NULL)) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Dbus ERROR] >>>> Fail to send message for 'start next synthesis'\n");
- return -1;
- }
-
- dbus_connection_flush(g_conn);
- dbus_message_unref(msg);
-
- return 0;
-}
diff --git a/server/ttsd_dbus.h b/server/ttsd_dbus.h
index a176bcf..a3f293d 100644
--- a/server/ttsd_dbus.h
+++ b/server/ttsd_dbus.h
@@ -24,17 +24,15 @@ int ttsd_dbus_open_connection();
int ttsd_dbus_close_connection();
+int ttsdc_send_hello(int pid, int uid);
+
int ttsdc_send_utt_start_message(int pid, int uid, int uttid);
int ttsdc_send_utt_finish_message(int pid, int uid, int uttid);
int ttsdc_send_error_message(int pid, int uid, int uttid, int reason);
-int ttsdc_send_interrupt_message(int pid, int uid, ttsd_interrupted_code_e code);
-
-int ttsd_send_start_next_play_message(int uid);
-
-int ttsd_send_start_next_synthesis_message(int uid);
+int ttsdc_send_set_state_message(int pid, int uid, int state);
#ifdef __cplusplus
}
diff --git a/server/ttsd_dbus_server.c b/server/ttsd_dbus_server.c
index 4837fcc..5a632a6 100644
--- a/server/ttsd_dbus_server.c
+++ b/server/ttsd_dbus_server.c
@@ -1264,63 +1264,3 @@ int ttsd_dbus_server_setting_set_engine_setting(DBusConnection* conn, DBusMessag
return 0;
}
-
-/*
-* Dbus Server functions for tts daemon intenal
-*/
-
-int ttsd_dbus_server_start_next_play(DBusMessage* msg)
-{
- DBusError err;
- dbus_error_init(&err);
-
- int uid;
-
- dbus_message_get_args(msg, &err,
- DBUS_TYPE_INT32, &uid,
- DBUS_TYPE_INVALID);
-
- SLOG(LOG_DEBUG, TAG_TTSD, ">>>>> TTSD NEXT PLAY");
-
- if (dbus_error_is_set(&err)) {
- SLOG(LOG_ERROR, TAG_TTSD, "[IN ERROR] ttsd 'start next play' : Get arguments error (%s)\n", err.message);
- dbus_error_free(&err);
- } else {
- SLOG(LOG_DEBUG, TAG_TTSD, "[IN] ttsd 'start next play' : uid(%d) \n", uid);
- int ret = ttsd_server_start_next_play(uid);
- SLOG(LOG_DEBUG, TAG_TTSD, "[OUT] ttsd 'start next play' : result(%d) \n", ret);
- }
-
- SLOG(LOG_DEBUG, TAG_TTSD, "<<<<<");
- SLOG(LOG_DEBUG, TAG_TTSD, " ");
-
- return 0;
-}
-
-int ttsd_dbus_server_start_next_synthesis(DBusMessage* msg)
-{
- DBusError err;
- dbus_error_init(&err);
-
- int uid;
-
- dbus_message_get_args(msg, &err,
- DBUS_TYPE_INT32, &uid,
- DBUS_TYPE_INVALID);
-
- SLOG(LOG_DEBUG, TAG_TTSD, ">>>>> TTSD NEXT SYNTHESIS");
-
- if (dbus_error_is_set(&err)) {
- SLOG(LOG_ERROR, TAG_TTSD, "[IN ERROR] ttsd 'start next synthesis' : Get arguments error (%s)\n", err.message);
- dbus_error_free(&err);
- } else {
- SLOG(LOG_DEBUG, TAG_TTSD, "[IN] ttsd 'start next synthesis' : uid(%d) \n", uid);
- int ret = ttsd_server_start_next_synthesis(uid);
- SLOG(LOG_DEBUG, TAG_TTSD, "[OUT] ttsd 'start next synthesis' : result(%d) \n", ret);
- }
-
- SLOG(LOG_DEBUG, TAG_TTSD, "<<<<<");
- SLOG(LOG_DEBUG, TAG_TTSD, " ");
-
- return 0;
-} \ No newline at end of file
diff --git a/server/ttsd_dbus_server.h b/server/ttsd_dbus_server.h
index f96bc4a..e876543 100644
--- a/server/ttsd_dbus_server.h
+++ b/server/ttsd_dbus_server.h
@@ -73,14 +73,6 @@ int ttsd_dbus_server_setting_get_engine_setting(DBusConnection* conn, DBusMessag
int ttsd_dbus_server_setting_set_engine_setting(DBusConnection* conn, DBusMessage* msg);
-/*
-* Dbus Server functions for tts daemon internal
-*/
-
-int ttsd_dbus_server_start_next_play(DBusMessage* msg);
-
-int ttsd_dbus_server_start_next_synthesis(DBusMessage* msg);
-
#ifdef __cplusplus
}
#endif
diff --git a/server/ttsd_engine_agent.c b/server/ttsd_engine_agent.c
index c7f9361..06bb623 100644
--- a/server/ttsd_engine_agent.c
+++ b/server/ttsd_engine_agent.c
@@ -120,17 +120,16 @@ int ttsd_engine_agent_init(synth_result_callback result_cb)
g_agent_init = true;
- if (0 != ttsd_config_get_char_type(CONFIG_KEY_DEFAULT_LANGUAGE, &(g_cur_engine.default_lang)) &&
- 0 != ttsd_config_get_int_type(CONFIG_KEY_DEFAULT_VOICE_TYPE, &(g_cur_engine.default_vctype)) ) {
- /* Set default voice */
+ if (0 != ttsd_config_get_default_voice(&(g_cur_engine.default_lang), &(g_cur_engine.default_vctype))) {
SLOG(LOG_WARN, TAG_TTSD, "[Server WARNING] There is No default voice in config\n");
+ /* Set default voice */
g_cur_engine.default_lang = strdup("en_US");
g_cur_engine.default_vctype = TTSP_VOICE_TYPE_FEMALE;
}
- if (0 != ttsd_config_get_int_type(CONFIG_KEY_DEFAULT_SPEED, &(g_cur_engine.default_speed))) {
+ if (0 != ttsd_config_get_default_speed(&(g_cur_engine.default_speed))) {
SLOG(LOG_WARN, TAG_TTSD, "[Server WARNING] There is No default speed in config\n");
- ttsd_config_set_int_type(CONFIG_KEY_DEFAULT_SPEED, TTSP_SPEED_NORMAL);
+ ttsd_config_set_default_speed((int)TTSP_SPEED_NORMAL);
g_cur_engine.default_speed = TTSP_SPEED_NORMAL;
}
@@ -169,15 +168,19 @@ int ttsd_engine_agent_release()
g_list_free(iter);
/* release current engine data */
- if( g_cur_engine.pefuncs != NULL)
+ if (g_cur_engine.pefuncs != NULL)
g_free(g_cur_engine.pefuncs);
- if( g_cur_engine.pdfuncs != NULL)
+ if (g_cur_engine.pdfuncs != NULL)
g_free(g_cur_engine.pdfuncs);
g_result_cb = NULL;
g_agent_init = false;
+ if (g_cur_engine.default_lang != NULL)
+ g_free(g_cur_engine.default_lang);
+
+
SLOG(LOG_DEBUG, TAG_TTSD, "[Engine Agent SUCCESS] Release Engine Agent\n");
return 0;
@@ -200,7 +203,7 @@ int ttsd_engine_agent_initialize_current_engine()
char* cur_engine_uuid = NULL;
bool is_get_engineid_from_config = false;
- if (0 != ttsd_config_get_char_type(CONFIG_KEY_DEFAULT_ENGINE_ID ,&cur_engine_uuid)) {
+ if (0 != ttsd_config_get_default_engine(&cur_engine_uuid)) {
/*not set current engine */
/*set system default engine*/
GList *iter = NULL;
@@ -273,7 +276,7 @@ int ttsd_engine_agent_initialize_current_engine()
}
if (false == is_get_engineid_from_config) {
- if (0 != ttsd_config_set_char_type(CONFIG_KEY_DEFAULT_ENGINE_ID ,cur_engine_uuid))
+ if (0 != ttsd_config_set_default_engine(cur_engine_uuid))
SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] fail to set id to config \n");
}
@@ -526,6 +529,11 @@ int __internal_set_current_engine(const char* engine_uuid)
if (g_cur_engine.engine_name != NULL) g_free(g_cur_engine.engine_name);
if (g_cur_engine.engine_path != NULL) g_free(g_cur_engine.engine_path);
+ if (NULL == data->engine_uuid || NULL == data->engine_name || NULL == data->engine_path) {
+ SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] __internal_set_current_engine : Engine data is NULL");
+ return TTSD_ERROR_OPERATION_FAILED;
+ }
+
g_cur_engine.engine_uuid = g_strdup(data->engine_uuid);
g_cur_engine.engine_name = g_strdup(data->engine_name);
g_cur_engine.engine_path = g_strdup(data->engine_path);
@@ -661,9 +669,8 @@ int ttsd_engine_agent_load_current_engine()
return TTSD_ERROR_OPERATION_FAILED;
}
- ttsd_config_set_char_type(CONFIG_KEY_DEFAULT_LANGUAGE, voice->language);
- ttsd_config_set_int_type(CONFIG_KEY_DEFAULT_VOICE_TYPE, voice->type);
-
+ ttsd_config_set_default_voice(voice->language, (int)voice->type);
+
g_cur_engine.default_lang = g_strdup(voice->language);
g_cur_engine.default_vctype = voice->type;
@@ -1100,10 +1107,9 @@ int ttsd_engine_get_default_voice( char** lang, ttsp_voice_type_e* vctype )
SLOG(LOG_ERROR, TAG_TTSD, "[Engine ERROR] Fail voice is NOT valid ");
return TTSD_ERROR_OPERATION_FAILED;
}
-
- ttsd_config_set_char_type(CONFIG_KEY_DEFAULT_LANGUAGE, voice->language);
- ttsd_config_set_int_type(CONFIG_KEY_DEFAULT_VOICE_TYPE, voice->type);
-
+
+ ttsd_config_set_default_voice(voice->language, (int)voice->type);
+
if (NULL != g_cur_engine.default_lang)
g_free(g_cur_engine.default_lang);
@@ -1228,8 +1234,9 @@ int ttsd_engine_setting_set_engine(const char* engine_id)
/* roll back to old current engine. */
__internal_set_current_engine(tmp_uuid);
-
- if( tmp_uuid != NULL )
+ ttsd_engine_agent_load_current_engine();
+
+ if (tmp_uuid != NULL)
free(tmp_uuid);
return TTSD_ERROR_OPERATION_FAILED;
@@ -1248,7 +1255,7 @@ int ttsd_engine_setting_set_engine(const char* engine_id)
}
/* save engine id to config */
- if (0 != ttsd_config_set_char_type(CONFIG_KEY_DEFAULT_ENGINE_ID, engine_id)) {
+ if (0 != ttsd_config_set_default_engine(engine_id)) {
SLOG(LOG_WARN, TAG_TTSD, "[Engine Agent WARNING] Fail to save engine id to config \n");
}
@@ -1348,15 +1355,10 @@ int ttsd_engine_setting_set_default_voice(const char* language, ttsp_voice_type_
g_cur_engine.default_lang = strdup(language);
g_cur_engine.default_vctype = vctype;
- ret = ttsd_config_set_char_type(CONFIG_KEY_DEFAULT_LANGUAGE, language);
+ ret = ttsd_config_set_default_voice(language, (int)vctype);
if (0 == ret) {
- ret = ttsd_config_set_int_type(CONFIG_KEY_DEFAULT_VOICE_TYPE, vctype);
- if (0 != ret) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] fail to write default voice to config (%d) \n", ret);
- } else {
- SLOG(LOG_DEBUG, TAG_TTSD, "[Engine Agent SUCCESS] Set default voice : lang(%s), type(%d) \n",
+ SLOG(LOG_DEBUG, TAG_TTSD, "[Engine Agent SUCCESS] Set default voice : lang(%s), type(%d) \n",
g_cur_engine.default_lang, g_cur_engine.default_vctype);
- }
} else {
SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] fail to write default voice to config (%d) \n", ret);
}
@@ -1396,7 +1398,7 @@ int ttsd_engine_setting_set_default_speed(const ttsp_speed_e speed)
g_cur_engine.default_speed = speed;
- if (0 != ttsd_config_set_int_type(CONFIG_KEY_DEFAULT_SPEED, speed)) {
+ if (0 != ttsd_config_set_default_speed(speed)) {
SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] fail to set default speed to config");
}
diff --git a/server/ttsd_main.c b/server/ttsd_main.c
index 6411921..1930eaf 100644
--- a/server/ttsd_main.c
+++ b/server/ttsd_main.c
@@ -19,6 +19,8 @@
#include <Ecore.h>
+#define CLIENT_CLEAN_UP_TIME 500
+
/* Main of TTS Daemon */
int main()
{
@@ -47,6 +49,8 @@ int main()
return EXIT_FAILURE;
}
+ ecore_timer_add(CLIENT_CLEAN_UP_TIME, ttsd_cleanup_client, NULL);
+
SLOG(LOG_DEBUG, TAG_TTSD, "[Main] tts-daemon start...\n");
SLOG(LOG_DEBUG, TAG_TTSD, "=====");
SLOG(LOG_DEBUG, TAG_TTSD, " ");
diff --git a/server/ttsd_main.h b/server/ttsd_main.h
index 78becd1..8933868 100644
--- a/server/ttsd_main.h
+++ b/server/ttsd_main.h
@@ -34,9 +34,11 @@ extern "C" {
/* TTS Daemon Define */
#define TAG_TTSD "ttsd"
+#define BASE_DIRECTORY_DEFAULT "/usr/lib/voice/tts/1.0/"
#define ENGINE_DIRECTORY_DEFAULT "/usr/lib/voice/tts/1.0/engine"
#define ENGINE_DIRECTORY_DEFAULT_SETTING "/usr/lib/voice/tts/1.0/setting"
+#define BASE_DIRECTORY_DOWNLOAD "/opt/apps/voice/tts/1.0/"
#define ENGINE_DIRECTORY_DOWNLOAD "/opt/apps/voice/tts/1.0/engine"
#define ENGINE_DIRECTORY_DOWNLOAD_SETTING "/opt/apps/voice/tts/1.0/setting"
diff --git a/server/ttsd_network.c b/server/ttsd_network.c
index ae46d1f..f9b8a75 100644
--- a/server/ttsd_network.c
+++ b/server/ttsd_network.c
@@ -58,7 +58,6 @@ int ttsd_network_initialize()
vconf_get_int(VCONFKEY_NETWORK_STATUS, &network_status);
if(network_status == VCONFKEY_NETWORK_OFF){
- printf("Current network connection is OFF!! \n");
SLOG(LOG_DEBUG, TAG_TTSD, "[Network] Current network connection is OFF.");
}
else{
@@ -66,14 +65,13 @@ int ttsd_network_initialize()
* This is the problem of network connection
* Just terminate the application, network f/w will fix the problem automatically.
*/
- printf("network status is wrong or IP is not set\n");
- printf("network has problem, try again\n");
+ SLOG(LOG_WARN, TAG_TTSD, "network status is wrong or IP is not set\n");
+ SLOG(LOG_WARN, TAG_TTSD, "network has problem, try again\n");
return -1;
}
g_is_connected = false;
} else {
- printf("Current network connection is ON. \n");
SLOG(LOG_DEBUG, TAG_TTSD, "[Network] Current network connection is ON.");
g_is_connected = true;
diff --git a/server/ttsd_player.cpp b/server/ttsd_player.cpp
index 01bafd1..b7a4edf 100644
--- a/server/ttsd_player.cpp
+++ b/server/ttsd_player.cpp
@@ -15,6 +15,7 @@
#include <mm_types.h>
#include <mm_player.h>
#include <mm_error.h>
+#include <Ecore.h>
#include "ttsd_main.h"
#include "ttsd_player.h"
@@ -199,12 +200,6 @@ int ttsd_player_destroy_instance(int uid)
switch (player_state) {
case MM_PLAYER_STATE_PLAYING:
case MM_PLAYER_STATE_PAUSED:
- ret = mm_player_stop(current->player_handle);
- if (MM_ERROR_NONE != ret) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Player WARNING] fail mm_player_stop() : %x", ret);
- }
- /* NO break for unrealize */
-
case MM_PLAYER_STATE_READY:
ret = mm_player_unrealize(current->player_handle);
if (MM_ERROR_NONE != ret) {
@@ -213,13 +208,16 @@ int ttsd_player_destroy_instance(int uid)
/* NO break for destroy */
case MM_PLAYER_STATE_NULL:
- mm_player_destroy(current->player_handle);
+ ret = mm_player_destroy(current->player_handle);
+ if (MM_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] fail mm_player_destroy() : %x", ret);
+ }
break;
default:
break;
}
-
+
GList *iter = NULL;
player_s *data = NULL;
@@ -245,6 +243,8 @@ int ttsd_player_destroy_instance(int uid)
}
}
+ SLOG(LOG_DEBUG, TAG_TTSD, "[PLAYER Success] Destroy instance");
+
return 0;
}
@@ -340,7 +340,7 @@ int ttsd_player_next_play(int uid)
return 0;
}
} else {
- SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] Current player do NOT exist");
+ SLOG(LOG_WARN, TAG_TTSD, "[Player WARNING] Current player do NOT exist");
return -1;
}
@@ -354,12 +354,6 @@ int ttsd_player_next_play(int uid)
switch (player_state) {
case MM_PLAYER_STATE_PLAYING:
case MM_PLAYER_STATE_PAUSED:
- ret = mm_player_stop(current->player_handle);
- if (MM_ERROR_NONE != ret) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Player WARNING] fail mm_player_stop() : %x", ret);
- }
- /* NO break for unrealize */
-
case MM_PLAYER_STATE_READY:
ret = mm_player_unrealize(current->player_handle);
if (MM_ERROR_NONE != ret) {
@@ -431,12 +425,6 @@ int ttsd_player_stop(const int uid)
switch (player_state) {
case MM_PLAYER_STATE_PLAYING:
case MM_PLAYER_STATE_PAUSED:
- ret = mm_player_stop(current->player_handle);
- if (MM_ERROR_NONE != ret) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Player WARNING] fail mm_player_stop() : %x", ret);
- }
- /* NO break for unrealize */
-
case MM_PLAYER_STATE_READY:
ret = mm_player_unrealize(current->player_handle);
if (MM_ERROR_NONE != ret) {
@@ -536,6 +524,8 @@ int ttsd_player_resume(const int uid)
if (MM_ERROR_NONE != ret) {
SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] fail mm_player_resume() : %d", ret);
return -1;
+ } else {
+ SLOG(LOG_DEBUG, TAG_TTSD, "[Player] Resume player");
}
g_playing_info = current;
@@ -611,11 +601,6 @@ int ttsd_player_all_stop()
}
if (APP_STATE_PLAYING == state || APP_STATE_PAUSED == state) {
- ret = mm_player_stop(data->player_handle);
- if (MM_ERROR_NONE != ret) {
- SLOG(LOG_WARN, TAG_TTSD, "[player WARNING] fail mm_player_stop() : %x ", ret);
- }
-
/* unrealize player */
ret = mm_player_unrealize(data->player_handle);
if (MM_ERROR_NONE != ret) {
@@ -636,6 +621,27 @@ int ttsd_player_all_stop()
return 0;
}
+static Eina_Bool __player_next_play(void *data)
+{
+ SLOG(LOG_DEBUG, TAG_TTSD, "===== PLAYER NEXT PLAY");
+
+ int* uid = (int*)data;
+
+ SLOG(LOG_DEBUG, TAG_TTSD, "[PLAYER] uid = %d", *uid);
+
+ if (0 != ttsd_player_next_play(*uid)) {
+ SLOG(LOG_WARN, TAG_TTSD, "[PLAYER WARNING] Fail to play next");
+ }
+
+ if (NULL != uid)
+ free(uid);
+
+ SLOG(LOG_DEBUG, TAG_TTSD, "=====");
+ SLOG(LOG_DEBUG, TAG_TTSD, " ");
+
+ return EINA_FALSE;
+}
+
static int msg_callback(int message, void *data, void *user_param)
{
user_data_s* user_data;
@@ -769,7 +775,12 @@ static int msg_callback(int message, void *data, void *user_param)
SLOG(LOG_ERROR, TAG_TTSD, "[Send ERROR] Fail to send Utterance Completed Signal : pid(%d), uid(%d), uttid(%d)", pid, uid, utt_id);
}
- ttsd_send_start_next_play_message(uid);
+ int* uid_data = (int*) g_malloc0(sizeof(int));
+ *uid_data = uid;
+
+ SLOG(LOG_DEBUG, TAG_TTSD, "[PLAYER] uid = %d", *uid_data);
+
+ ecore_timer_add(0, __player_next_play, (void*)uid_data);
SLOG(LOG_DEBUG, TAG_TTSD, "=====");
SLOG(LOG_DEBUG, TAG_TTSD, " ");
diff --git a/server/ttsd_server.cpp b/server/ttsd_server.cpp
index 60ae8ec..3bf737d 100644
--- a/server/ttsd_server.cpp
+++ b/server/ttsd_server.cpp
@@ -11,7 +11,7 @@
* limitations under the License.
*/
-
+#include <Ecore.h>
#include "ttsd_main.h"
#include "ttsd_player.h"
#include "ttsd_data.h"
@@ -30,10 +30,18 @@ typedef struct {
} utterance_t;
/* If current engine exist */
-static bool g_is_engine;
+static bool g_is_engine;
/* If engine is running */
-static bool g_is_synthesizing;
+static bool g_is_synthesizing;
+
+/* If the daemon get the result */
+Ecore_Timer* g_timer;
+static bool g_is_next_synthesis;
+
+/* Function definitions */
+int __server_next_synthesis(int uid);
+
int __server_set_is_synthesizing(bool flag)
{
@@ -58,38 +66,20 @@ int __server_send_error(int uid, int utt_id, int error_code)
return 0;
}
-int __server_interrupt_client(int org_uid)
-{
- int pid = ttsd_data_get_pid(org_uid);
-
- /* pause player */
- if (0 != ttsd_player_pause(org_uid)) {
- SLOG(LOG_WARN, TAG_TTSD, "[Server ERROR] fail to ttsd_player_pause() : uid (%d)\n", org_uid);
- }
-
- /* send message to client about changing state */
- ttsdc_send_interrupt_message (pid, org_uid, TTSD_INTERRUPTED_PAUSED);
-
- /* change state */
- ttsd_data_set_client_state(org_uid, APP_STATE_PAUSED);
-
- return 0;
-}
-
-int __server_start_synthesis(int uid)
+int __server_start_synthesis(int uid, int mode)
{
int result = 0;
/* check if tts-engine is running */
if (true == __server_get_current_synthesis()) {
- SLOG(LOG_DEBUG, TAG_TTSD, "[Server] TTS-engine is running \n");
+ SLOG(LOG_DEBUG, TAG_TTSD, "[Server] TTS-engine is running ");
} else {
speak_data_s sdata;
if (0 == ttsd_data_get_speak_data(uid, &sdata)) {
utterance_t* utt = (utterance_t*)g_malloc0(sizeof(utterance_t));
if (NULL == utt) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Out of memory : utterance \n");
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Out of memory : utterance ");
return TTSD_ERROR_OUT_OF_MEMORY;
}
@@ -104,7 +94,7 @@ int __server_start_synthesis(int uid)
__server_set_is_synthesizing(true);
int ret = 0;
- ret = ttsd_engine_start_synthesis( sdata.lang, sdata.vctype, sdata.text, sdata.speed, (void*)utt);
+ ret = ttsd_engine_start_synthesis(sdata.lang, sdata.vctype, sdata.text, sdata.speed, (void*)utt);
if (0 != ret) {
SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] * FAIL to start SYNTHESIS !!!! * ");
@@ -113,6 +103,14 @@ int __server_start_synthesis(int uid)
result = TTSD_ERROR_OPERATION_FAILED;
g_free(utt);
+
+ if (2 == mode) {
+ __server_send_error(uid, sdata.utt_id, TTSD_ERROR_OPERATION_FAILED);
+ ttsd_server_stop(uid);
+
+ int pid = ttsd_data_get_pid(uid);
+ ttsdc_send_set_state_message(pid, uid, APP_STATE_READY);
+ }
} else {
SLOG(LOG_DEBUG, TAG_TTSD, "[Server] SUCCESS to start synthesis");
}
@@ -142,16 +140,17 @@ int __server_play_internal(int uid, app_state_e state)
/* resume player and start speech synthesis */
if (0 != ttsd_player_resume(uid)) {
- SLOG(LOG_WARN, TAG_TTSD, "[Server WARNING] fail to ttsd_player_resume() \n");
+ SLOG(LOG_WARN, TAG_TTSD, "[Server WARNING] fail to ttsd_player_resume()");
}
- ret = __server_start_synthesis(uid);
+ /* mode 1 for play */
+ ret = __server_start_synthesis(uid, 1);
} else if(APP_STATE_READY == state) {
-
SLOG(LOG_DEBUG, TAG_TTSD, "[Server] uid(%d) is 'Ready' state : Next step is start synthesis ", uid);
-
- ret = __server_start_synthesis(uid);
+
+ /* mode 1 for play */
+ ret = __server_start_synthesis(uid, 1);
} else {
/* NO this case */
}
@@ -174,7 +173,7 @@ int __server_next_synthesis(int uid)
}
if (true == __server_get_current_synthesis()) {
- SLOG(LOG_WARN, TAG_TTSD, "[Server WARNING] Engine has already been running. \n");
+ SLOG(LOG_WARN, TAG_TTSD, "[Server WARNING] Engine has already been running. ");
SLOG(LOG_DEBUG, TAG_TTSD, "=====");
SLOG(LOG_DEBUG, TAG_TTSD, " ");
return 0;
@@ -187,7 +186,7 @@ int __server_next_synthesis(int uid)
utterance_t* utt = (utterance_t*)g_malloc0(sizeof(utterance_t));
if (NULL == utt) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] fail to allocate memory : utterance \n");
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] fail to allocate memory : utterance ");
__server_send_error(current_uid, sdata.utt_id, TTSD_ERROR_OUT_OF_MEMORY);
return TTSD_ERROR_OUT_OF_MEMORY;
@@ -214,6 +213,11 @@ int __server_next_synthesis(int uid)
__server_send_error(current_uid, sdata.utt_id, TTSD_ERROR_OPERATION_FAILED);
g_free(utt);
+
+ ttsd_server_stop(current_uid);
+
+ int pid = ttsd_data_get_pid(current_uid);
+ ttsdc_send_set_state_message(pid, current_uid, APP_STATE_READY);
}
if(sdata.text != NULL)
@@ -221,7 +225,7 @@ int __server_next_synthesis(int uid)
}
if (0 != ttsd_player_play(current_uid)) {
- SLOG(LOG_WARN, TAG_TTSD, "[Server WARNING] __synthesis_result_callback : fail ttsd_player_play() \n");
+ SLOG(LOG_WARN, TAG_TTSD, "[Server WARNING] __synthesis_result_callback : fail ttsd_player_play() ");
} else {
/* success playing */
SLOG(LOG_DEBUG, TAG_TTSD, "[Server] Success to start player");
@@ -245,13 +249,13 @@ int __player_result_callback(player_event_e event, int uid, int utt_id)
if (false == __server_get_current_synthesis()) {
/* check text queue is empty */
if (0 == ttsd_data_get_speak_data_size(uid) && 0 == ttsd_data_get_sound_data_size(uid)) {
- SLOG(LOG_DEBUG, TAG_TTSD, "[SERVER Callback] all play completed \n");
+ SLOG(LOG_DEBUG, TAG_TTSD, "[SERVER Callback] all play completed ");
}
}
break;
case PLAYER_ERROR:
- SLOG(LOG_ERROR, TAG_TTSD, "[SERVER Callback ERROR] callback : player error \n");
+ SLOG(LOG_ERROR, TAG_TTSD, "[SERVER Callback ERROR] callback : player error ");
__server_send_error(uid, utt_id, TTSD_ERROR_OPERATION_FAILED);
break;
@@ -263,9 +267,29 @@ int __player_result_callback(player_event_e event, int uid, int utt_id)
return 0;
}
+Eina_Bool __start_next_synthesis(void *data)
+{
+ /* get current play */
+ int uid = ttsd_data_is_current_playing();
+
+ if (uid < 0)
+ return EINA_FALSE;
+
+ if (true == g_is_next_synthesis) {
+ SLOG(LOG_DEBUG, TAG_TTSD, "===== NEXT SYNTHESIS START");
+ __server_next_synthesis(uid);
+ SLOG(LOG_DEBUG, TAG_TTSD, "===== ");
+ SLOG(LOG_DEBUG, TAG_TTSD, " ");
+
+ g_is_next_synthesis = false;
+ }
+
+ return EINA_TRUE;
+}
+
int __synthesis_result_callback(ttsp_result_event_e event, const void* data, unsigned int data_size, void *user_data)
{
- SLOG(LOG_DEBUG, TAG_TTSD, "===== SYNTHESIS RESULT CALLBACK");
+ SLOG(LOG_DEBUG, TAG_TTSD, "===== SYNTHESIS RESULT CALLBACK START");
utterance_t* utt_get_param;
utt_get_param = (utterance_t*)user_data;
@@ -274,7 +298,7 @@ int __synthesis_result_callback(ttsp_result_event_e event, const void* data, uns
int uttid = utt_get_param->uttid;
if (NULL == utt_get_param) {
- SLOG(LOG_ERROR, TAG_TTSD, "[SERVER ERROR] User data is NULL \n" );
+ SLOG(LOG_ERROR, TAG_TTSD, "[SERVER ERROR] User data is NULL " );
SLOG(LOG_DEBUG, TAG_TTSD, "=====");
SLOG(LOG_DEBUG, TAG_TTSD, " ");
return -1;
@@ -288,7 +312,7 @@ int __synthesis_result_callback(ttsp_result_event_e event, const void* data, uns
if (TTSP_RESULT_EVENT_FINISH == event) SLOG(LOG_DEBUG, TAG_TTSD, "[SERVER] Event : TTSP_RESULT_EVENT_FINISH");
if (false == ttsd_data_is_uttid_valid(uid, uttid)) {
- SLOG(LOG_ERROR, TAG_TTSD, "[SERVER ERROR] uttid is NOT valid !!!! \n" );
+ SLOG(LOG_ERROR, TAG_TTSD, "[SERVER ERROR] uttid is NOT valid !!!! " );
SLOG(LOG_DEBUG, TAG_TTSD, "=====");
SLOG(LOG_DEBUG, TAG_TTSD, " ");
@@ -296,7 +320,7 @@ int __synthesis_result_callback(ttsp_result_event_e event, const void* data, uns
}
- SLOG(LOG_DEBUG, TAG_TTSD, "[SERVER] Result Info : uid(%d), utt(%d), data(%p), data size(%d) \n",
+ SLOG(LOG_DEBUG, TAG_TTSD, "[SERVER] Result Info : uid(%d), utt(%d), data(%p), data size(%d) ",
uid, uttid, data, data_size);
/* add wav data */
@@ -324,16 +348,13 @@ int __synthesis_result_callback(ttsp_result_event_e event, const void* data, uns
temp_data.channels = channels;
if (0 != ttsd_data_add_sound_data(uid, temp_data)) {
- SLOG(LOG_ERROR, TAG_TTSD, "[SERVER ERROR] Fail to add sound data : uid(%d)\n", utt_get_param->uid);
+ SLOG(LOG_ERROR, TAG_TTSD, "[SERVER ERROR] Fail to add sound data : uid(%d)", utt_get_param->uid);
}
if (event == TTSP_RESULT_EVENT_FINISH) {
__server_set_is_synthesizing(false);
-
- if (0 != ttsd_send_start_next_synthesis_message(uid)) {
- /* critical error */
- SLOG(LOG_ERROR, TAG_TTSD, "[SERVER ERROR] IPC ERROR FOR NEXT SYNTHESIS \n");
- }
+
+ g_is_next_synthesis = true;
}
}
@@ -341,20 +362,15 @@ int __synthesis_result_callback(ttsp_result_event_e event, const void* data, uns
SLOG(LOG_DEBUG, TAG_TTSD, "[SERVER] Event : TTSP_RESULT_EVENT_CANCEL");
__server_set_is_synthesizing(false);
- if (0 != ttsd_send_start_next_synthesis_message(uid)) {
- /* critical error */
- SLOG(LOG_ERROR, TAG_TTSD, "[SERVER ERROR] IPC ERROR FOR NEXT SYNTHESIS \n");
- }
+ g_is_next_synthesis = true;
}
else {
- SLOG(LOG_DEBUG, TAG_TTSD, "[SERVER] Event : TTSP_RESULT_EVENT_CANCEL");
+ SLOG(LOG_DEBUG, TAG_TTSD, "[SERVER] Event : etc");
__server_set_is_synthesizing(false);
- if (0 != ttsd_send_start_next_synthesis_message(uid)) {
- /* critical error */
- SLOG(LOG_ERROR, TAG_TTSD, "[SERVER ERROR] IPC ERROR FOR NEXT SYNTHESIS \n");
- }
+
+ g_is_next_synthesis = true;
}
if (TTSP_RESULT_EVENT_FINISH == event || TTSP_RESULT_EVENT_CANCEL == event || TTSP_RESULT_EVENT_FAIL == event) {
@@ -362,7 +378,7 @@ int __synthesis_result_callback(ttsp_result_event_e event, const void* data, uns
free(utt_get_param);
}
- SLOG(LOG_DEBUG, TAG_TTSD, "=====");
+ SLOG(LOG_DEBUG, TAG_TTSD, "===== SYNTHESIS RESULT CALLBACK END");
SLOG(LOG_DEBUG, TAG_TTSD, " ");
return 0;
@@ -374,29 +390,62 @@ int __synthesis_result_callback(ttsp_result_event_e event, const void* data, uns
int ttsd_initialize()
{
+ if (ttsd_config_initialize()) {
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server WARNING] Fail to initialize config.");
+ }
+
/* player init */
if (ttsd_player_init(__player_result_callback)) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Fail to initialize player init \n");
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Fail to initialize player init.");
return TTSD_ERROR_OPERATION_FAILED;
}
/* Engine Agent initialize */
if (0 != ttsd_engine_agent_init(__synthesis_result_callback)) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Fail to engine agent initialize \n");
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Fail to engine agent initialize.");
return TTSD_ERROR_OPERATION_FAILED;
}
/* set current engine */
if (0 != ttsd_engine_agent_initialize_current_engine()) {
- SLOG(LOG_WARN, TAG_TTSD, "[Server WARNING] No Engine !!! \n" );
+ SLOG(LOG_WARN, TAG_TTSD, "[Server WARNING] No Engine !!!" );
g_is_engine = false;
} else
g_is_engine = true;
+ g_timer = NULL;
+
return TTSD_ERROR_NONE;
}
+bool __get_client_for_clean_up(int pid, int uid, app_state_e state, void* user_data)
+{
+ int result = 1;
+
+ result = ttsdc_send_hello(pid, uid);
+
+ if (0 == result) {
+ SLOG(LOG_DEBUG, TAG_TTSD, "[Server] uid(%d) should be removed.", uid);
+ ttsd_server_finalize(uid);
+ } else if (-1 == result) {
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Hello result has error");
+ }
+
+ return true;
+}
+
+
+Eina_Bool ttsd_cleanup_client(void *data)
+{
+ SLOG(LOG_DEBUG, TAG_TTSD, "===== CLEAN UP CLIENT START");
+ ttsd_data_foreach_clients(__get_client_for_clean_up, NULL);
+ SLOG(LOG_DEBUG, TAG_TTSD, "=====");
+ SLOG(LOG_DEBUG, TAG_TTSD, " ");
+
+ return EINA_TRUE;
+}
+
/*
* TTS Server Functions for Client
*/
@@ -405,7 +454,7 @@ int ttsd_server_initialize(int pid, int uid)
{
if (false == g_is_engine) {
if (0 != ttsd_engine_agent_initialize_current_engine()) {
- SLOG(LOG_WARN, TAG_TTSD, "[Server WARNING] No Engine !!! \n" );
+ SLOG(LOG_WARN, TAG_TTSD, "[Server WARNING] No Engine !!! " );
g_is_engine = false;
return TTSD_ERROR_ENGINE_NOT_FOUND;
@@ -415,24 +464,24 @@ int ttsd_server_initialize(int pid, int uid)
}
if (-1 != ttsd_data_is_client(uid)) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Uid has already been registered \n");
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Uid has already been registered ");
return TTSD_ERROR_INVALID_PARAMETER;
}
if (0 == ttsd_data_get_client_count()) {
if (0 != ttsd_engine_agent_load_current_engine()) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Fail to load current engine \n");
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Fail to load current engine ");
return TTSD_ERROR_OPERATION_FAILED;
}
}
if (0 != ttsd_data_new_client(pid, uid)) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Fail to add client info \n");
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Fail to add client info ");
return TTSD_ERROR_OPERATION_FAILED;
}
if (0 != ttsd_player_create_instance(uid)) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Fail to create player \n");
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Fail to create player ");
return TTSD_ERROR_OPERATION_FAILED;
}
@@ -444,7 +493,7 @@ int ttsd_server_finalize(int uid)
{
app_state_e state;
if (0 > ttsd_data_get_client_state(uid, &state)) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] ttsd_server_finalize : uid is not valid \n");
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] ttsd_server_finalize : uid is not valid ");
return TTSD_ERROR_INVALID_PARAMETER;
}
@@ -457,9 +506,9 @@ int ttsd_server_finalize(int uid)
/* unload engine, if ref count of client is 0 */
if (0 == ttsd_data_get_client_count()) {
if (0 != ttsd_engine_agent_unload_current_engine()) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] fail to unload current engine \n");
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] fail to unload current engine ");
} else {
- SLOG(LOG_DEBUG, TAG_TTSD, "[Server SUCCESS] unload current engine \n");
+ SLOG(LOG_DEBUG, TAG_TTSD, "[Server SUCCESS] unload current engine ");
}
}
@@ -470,7 +519,7 @@ int ttsd_server_add_queue(int uid, const char* text, const char* lang, int voice
{
app_state_e state;
if (0 > ttsd_data_get_client_state(uid, &state)) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] ttsd_server_add_queue : uid is not valid \n");
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] ttsd_server_add_queue : uid is not valid ");
return TTSD_ERROR_INVALID_PARAMETER;
}
@@ -478,7 +527,7 @@ int ttsd_server_add_queue(int uid, const char* text, const char* lang, int voice
char* temp_lang = NULL;
ttsp_voice_type_e temp_type;
if (true != ttsd_engine_select_valid_voice((const char*)lang, (const ttsp_voice_type_e)voice_type, &temp_lang, &temp_type)) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Fail to select valid voice \n");
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Fail to select valid voice ");
return TTSD_ERROR_INVALID_VOICE;
} else {
if (NULL == temp_lang)
@@ -497,7 +546,7 @@ int ttsd_server_add_queue(int uid, const char* text, const char* lang, int voice
/* if state is APP_STATE_READY , APP_STATE_PAUSED , only need to add speak data to queue*/
if (0 != ttsd_data_add_speak_data(uid, data)) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] ttsd_server_add_queue : Current state of uid is not 'ready' \n");
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] ttsd_server_add_queue : Current state of uid is not 'ready' ");
return TTSD_ERROR_OPERATION_FAILED;
}
@@ -505,13 +554,14 @@ int ttsd_server_add_queue(int uid, const char* text, const char* lang, int voice
/* check if engine use network */
if (ttsd_engine_agent_need_network()) {
if (false == ttsd_network_is_connected()) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Disconnect network. Current engine needs network.\n");
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Disconnect network. Current engine needs network.");
return TTSD_ERROR_OPERATION_FAILED;
}
}
- if (0 != __server_start_synthesis(uid)) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] fail to schedule synthesis : uid(%d)\n", uid);
+ /* mode 2 for add text */
+ if (0 != __server_start_synthesis(uid, 2)) {
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] fail to schedule synthesis : uid(%d)", uid);
return TTSD_ERROR_OPERATION_FAILED;
}
}
@@ -519,23 +569,36 @@ int ttsd_server_add_queue(int uid, const char* text, const char* lang, int voice
return TTSD_ERROR_NONE;
}
+Eina_Bool __send_interrupt_client(void *data)
+{
+ int* uid = (int*)data;
+
+ if (NULL != uid) {
+ int pid = ttsd_data_get_pid(*uid);
+ /* send message to client about changing state */
+ ttsdc_send_set_state_message (pid, *uid, APP_STATE_PAUSED);
+ free(uid);
+ }
+ return EINA_FALSE;
+}
+
int ttsd_server_play(int uid)
{
app_state_e state;
if (0 > ttsd_data_get_client_state(uid, &state)) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] uid(%d) is NOT valid \n", uid);
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] uid(%d) is NOT valid ", uid);
return TTSD_ERROR_INVALID_PARAMETER;
}
if (APP_STATE_PLAYING == state) {
- SLOG(LOG_WARN, TAG_TTSD, "[Server WARNING] Current state(%d) is 'play' \n", uid);
+ SLOG(LOG_WARN, TAG_TTSD, "[Server WARNING] Current state(%d) is 'play' ", uid);
return TTSD_ERROR_NONE;
}
/* check if engine use network */
if (ttsd_engine_agent_need_network()) {
if (false == ttsd_network_is_connected()) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Disconnect network. Current engine needs network service!!!.\n");
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Disconnect network. Current engine needs network service!!!.");
return TTSD_ERROR_OUT_OF_NETWORK;
}
}
@@ -544,21 +607,35 @@ int ttsd_server_play(int uid)
if (uid != current_uid && -1 != current_uid) {
/* Send interrupt message */
- SLOG(LOG_DEBUG, TAG_TTSD, "[Server] Old uid(%d) will be interrupted into 'Pause' state \n", current_uid);
- __server_interrupt_client(current_uid);
+ SLOG(LOG_DEBUG, TAG_TTSD, "[Server] Old uid(%d) will be interrupted into 'Pause' state ", current_uid);
+
+ /* pause player */
+ if (0 != ttsd_player_pause(current_uid)) {
+ SLOG(LOG_WARN, TAG_TTSD, "[Server ERROR] fail to ttsd_player_pause() : uid (%d)", current_uid);
+ }
+
+ /* change state */
+ ttsd_data_set_client_state(current_uid, APP_STATE_PAUSED);
+
+ int* temp_uid = (int*)malloc(sizeof(int));
+ *temp_uid = current_uid;
+ ecore_timer_add(0, __send_interrupt_client, temp_uid);
}
/* Change current play */
if (0 != ttsd_data_set_client_state(uid, APP_STATE_PLAYING)) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Fail to set state : uid(%d)\n", uid);
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Fail to set state : uid(%d)", uid);
return TTSD_ERROR_OPERATION_FAILED;
}
if (0 != __server_play_internal(uid, state)) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Fail to start synthesis : uid(%d)\n", uid);
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Fail to start synthesis : uid(%d)", uid);
return TTSD_ERROR_OPERATION_FAILED;
}
+ if (NULL == g_timer)
+ ecore_timer_add(0, __start_next_synthesis, NULL);
+
return TTSD_ERROR_NONE;
}
@@ -567,7 +644,7 @@ int ttsd_server_stop(int uid)
{
app_state_e state;
if (0 > ttsd_data_get_client_state(uid, &state)) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] uid is not valid \n");
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] uid is not valid ");
return TTSD_ERROR_INVALID_PARAMETER;
}
@@ -578,10 +655,10 @@ int ttsd_server_stop(int uid)
ttsd_data_set_client_state(uid, APP_STATE_READY);
if (0 != ttsd_player_stop(uid))
- SLOG(LOG_WARN, TAG_TTSD, "[Server] Fail to ttsd_player_stop()\n");
+ SLOG(LOG_WARN, TAG_TTSD, "[Server] Fail to ttsd_player_stop()");
if (true == __server_get_current_synthesis()) {
- SLOG(LOG_DEBUG, TAG_TTSD, "[Server] TTS-engine is running \n");
+ SLOG(LOG_DEBUG, TAG_TTSD, "[Server] TTS-engine is running ");
int ret = 0;
ret = ttsd_engine_cancel_synthesis();
@@ -591,7 +668,7 @@ int ttsd_server_stop(int uid)
__server_set_is_synthesizing(false);
}
} else {
- SLOG(LOG_WARN, TAG_TTSD, "[Server WARNING] Current state is 'ready' \n");
+ SLOG(LOG_WARN, TAG_TTSD, "[Server WARNING] Current state is 'ready' ");
}
return TTSD_ERROR_NONE;
@@ -601,19 +678,19 @@ int ttsd_server_pause(int uid, int* utt_id)
{
app_state_e state;
if (0 > ttsd_data_get_client_state(uid, &state)) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] ttsd_server_pause : uid is not valid \n");
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] ttsd_server_pause : uid is not valid ");
return TTSD_ERROR_INVALID_PARAMETER;
}
if (APP_STATE_PLAYING != state) {
- SLOG(LOG_WARN, TAG_TTSD, "[Server WARNING] Current state is not 'play' \n");
+ SLOG(LOG_WARN, TAG_TTSD, "[Server WARNING] Current state is not 'play' ");
return TTSD_ERROR_INVALID_STATE;
}
int ret = 0;
ret = ttsd_player_pause(uid);
if (0 != ret) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] fail player_pause() : ret(%d)\n", ret);
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] fail player_pause() : ret(%d)", ret);
return TTSD_ERROR_OPERATION_FAILED;
}
@@ -626,17 +703,17 @@ int ttsd_server_get_support_voices(int uid, GList** voice_list)
{
app_state_e state;
if (0 > ttsd_data_get_client_state(uid, &state)) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] uid is not valid \n");
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] uid is not valid ");
return TTSD_ERROR_INVALID_PARAMETER;
}
/* get voice list*/
if (0 != ttsd_engine_get_voice_list(voice_list)) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Fail ttsd_server_get_support_voices() \n");
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Fail ttsd_server_get_support_voices() ");
return TTSD_ERROR_OPERATION_FAILED;
}
- SLOG(LOG_DEBUG, TAG_TTSD, "[Server SUCCESS] Get supported voices \n");
+ SLOG(LOG_DEBUG, TAG_TTSD, "[Server SUCCESS] Get supported voices ");
return TTSD_ERROR_NONE;
}
@@ -645,18 +722,18 @@ int ttsd_server_get_current_voice(int uid, char** language, int* voice_type)
{
app_state_e state;
if (0 > ttsd_data_get_client_state(uid, &state)) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] ttsd_server_get_current_voice : uid is not valid \n");
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] ttsd_server_get_current_voice : uid is not valid ");
return TTSD_ERROR_INVALID_PARAMETER;
}
/* get current voice */
int ret = ttsd_engine_get_default_voice(language, (ttsp_voice_type_e*)voice_type);
if (0 != ret) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] fail ttsd_server_get_support_voices() \n");
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] fail ttsd_server_get_support_voices() ");
return ret;
}
- SLOG(LOG_DEBUG, TAG_TTSD, "[Server] Get default language (%s), voice type(%d) \n", *language, *voice_type);
+ SLOG(LOG_DEBUG, TAG_TTSD, "[Server] Get default language (%s), voice type(%d) ", *language, *voice_type);
return TTSD_ERROR_NONE;
}
@@ -670,7 +747,7 @@ int ttsd_server_setting_initialize(int uid)
{
if (false == g_is_engine) {
if (0 != ttsd_engine_agent_initialize_current_engine()) {
- SLOG(LOG_WARN, TAG_TTSD, "[Server Setting WARNING] No Engine !!! \n" );
+ SLOG(LOG_WARN, TAG_TTSD, "[Server Setting WARNING] No Engine !!! " );
g_is_engine = false;
return TTSD_ERROR_ENGINE_NOT_FOUND;
} else {
@@ -678,21 +755,21 @@ int ttsd_server_setting_initialize(int uid)
}
}
- if (-1 != ttsd_data_is_client(uid)) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] pid has already been registered \n");
+ if (-1 != ttsd_setting_data_is_setting(uid)) {
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] pid has already been registered ");
return TTSD_ERROR_INVALID_PARAMETER;
}
if (0 == ttsd_data_get_client_count()) {
if( 0 != ttsd_engine_agent_load_current_engine() ) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] Fail to load current engine \n");
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] Fail to load current engine ");
return TTSD_ERROR_OPERATION_FAILED;
}
}
/* register pid */
- if (0 != ttsd_data_new_client(uid, uid)) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] Fail to add client info \n");
+ if (0 != ttsd_setting_data_add(uid)) {
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] Fail to add client info ");
return TTSD_ERROR_OPERATION_FAILED;
}
@@ -701,21 +778,20 @@ int ttsd_server_setting_initialize(int uid)
int ttsd_server_setting_finalize(int uid)
{
- app_state_e state;
- if (0 > ttsd_data_get_client_state(uid, &state)) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid (%s)\n", uid);
+ if (-1 == ttsd_setting_data_is_setting(uid)) {
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid (%s)", uid);
return TTSD_ERROR_INVALID_PARAMETER;
}
- ttsd_data_delete_client(uid);
+ ttsd_setting_data_delete(uid);
/* unload engine, if ref count of client is 0 */
if (0 == ttsd_data_get_client_count())
{
if (0 != ttsd_engine_agent_unload_current_engine())
- SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] fail to unload current engine \n");
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] fail to unload current engine ");
else
- SLOG(LOG_DEBUG, TAG_TTSD, "[Server Setting SUCCESS] unload current engine \n");
+ SLOG(LOG_DEBUG, TAG_TTSD, "[Server Setting SUCCESS] unload current engine ");
}
return TTSD_ERROR_NONE;
@@ -723,16 +799,15 @@ int ttsd_server_setting_finalize(int uid)
int ttsd_server_setting_get_engine_list(int uid, GList** engine_list)
{
- app_state_e state;
- if (0 > ttsd_data_get_client_state(uid, &state)) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid \n");
+ if (-1 == ttsd_setting_data_is_setting(uid)) {
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid (%s)", uid);
return TTSD_ERROR_INVALID_PARAMETER;
}
int ret = 0;
ret = ttsd_engine_setting_get_engine_list(engine_list);
if (0 != ret) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] fail to get engine list : result(%d)\n", ret);
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] fail to get engine list : result(%d)", ret);
return ret;
}
@@ -741,16 +816,15 @@ int ttsd_server_setting_get_engine_list(int uid, GList** engine_list)
int ttsd_server_setting_get_current_engine(int uid, char** engine_id)
{
- app_state_e state;
- if (0 > ttsd_data_get_client_state(uid, &state)) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid \n");
+ if (-1 == ttsd_setting_data_is_setting(uid)) {
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid (%s)", uid);
return TTSD_ERROR_INVALID_PARAMETER;
}
int ret = 0;
ret = ttsd_engine_setting_get_engine(engine_id);
if (0 != ret) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] Fail to get current engine : result(%d) \n", ret);
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] Fail to get current engine : result(%d) ", ret);
return ret;
}
@@ -765,7 +839,7 @@ bool __get_client_cb(int pid, int uid, app_state_e state, void* user_data)
ttsd_data_set_client_state(uid, APP_STATE_READY);
/* send message */
- if ( 0 != ttsdc_send_interrupt_message(pid, uid, TTSD_INTERRUPTED_STOPPED)) {
+ if ( 0 != ttsdc_send_set_state_message(pid, uid, APP_STATE_READY)) {
/* remove client */
ttsd_data_delete_client(uid);
}
@@ -775,15 +849,14 @@ bool __get_client_cb(int pid, int uid, app_state_e state, void* user_data)
int ttsd_server_setting_set_current_engine(int uid, const char* engine_id)
{
- /* check if pid is valid */
- app_state_e state;
- if (0 > ttsd_data_get_client_state(uid, &state)) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid \n");
+ /* check if uid is valid */
+ if (-1 == ttsd_setting_data_is_setting(uid)) {
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid (%s)", uid);
return TTSD_ERROR_INVALID_PARAMETER;
}
if (true == ttsd_engine_agent_is_same_engine(engine_id)) {
- SLOG(LOG_DEBUG, TAG_TTSD, "[Server Setting] new engine is the same as current engine \n");
+ SLOG(LOG_DEBUG, TAG_TTSD, "[Server Setting] new engine is the same as current engine ");
return TTSD_ERROR_NONE;
}
@@ -797,7 +870,7 @@ int ttsd_server_setting_set_current_engine(int uid, const char* engine_id)
int ret = 0;
ret = ttsd_engine_setting_set_engine(engine_id);
if (0 != ret) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] fail to set current engine : result(%d) \n", ret);
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] fail to set current engine : result(%d) ", ret);
return ret;
}
@@ -806,9 +879,9 @@ int ttsd_server_setting_set_current_engine(int uid, const char* engine_id)
int ttsd_server_setting_get_voice_list(int uid, char** engine_id, GList** voice_list)
{
- app_state_e state;
- if (0 > ttsd_data_get_client_state(uid, &state)) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid \n");
+ /* check if uid is valid */
+ if (-1 == ttsd_setting_data_is_setting(uid)) {
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid (%s)", uid);
return TTSD_ERROR_INVALID_PARAMETER;
}
@@ -816,7 +889,7 @@ int ttsd_server_setting_get_voice_list(int uid, char** engine_id, GList** voice_
int ret = 0;
ret = ttsd_engine_setting_get_voice_list(engine_id, voice_list);
if (0 != ret) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] Fail to get voice list : result(%d)\n", ret);
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] Fail to get voice list : result(%d)", ret);
return ret;
}
@@ -825,16 +898,16 @@ int ttsd_server_setting_get_voice_list(int uid, char** engine_id, GList** voice_
int ttsd_server_setting_get_default_voice(int uid, char** language, ttsp_voice_type_e* vctype)
{
- app_state_e state;
- if (0 > ttsd_data_get_client_state(uid, &state)) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid \n");
+ /* check if uid is valid */
+ if (-1 == ttsd_setting_data_is_setting(uid)) {
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid (%s)", uid);
return TTSD_ERROR_INVALID_PARAMETER;
}
int ret = 0;
ret = ttsd_engine_setting_get_default_voice(language, vctype);
if (0 != ret) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] Fail to get default voice : result(%d) \n", ret);
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] Fail to get default voice : result(%d) ", ret);
return ret;
}
@@ -843,9 +916,9 @@ int ttsd_server_setting_get_default_voice(int uid, char** language, ttsp_voice_t
int ttsd_server_setting_set_default_voice(int uid, const char* language, int vctype)
{
- app_state_e state;
- if (0 > ttsd_data_get_client_state(uid, &state)) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid \n");
+ /* check if uid is valid */
+ if (-1 == ttsd_setting_data_is_setting(uid)) {
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid (%s)", uid);
return TTSD_ERROR_INVALID_PARAMETER;
}
@@ -853,7 +926,7 @@ int ttsd_server_setting_set_default_voice(int uid, const char* language, int vct
int ret = 0;
ret = ttsd_engine_setting_set_default_voice((const char*)language, (const ttsp_voice_type_e)vctype);
if (0 != ret) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] fail to set default voice : result(%d) \n", ret);
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] fail to set default voice : result(%d) ", ret);
return ret;
}
@@ -862,16 +935,16 @@ int ttsd_server_setting_set_default_voice(int uid, const char* language, int vct
int ttsd_server_setting_get_engine_setting(int uid, char** engine_id, GList** engine_setting_list)
{
- app_state_e state;
- if (0 > ttsd_data_get_client_state(uid, &state)) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid \n");
+ /* check if uid is valid */
+ if (-1 == ttsd_setting_data_is_setting(uid)) {
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid (%s)", uid);
return TTSD_ERROR_INVALID_PARAMETER;
}
int ret = 0;
ret = ttsd_engine_setting_get_engine_setting_info(engine_id, engine_setting_list);
if (0 != ret) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] fail to get engine setting info : result(%d)\n", ret);
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] fail to get engine setting info : result(%d)", ret);
return ret;
}
@@ -880,16 +953,16 @@ int ttsd_server_setting_get_engine_setting(int uid, char** engine_id, GList** en
int ttsd_server_setting_set_engine_setting(int uid, const char* key, const char* value)
{
- app_state_e state;
- if (0 > ttsd_data_get_client_state(uid, &state)) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid \n");
+ /* check if uid is valid */
+ if (-1 == ttsd_setting_data_is_setting(uid)) {
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid (%s)", uid);
return TTSD_ERROR_INVALID_PARAMETER;
}
int ret = 0;
ret = ttsd_engine_setting_set_engine_setting(key, value);
if (0 != ret) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] fail to set engine setting info : result(%d)\n", ret);
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] fail to set engine setting info : result(%d)", ret);
return ret;
}
@@ -898,9 +971,9 @@ int ttsd_server_setting_set_engine_setting(int uid, const char* key, const char*
int ttsd_server_setting_get_default_speed(int uid, int* default_speed)
{
- app_state_e state;
- if (0 > ttsd_data_get_client_state(uid, &state)) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid \n");
+ /* check if uid is valid */
+ if (-1 == ttsd_setting_data_is_setting(uid)) {
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid (%s)", uid);
return TTSD_ERROR_INVALID_PARAMETER;
}
@@ -908,7 +981,7 @@ int ttsd_server_setting_get_default_speed(int uid, int* default_speed)
int ret = 0;
ret = ttsd_engine_setting_get_default_speed((ttsp_speed_e*)default_speed);
if (0 != ret) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] fail to get default speed : result(%d)\n", ret);
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] fail to get default speed : result(%d)", ret);
return ret;
}
@@ -917,9 +990,9 @@ int ttsd_server_setting_get_default_speed(int uid, int* default_speed)
int ttsd_server_setting_set_default_speed(int uid, int default_speed)
{
- app_state_e state;
- if (0 > ttsd_data_get_client_state(uid, &state)) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid \n");
+ /* check if uid is valid */
+ if (-1 == ttsd_setting_data_is_setting(uid)) {
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid (%s)", uid);
return TTSD_ERROR_INVALID_PARAMETER;
}
@@ -927,32 +1000,11 @@ int ttsd_server_setting_set_default_speed(int uid, int default_speed)
int ret = 0;
ret = ttsd_engine_setting_set_default_speed((ttsp_speed_e)default_speed);
if (0 != ret) {
- SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] fail to set default speed : result(%d)\n", ret);
+ SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] fail to set default speed : result(%d)", ret);
return ret;
}
return TTSD_ERROR_NONE;
}
-/*
-* Server API for Internal event
-*/
-
-int ttsd_server_start_next_play(int uid)
-{
- SLOG(LOG_DEBUG, TAG_TTSD, "===== NEXT PLAY START");
-
- int ret = ttsd_player_next_play(uid);
-
- SLOG(LOG_DEBUG, TAG_TTSD, "===== ");
- SLOG(LOG_DEBUG, TAG_TTSD, " ");
-
- return ret ;
-}
-
-int ttsd_server_start_next_synthesis(int uid)
-{
- return __server_next_synthesis(uid);
-}
-
diff --git a/server/ttsd_server.h b/server/ttsd_server.h
index 7b283ce..7dda232 100644
--- a/server/ttsd_server.h
+++ b/server/ttsd_server.h
@@ -16,6 +16,7 @@
#define __TTSD_SERVER_CORE_H_
#include <glib.h>
+#include <Ecore.h>
#ifdef __cplusplus
extern "C" {
@@ -28,6 +29,8 @@ extern "C" {
/** Daemon initialize */
int ttsd_initialize();
+Eina_Bool ttsd_cleanup_client(void *data);
+
/*
* Server API for client
*/
@@ -49,14 +52,6 @@ int ttsd_server_stop(int uid);
int ttsd_server_pause(int uid, int* utt_id);
/*
-* Server API for Internal event
-*/
-
-int ttsd_server_start_next_play(int uid);
-
-int ttsd_server_start_next_synthesis(int uid);
-
-/*
* Server API for setting
*/