#include "ttsd_main.h"
#include "ttsd_data.h"
-#include "ttsd_stub.h"
using namespace std;
std::list<sound_data_s*> m_wav_data;
std::list<used_voice_s> m_used_voice;
- rpc_port_tts_notify_cb_h notify_cb_h;
tts_ipc_method_e ipc_method;
} app_data_s;
app.uid = uid;
app.utt_id_stopped = 0;
app.state = APP_STATE_READY;
- app.notify_cb_h = NULL;
app.ipc_method = TTS_IPC_METHOD_UNDEFINED;
g_app_list.insert(g_app_list.end(), app);
return g_app_list[index].ipc_method;
}
-int ttsd_data_set_notify_h(int uid, rpc_port_tts_notify_cb_h handle, void* user_data)
-{
- int index = ttsd_data_is_client(uid);
-
- if (index < 0) {
- SECURE_SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] uid is not valid (%d)", uid);
- return TTSD_ERROR_INVALID_PARAMETER;
- }
-
- if (rpc_port_tts_notify_cb_clone(handle, &(g_app_list[index].notify_cb_h)) != 0) {
- return TTSD_ERROR_OPERATION_FAILED;
- }
-
- return TTSD_ERROR_NONE;
-}
-
-rpc_port_tts_notify_cb_h ttsd_data_get_notify_handle(int uid)
-{
- int index = ttsd_data_is_client(uid);
- SLOG(LOG_DEBUG, tts_tag(), "ttsd_data_is_client : index(%d)", index);
- if (index < 0) {
- SECURE_SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] uid is not valid (%d)", uid);
- return NULL;
- }
- return g_app_list[index].notify_cb_h;
-}
-
-int ttsd_data_unset_notify_h(int uid)
-{
- int index = ttsd_data_is_client(uid);
-
- if (index < 0) {
- SECURE_SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] uid is not valid (%d)", uid);
- return TTSD_ERROR_INVALID_PARAMETER;
- }
-
- g_app_list[index].notify_cb_h = NULL;
- SLOG(LOG_DEBUG, tts_tag(), "[DATA] uid(%d) callback is unseted", g_app_list[index].uid);
-
- return TTSD_ERROR_NONE;
-}
-
int ttsd_data_get_speak_data_size(int uid)
{
int index = 0;
#include "ttsd_tidl.h"
+typedef struct {
+ int uid;
+ rpc_port_tts_notify_cb_h notify_cb_h;
+} tts_tidl_proxy_info_s;
+
+static GList* g_tidl_proxy_infos = NULL;
+
rpc_port_stub_tts_callback_s g_callback;
+static tts_tidl_proxy_info_s* __get_tidl_proxy_info_s(int uid)
+{
+ GList* iter = NULL;
+ tts_tidl_proxy_info_s* info = NULL;
+
+ if (g_list_length(g_tidl_proxy_infos) > 0) {
+ /* Get a first item */
+ iter = g_list_first(g_tidl_proxy_infos);
+
+ while (NULL != iter) {
+ info = iter->data;
+ if (info->uid == uid) {
+ return info;
+ }
+
+ /* Next item */
+ iter = g_list_next(iter);
+ }
+ }
+
+ return NULL;
+}
+
void __send_msg(int pid, int uid, bundle* msg)
{
SLOG(LOG_INFO, tts_tag(), "[TIDL] start : send msg : pid(%d), uid(%d)", pid, uid);
- rpc_port_tts_notify_cb_h handle;
+ tts_tidl_proxy_info_s* info = __get_tidl_proxy_info_s(uid);
+ if (NULL == info) {
+ SLOG(LOG_ERROR, tts_tag(), "[TIDL] Uid is not valid. pid(%d), uid(%d)", pid, uid);
+ return;
+ }
- handle = ttsd_data_get_notify_handle(uid);
- if (!handle) {
- SLOG(LOG_INFO, tts_tag(), "ttsd_data_get_notify_handle handle null");
+ rpc_port_tts_notify_cb_h handle = info->notify_cb_h;
+ if (NULL == handle) {
+ SLOG(LOG_INFO, tts_tag(), "notify callback handle null");
return;
}
credential_needed = TTS_CREDENTIAL_NEEDED_ALREADY_INITIALIZED;
}
- if (0 != ttsd_data_set_notify_h(uid, callback, NULL)) {
- SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to set notify callback");
+ tts_tidl_proxy_info_s* info = (tts_tidl_proxy_info_s*)calloc(1, sizeof(tts_tidl_proxy_info_s));
+ if (NULL == info) {
+ SLOG(LOG_ERROR, tts_tag(), "[TIDL ERROR] Fail to allocate memory for tidl proxy");
return;
}
+ if (0 != rpc_port_tts_notify_cb_clone(callback, &info->notify_cb_h)) {
+ SLOG(LOG_ERROR, tts_tag(), "[TIDL ERROR] Fail to set notify callback");
+ free(info);
+ return;
+ }
+
+ info->uid = uid;
+ g_tidl_proxy_infos = g_list_append(g_tidl_proxy_infos, info);
+
SLOG(LOG_INFO, tts_tag(), "create player instance");
ttsdc_tidl_send_hello(pid, uid, ret, credential_needed);
static int __register_cb_sync(rpc_port_stub_tts_context_h context, int pid, int uid, rpc_port_tts_notify_cb_h callback, void* user_data)
{
SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS REGISTER CALLBACK synchronously uid(%d)", uid);
- if (0 != ttsd_data_set_notify_h(uid, callback, NULL)) {
- SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to set notify callback");
+
+ tts_tidl_proxy_info_s* info = (tts_tidl_proxy_info_s*)calloc(1, sizeof(tts_tidl_proxy_info_s));
+ if (NULL == info) {
+ SLOG(LOG_ERROR, tts_tag(), "[TIDL ERROR] Fail to allocate memory for tidl proxy");
+ return TTSD_ERROR_OPERATION_FAILED;
+ }
+
+ if (0 != rpc_port_tts_notify_cb_clone(callback, &info->notify_cb_h)) {
+ SLOG(LOG_ERROR, tts_tag(), "[TIDL ERROR] Fail to set notify callback");
+ free(info);
return TTSD_ERROR_OPERATION_FAILED;
}
+ info->uid = uid;
+ g_tidl_proxy_infos = g_list_append(g_tidl_proxy_infos, info);
+
SLOG(LOG_ERROR, tts_tag(), "<<<<<<<<<<<");
return TTSE_ERROR_NONE;
if (0 != ttsd_server_finalize(uid)) {
return -1;
}
+
+ tts_tidl_proxy_info_s* info = __get_tidl_proxy_info_s(uid);
+ if (NULL == info) {
+ SLOG(LOG_ERROR, tts_tag(), "[TIDL ERROR] Fail to set notify callback");
+ return TTSD_ERROR_INVALID_PARAMETER;
+ }
+
+ rpc_port_tts_notify_cb_destroy(info->notify_cb_h);
+ info->notify_cb_h = NULL;
+
+ g_tidl_proxy_infos = g_list_remove(g_tidl_proxy_infos, info);
+ free(info);
+
SLOG(LOG_DEBUG, tts_tag(), "<<<<<");
return TTSE_ERROR_NONE;