Clean up header files 96/271896/2
authorSuyeon Hwang <stom.hwang@samsung.com>
Mon, 24 Jan 2022 05:54:52 +0000 (14:54 +0900)
committerSuyeon Hwang <stom.hwang@samsung.com>
Tue, 15 Mar 2022 05:47:40 +0000 (14:47 +0900)
Change-Id: I87127a6429e4396dfaf5492c06eba9a6cbb230b2
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
server/ttsd_data.cpp
server/ttsd_data.h
server/ttsd_dbus.c
server/ttsd_dbus.h
server/ttsd_dbus_server.c
server/ttsd_player.cpp
server/ttsd_server.c
server/ttsd_server.h

index 367f60a0daad8ccd9b9b8ae593cb39fbadb7b60e..62621945b4397079166d040b86cc2e3fa274eca6 100644 (file)
@@ -130,14 +130,14 @@ static void __data_show_used_voice_list(app_data_s& app_data)
 * ttsd data functions
 */
 
-int ttsd_set_synth_control(ttsd_synthesis_control_e control)
+int ttsd_data_set_synth_control(ttsd_synthesis_control_e control)
 {
        SLOG(LOG_INFO, tts_tag(), "[DATA INFO] set synth_control(%d)", control);
        g_synth_control = control;
        return 0;
 }
 
-ttsd_synthesis_control_e ttsd_get_synth_control()
+ttsd_synthesis_control_e ttsd_data_get_synth_control()
 {
        return g_synth_control.load();
 }
index feff8d740cbdfc684f83949ef47fa4cf38b54d4a..d59b3115088f18db46ad925e3bf0734a08445a60 100644 (file)
@@ -63,9 +63,10 @@ typedef struct {
        int channels;
 } sound_data_s;
 
-int ttsd_set_synth_control(ttsd_synthesis_control_e control);
 
-ttsd_synthesis_control_e ttsd_get_synth_control();
+int ttsd_data_set_synth_control(ttsd_synthesis_control_e control);
+
+ttsd_synthesis_control_e ttsd_data_get_synth_control();
 
 typedef void (* ttsd_used_voice_cb)(const char* lang, int type);
 
index 57ced0b5469053f478701ce1d4bd09fa8a396be1..f639b53b26ce6174438bd680afd6097e4f49c92d 100644 (file)
@@ -54,7 +54,7 @@ const char* __ttsd_get_error_code(ttsd_error_e err)
        return NULL;
 }
 
-int ttsdc_send_hello(int pid, unsigned int uid, int ret, int credential_needed)
+int ttsdc_dbus_send_hello(int pid, unsigned int uid, int ret, int credential_needed)
 {
        if (NULL == g_conn_sender) {
                SLOG(LOG_ERROR, tts_tag(), "[Dbus ERROR] Dbus connection is not available");
index bb216157be07eabcaf1a9571a445922337cca73b..0d9cd9c8197a2f0a80092b46547a0302a2b6c601 100644 (file)
@@ -23,7 +23,7 @@ int ttsd_dbus_open_connection();
 
 int ttsd_dbus_close_connection();
 
-int ttsdc_send_hello(int pid, unsigned int uid, int ret, int credential_needed);
+int ttsdc_dbus_send_hello(int pid, unsigned int uid, int ret, int credential_needed);
 
 int ttsdc_dbus_send_utt_start_message(int pid, unsigned int uid, int uttid);
 
index 0b9fddf64f7520665b2e4afff056988ba684acdf..82e41df596302d01aa0e172ecf9c928c1e0c4949 100644 (file)
@@ -61,7 +61,7 @@ int ttsd_dbus_server_hello(DBusConnection* conn, DBusMessage* msg)
                }
                SLOG(LOG_INFO, tts_tag(), "[INFO] send_hello. pid(%d), uid(%u), ret(%d), credential_needed(%d)", pid, uid, ret, credential_needed);
 
-               ttsdc_send_hello(pid, uid, ret, credential_needed);
+               ttsdc_dbus_send_hello(pid, uid, ret, credential_needed);
        }
 
        return 0;
index 05c12c9ee7965f13c5dd8e7c64524c5189898d54..1bdd4f2f4f793ed6dd557d2edba3f7bb60cc33a3 100644 (file)
@@ -260,7 +260,7 @@ static void __wait_sound_data(PlayerThread* player, unsigned int uid)
                }
 
                /* If engine is not on processing */
-               ttsd_synthesis_control_e synth_control = ttsd_get_synth_control();
+               ttsd_synthesis_control_e synth_control = ttsd_data_get_synth_control();
                if (TTSD_SYNTHESIS_CONTROL_DOING != synth_control) {
                        SLOG(LOG_INFO, tts_tag(), "[Server INFO] synth_control(%d)", synth_control);
                        if (AudioStream::AUDIO_STATE_PLAY == g_audio_stream->getState()) {
index 7cb042a6b91c09c244609c0e92d87b096493248c..e3ebd8bd2024a1c54feece483cbc9d1a78c0c809 100644 (file)
@@ -84,7 +84,7 @@ static Eina_Bool __wait_synthesis(void *data)
        unsigned int uid = ttsd_data_get_current_playing();
 
        if (uid > 0) {
-               ttsd_synthesis_control_e synth_control = ttsd_get_synth_control();
+               ttsd_synthesis_control_e synth_control = ttsd_data_get_synth_control();
                if (TTSD_SYNTHESIS_CONTROL_DOING == synth_control) {
                        return EINA_TRUE;
                } else {
@@ -147,12 +147,12 @@ static void __synthesis(unsigned int uid)
        SLOG(LOG_INFO, tts_tag(), "Credential : %s", credential);
        SLOG(LOG_INFO, tts_tag(), "-----------------------------------------------------------");
 
-       ttsd_set_synth_control(TTSD_SYNTHESIS_CONTROL_DOING);
+       ttsd_data_set_synth_control(TTSD_SYNTHESIS_CONTROL_DOING);
        ret = ttsd_engine_start_synthesis(speak_data->lang, speak_data->vctype, speak_data->text, speak_data->speed, appid, credential, NULL);
        if (TTSD_ERROR_NONE != ret) {
                SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] * FAIL to start SYNTHESIS !!!! * ");
 
-               ttsd_set_synth_control(TTSD_SYNTHESIS_CONTROL_DONE);
+               ttsd_data_set_synth_control(TTSD_SYNTHESIS_CONTROL_DONE);
                __stop_and_send_ready_state(uid);
        } else {
                g_wait_timer = ecore_timer_add(0.05, __wait_synthesis, (void*)credential);
@@ -178,7 +178,7 @@ int ttsd_send_error(ttse_error_e error, const char* msg)
 
        SLOG(LOG_ERROR, tts_tag(), "[SERVER ERROR] Error msg from engine, pid(%d), uid(%u), uttid(%d), error(%d), msg(%s)", tmp_pid, uid, uttid, error, (NULL == msg ? "NULL" : msg));
 
-       ttsd_set_synth_control(TTSD_SYNTHESIS_CONTROL_EXPIRED);
+       ttsd_data_set_synth_control(TTSD_SYNTHESIS_CONTROL_EXPIRED);
 
        if (0 != ttsd_data_clear_data(uid))
                SLOG(LOG_WARN, tts_tag(), "[Server] Fail to ttsd_data_clear_data()");
@@ -206,7 +206,7 @@ int ttsd_send_result(ttse_result_event_e event, const void* data, unsigned int d
        int uttid = g_utt.uttid;
 
        if (false == ttsd_data_is_uttid_valid(uid, uttid)) {
-               ttsd_set_synth_control(TTSD_SYNTHESIS_CONTROL_DONE);
+               ttsd_data_set_synth_control(TTSD_SYNTHESIS_CONTROL_DONE);
                SLOG(LOG_ERROR, tts_tag(), "[SERVER ERROR] uttid is NOT valid !!!! - uid(%u), uttid(%d)", uid, uttid);
                SLOG(LOG_DEBUG, tts_tag(), "@@@");
                return TTSD_ERROR_INVALID_PARAMETER;
@@ -214,12 +214,12 @@ int ttsd_send_result(ttse_result_event_e event, const void* data, unsigned int d
 
        if (TTSE_RESULT_EVENT_START > event || TTSE_RESULT_EVENT_FINISH < event) {
                SLOG(LOG_DEBUG, tts_tag(), "[SERVER] Event : TTSE_RESULT_EVENT_ERROR");
-               ttsd_set_synth_control(TTSD_SYNTHESIS_CONTROL_EXPIRED);
+               ttsd_data_set_synth_control(TTSD_SYNTHESIS_CONTROL_EXPIRED);
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
        if (rate <= 0 || audio_type < 0 || audio_type > TTSE_AUDIO_TYPE_MAX) {
-               ttsd_set_synth_control(TTSD_SYNTHESIS_CONTROL_DONE);
+               ttsd_data_set_synth_control(TTSD_SYNTHESIS_CONTROL_DONE);
                SLOG(LOG_ERROR, tts_tag(), "[SERVER ERROR] audio data is invalid");
                SLOG(LOG_DEBUG, tts_tag(), "@@@");
                return TTSD_ERROR_INVALID_PARAMETER;
@@ -228,14 +228,14 @@ int ttsd_send_result(ttse_result_event_e event, const void* data, unsigned int d
        /* check the current state */
        app_tts_state_e state = ttsd_data_get_client_state(uid);
        if (APP_STATE_NONE == state) {
-               ttsd_set_synth_control(TTSD_SYNTHESIS_CONTROL_DONE);
+               ttsd_data_set_synth_control(TTSD_SYNTHESIS_CONTROL_DONE);
                SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] uid is not valid");
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
        SLOG(LOG_INFO, tts_tag(), "[Server] uid(%u), current state(%d)", uid, state);
        if (APP_STATE_CREATED == state || APP_STATE_READY == state) {
-               ttsd_set_synth_control(TTSD_SYNTHESIS_CONTROL_DONE);
+               ttsd_data_set_synth_control(TTSD_SYNTHESIS_CONTROL_DONE);
                SLOG(LOG_WARN, tts_tag(), "[SERVER WARNING] Current state is %d. The synthesized result is ignored.", state);
                return TTSD_ERROR_NONE;
        }
@@ -278,7 +278,7 @@ int ttsd_send_result(ttse_result_event_e event, const void* data, unsigned int d
        }
 
        if (event == TTSE_RESULT_EVENT_FINISH) {
-               ttsd_set_synth_control(TTSD_SYNTHESIS_CONTROL_DONE);
+               ttsd_data_set_synth_control(TTSD_SYNTHESIS_CONTROL_DONE);
        }
 
        return TTSD_ERROR_NONE;
@@ -308,7 +308,7 @@ static void __stop_all_client()
        SLOG(LOG_INFO, tts_tag(), "[Server] Send to stop all requests");
 
        ttsd_engine_cancel_synthesis();
-       ttsd_set_synth_control(TTSD_SYNTHESIS_CONTROL_EXPIRED);
+       ttsd_data_set_synth_control(TTSD_SYNTHESIS_CONTROL_EXPIRED);
 
        /* stop all player */
        ttsd_player_all_stop();
@@ -462,6 +462,87 @@ void __screen_reader_changed_cb(bool value)
        return;
 }
 
+static void __read_proc()
+{
+       DIR *dp = NULL;
+       struct dirent *dirp = NULL;
+       int tmp;
+
+       GList *iter = NULL;
+       if (0 < g_list_length(g_proc_list)) {
+               iter = g_list_first(g_proc_list);
+               while (NULL != iter) {
+                       g_proc_list = g_list_remove_link(g_proc_list, iter);
+                       g_list_free(iter);
+                       iter = g_list_first(g_proc_list);
+               }
+       }
+
+       dp = opendir("/proc");
+       if (NULL == dp) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to open proc");
+       } else {
+               do {
+                       dirp = readdir(dp);
+
+                       if (NULL != dirp) {
+                               tmp = atoi(dirp->d_name);
+                               if (0 >= tmp)   continue;
+                               g_proc_list = g_list_append(g_proc_list, GINT_TO_POINTER(tmp));
+                       }
+               } while (NULL != dirp);
+               closedir(dp);
+       }
+       return;
+}
+
+bool __get_client_for_clean_up(int pid, unsigned int uid, app_tts_state_e state, void* user_data)
+{
+       bool exist = false;
+       int i = 0;
+
+       GList *iter = NULL;
+       for (i = 0; i < g_list_length(g_proc_list); i++) {
+               iter = g_list_nth(g_proc_list, i);
+               if (NULL != iter) {
+                       if (pid == GPOINTER_TO_INT(iter->data)) {
+                               SLOG(LOG_DEBUG, tts_tag(), "uid (%u) is running", uid);
+                               exist = true;
+                               break;
+                       }
+               }
+       }
+
+       if (false == exist) {
+               SLOG(LOG_ERROR, tts_tag(), "uid (%u) should be removed", uid);
+               ttsd_server_finalize(uid);
+       }
+
+       return true;
+}
+
+static Eina_Bool __cleanup_client(void *data)
+{
+       SLOG(LOG_DEBUG, tts_tag(), "@@@ CLEAN UP CLIENT START");
+       __read_proc();
+
+       if (0 < ttsd_data_get_client_count()) {
+               ttsd_data_foreach_clients(__get_client_for_clean_up, NULL);
+       } else {
+               if (NULL == g_quit_loop_timer) {
+                       SLOG(LOG_INFO, tts_tag(), "[Server] Add a timer __quit_ecore_loop");
+                       g_quit_loop_timer = ecore_timer_add(0, __quit_ecore_loop, NULL);
+               }
+               SLOG(LOG_ERROR, tts_tag(), "[Server] Deleted timer");
+               g_check_client_timer = NULL;
+               return EINA_FALSE;
+       }
+
+       SLOG(LOG_DEBUG, tts_tag(), "@@@");
+
+       return EINA_TRUE;
+}
+
 /*
 * Server APIs
 */
@@ -497,22 +578,15 @@ int ttsd_initialize(ttse_request_callback_s *callback)
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
-       /* set current engine */
-       //if (0 != ttsd_engine_agent_initialize_current_engine(callback)) {
-       //      SLOG(LOG_WARN, tts_tag(), "[Server WARNING] No Engine !!!" );
-       //      g_is_engine = false;
-       //} else
-       //      g_is_engine = true;
-
        if (0 != ttsd_engine_agent_load_current_engine(callback)) {
                SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to load current engine");
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
-       ttsd_set_synth_control(TTSD_SYNTHESIS_CONTROL_EXPIRED);
+       ttsd_data_set_synth_control(TTSD_SYNTHESIS_CONTROL_EXPIRED);
        ttsd_config_set_screen_reader_callback(__screen_reader_changed_cb);
 
-       g_check_client_timer = ecore_timer_add(CLIENT_CLEAN_UP_TIME, ttsd_cleanup_client, NULL);
+       g_check_client_timer = ecore_timer_add(CLIENT_CLEAN_UP_TIME, __cleanup_client, NULL);
        if (NULL == g_check_client_timer) {
                SLOG(LOG_WARN, tts_tag(), "[WARNING] Fail to create timer");
        }
@@ -651,111 +725,6 @@ int ttsd_server_initialize(int pid, unsigned int uid, tts_ipc_method_e method, b
        return TTSD_ERROR_NONE;
 }
 
-static void __read_proc()
-{
-       DIR *dp = NULL;
-       struct dirent *dirp = NULL;
-       int tmp;
-
-       GList *iter = NULL;
-       if (0 < g_list_length(g_proc_list)) {
-               iter = g_list_first(g_proc_list);
-               while (NULL != iter) {
-                       g_proc_list = g_list_remove_link(g_proc_list, iter);
-                       g_list_free(iter);
-                       iter = g_list_first(g_proc_list);
-               }
-       }
-
-       dp = opendir("/proc");
-       if (NULL == dp) {
-               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to open proc");
-       } else {
-               do {
-                       dirp = readdir(dp);
-
-                       if (NULL != dirp) {
-                               tmp = atoi(dirp->d_name);
-                               if (0 >= tmp)   continue;
-                               g_proc_list = g_list_append(g_proc_list, GINT_TO_POINTER(tmp));
-                       }
-               } while (NULL != dirp);
-               closedir(dp);
-       }
-       return;
-}
-
-bool __get_client_for_clean_up(int pid, unsigned int uid, app_tts_state_e state, void* user_data)
-{
-       bool exist = false;
-       int i = 0;
-
-       GList *iter = NULL;
-       for (i = 0; i < g_list_length(g_proc_list); i++) {
-               iter = g_list_nth(g_proc_list, i);
-               if (NULL != iter) {
-                       if (pid == GPOINTER_TO_INT(iter->data)) {
-                               SLOG(LOG_DEBUG, tts_tag(), "uid (%u) is running", uid);
-                               exist = true;
-                               break;
-                       }
-               }
-       }
-
-       if (false == exist) {
-               SLOG(LOG_ERROR, tts_tag(), "uid (%u) should be removed", uid);
-               ttsd_server_finalize(uid);
-       }
-
-       return true;
-#if 0
-       char appid[1024] = {0, };
-       if (0 != aul_app_get_appid_bypid(pid, appid, sizeof(appid) - 1)) {
-               SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to get app id");
-       }
-
-       if (0 < strlen(appid)) {
-               SLOG(LOG_DEBUG, tts_tag(), "[%d] is running app - %s", pid, appid);
-       } else {
-               SLOG(LOG_DEBUG, tts_tag(), "[%d] is daemon or no_running app", pid);
-
-               int result = 1;
-               result = ttsdc_send_hello(pid, uid);
-
-               if (0 == result) {
-                       SLOG(LOG_DEBUG, tts_tag(), "[Server] uid(%u) should be removed.", uid);
-                       ttsd_server_finalize(uid);
-               } else if (-1 == result) {
-                       SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Hello result has error");
-               }
-       }
-       return true;
-#endif
-}
-
-
-Eina_Bool ttsd_cleanup_client(void *data)
-{
-       SLOG(LOG_DEBUG, tts_tag(), "@@@ CLEAN UP CLIENT START");
-       __read_proc();
-
-       if (0 < ttsd_data_get_client_count()) {
-               ttsd_data_foreach_clients(__get_client_for_clean_up, NULL);
-       } else {
-               if (NULL == g_quit_loop_timer) {
-                       SLOG(LOG_INFO, tts_tag(), "[Server] Add a timer __quit_ecore_loop");
-                       g_quit_loop_timer = ecore_timer_add(0, __quit_ecore_loop, NULL);
-               }
-               SLOG(LOG_ERROR, tts_tag(), "[Server] Deleted timer");
-               g_check_client_timer = NULL;
-               return EINA_FALSE;
-       }
-
-       SLOG(LOG_DEBUG, tts_tag(), "@@@");
-
-       return EINA_TRUE;
-}
-
 void __used_voice_cb(const char* lang, int type)
 {
        SLOG(LOG_DEBUG, tts_tag(), "[Server] Request to unload voice (%s,%d)", lang, type);
@@ -918,7 +887,7 @@ int ttsd_server_add_text(unsigned int uid, const char* text, const char* lang, i
                ttsd_data_set_credential(uid, credential);
 
                /* Check whether tts-engine is running or not */
-               ttsd_synthesis_control_e synth_control = ttsd_get_synth_control();
+               ttsd_synthesis_control_e synth_control = ttsd_data_get_synth_control();
                SLOG(LOG_INFO, tts_tag(), "[Server INFO] synth_control(%d)", synth_control);
                if (TTSD_SYNTHESIS_CONTROL_DOING == synth_control) {
                        SLOG(LOG_WARN, tts_tag(), "[Server WARNING] Engine has already been running.");
@@ -1016,7 +985,7 @@ int ttsd_server_play(unsigned int uid, const char* credential)
 
        /* Check whether tts-engine is running or not */
        clock_gettime(CLOCK_MONOTONIC_RAW, &g_request_playing);
-       ttsd_synthesis_control_e synth_control = ttsd_get_synth_control();
+       ttsd_synthesis_control_e synth_control = ttsd_data_get_synth_control();
        SLOG(LOG_INFO, tts_tag(), "[Server INFO] synth_control(%d)", synth_control);
        if (TTSD_SYNTHESIS_CONTROL_DOING == synth_control) {
                SLOG(LOG_WARN, tts_tag(), "[Server WARNING] Engine has already been running.");
@@ -1030,7 +999,7 @@ int ttsd_server_play(unsigned int uid, const char* credential)
 
 static void __stop_engine_synthesis(unsigned int uid)
 {
-       ttsd_synthesis_control_e synth_control = ttsd_get_synth_control();
+       ttsd_synthesis_control_e synth_control = ttsd_data_get_synth_control();
        SLOG(LOG_INFO, tts_tag(), "[Server INFO] synth_control(%d)", synth_control);
 
        if (TTSD_SYNTHESIS_CONTROL_DOING == synth_control && uid == ttsd_data_get_current_playing()) {
@@ -1041,7 +1010,7 @@ static void __stop_engine_synthesis(unsigned int uid)
                        SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to cancel synthesis : ret(%d)", ret);
        }
 
-       ttsd_set_synth_control(TTSD_SYNTHESIS_CONTROL_EXPIRED);
+       ttsd_data_set_synth_control(TTSD_SYNTHESIS_CONTROL_EXPIRED);
 }
 
 int ttsd_server_stop(unsigned int uid)
index ee9c120a57258513bf571fed7e286d95e8852697..ca5ae12db52f237444d31d02184508b20793f769 100644 (file)
@@ -34,10 +34,6 @@ int ttsd_finalize();
 
 int ttsd_terminate();
 
-Eina_Bool ttsd_cleanup_client(void *data);
-
-Eina_Bool ttsd_get_daemon_exist();
-
 int ttsd_send_result(ttse_result_event_e event, const void* data, unsigned int data_size, ttse_audio_type_e audio_type, int rate, void* user_data);
 int ttsd_send_error(ttse_error_e error, const char* msg);