Change uid and gid for service files
[platform/core/uifw/tts.git] / server / ttsd_server.c
index 72cee8f..7f2fe64 100644 (file)
@@ -92,7 +92,7 @@ static int __synthesis(int uid, const char* credential)
 
                        ttsdc_send_set_state_message(pid, uid, APP_STATE_READY);
 
-                       ttsd_data_clear_speak_data(&speak_data);
+                       ttsd_data_clear_speak_data(uid, &speak_data);
 
                        return 0;
                }
@@ -123,9 +123,9 @@ static int __synthesis(int uid, const char* credential)
                        g_wait_timer = ecore_timer_add(0.05, __wait_synthesis, (void*)credential);
                }
 
-               ttsd_data_clear_speak_data(&speak_data);
+               ttsd_data_clear_speak_data(uid, &speak_data);
        } else {
-               ttsd_data_clear_speak_data(&speak_data);
+               ttsd_data_clear_speak_data(uid, &speak_data);
        }
 
        SLOG(LOG_DEBUG, tts_tag(), "@@@ SYNTHESIS  END");
@@ -233,6 +233,15 @@ int ttsd_send_result(ttse_result_event_e event, const void* data, unsigned int d
 
                if (0 != ttsd_data_add_sound_data(uid, temp_sound_data)) {
                        SECURE_SLOG(LOG_ERROR, tts_tag(), "[SERVER ERROR] Fail to add sound data : uid(%d)", uid);
+                       if (NULL != temp_sound_data->data) {
+                               free(temp_sound_data->data);
+                               temp_sound_data->data = NULL;
+                       }
+
+                       free(temp_sound_data);
+                       temp_sound_data = NULL;
+
+                       return TTSD_ERROR_OPERATION_FAILED;
                }
 
                if (event == TTSE_RESULT_EVENT_FINISH) {
@@ -473,6 +482,19 @@ int ttsd_finalize()
        return TTSD_ERROR_NONE;
 }
 
+int ttsd_terminate()
+{
+       SLOG(LOG_INFO, tts_tag(), "[Server] Terminate");
+
+       ttsd_terminate_daemon(NULL);
+
+       ttsd_dbus_close_connection();
+       ttsd_network_finalize();
+       ttsd_finalize();
+
+       return TTSD_ERROR_NONE;
+}
+
 /*
 * TTS Server Functions for Client
 */
@@ -822,6 +844,7 @@ int ttsd_server_play(int uid, const char* credential)
                } else {
                        if (true == is_current_interrupt) {
                                SLOG(LOG_WARN, tts_tag(), "[Server WARNING] Current playback focus is set on Interrupt mode. Cannot play default, screen reader, and noti modes.");
+                               ttsd_data_clear_data(uid);
                                return TTSD_ERROR_AUDIO_POLICY_BLOCKED;
                        }
                }