Send synthesized PCM data from TTS engine to client
[platform/core/uifw/tts.git] / server / ttsd_dbus.c
1 /*
2 *  Copyright (c) 2011-2016 Samsung Electronics Co., Ltd All Rights Reserved
3 *  Licensed under the Apache License, Version 2.0 (the "License");
4 *  you may not use this file except in compliance with the License.
5 *  You may obtain a copy of the License at
6 *  http://www.apache.org/licenses/LICENSE-2.0
7 *  Unless required by applicable law or agreed to in writing, software
8 *  distributed under the License is distributed on an "AS IS" BASIS,
9 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 *  See the License for the specific language governing permissions and
11 *  limitations under the License.
12 */
13
14 #include <dbus/dbus.h>
15 #include <dirent.h>
16 #include <dlfcn.h>
17 #include <Ecore.h>
18
19 #include "ttsd_main.h"
20 #include "ttsd_dbus_server.h"
21 #include "ttsd_dbus.h"
22
23 static DBusConnection* g_conn_sender = NULL;
24 static DBusConnection* g_conn_listener = NULL;
25
26 static Ecore_Fd_Handler* g_dbus_fd_handler = NULL;
27
28 //static int g_waiting_time = 3000;
29
30 static char *g_service_name = NULL;
31 static char *g_service_object = NULL;
32 static char *g_service_interface = NULL;
33
34 const char* __ttsd_get_error_code(ttsd_error_e err)
35 {
36         switch (err) {
37         case TTSD_ERROR_NONE:                   return "TTS_ERROR_NONE";
38         case TTSD_ERROR_OUT_OF_MEMORY:          return "TTS_ERROR_OUT_OF_MEMORY";
39         case TTSD_ERROR_IO_ERROR:               return "TTS_ERROR_IO_ERROR";
40         case TTSD_ERROR_INVALID_PARAMETER:      return "TTS_ERROR_INVALID_PARAMETER";
41         case TTSD_ERROR_OUT_OF_NETWORK:         return "TTS_ERROR_OUT_OF_NETWORK";
42         case TTSD_ERROR_INVALID_STATE:          return "TTS_ERROR_INVALID_STATE";
43         case TTSD_ERROR_INVALID_VOICE:          return "TTS_ERROR_INVALID_VOICE";
44         case TTSD_ERROR_ENGINE_NOT_FOUND:       return "TTS_ERROR_ENGINE_NOT_FOUND";
45         case TTSD_ERROR_TIMED_OUT:              return "TTS_ERROR_TIMED_OUT";
46         case TTSD_ERROR_OPERATION_FAILED:       return "TTS_ERROR_OPERATION_FAILED";
47         case TTSD_ERROR_AUDIO_POLICY_BLOCKED:   return "TTS_ERROR_AUDIO_POLICY_BLOCKED";
48         case TTSD_ERROR_NOT_SUPPORTED_FEATURE:  return "TTSD_ERROR_NOT_SUPPORTED_FEATURE";
49         case TTSD_ERROR_SERVICE_RESET:          return "TTSD_ERROR_SERVICE_RESET";
50         default:
51                 return "Invalid error code";
52         }
53
54         return NULL;
55 }
56
57 int ttsdc_dbus_send_hello(int pid, unsigned int uid, int ret, int service_state, int credential_needed)
58 {
59         if (NULL == g_conn_sender) {
60                 SLOG(LOG_ERROR, tts_tag(), "[Dbus ERROR] Dbus connection is not available");
61                 return -1;
62         }
63
64         DBusMessage* msg;
65         char target_if_name[64];
66         snprintf(target_if_name, sizeof(target_if_name), "%s%d", TTS_CLIENT_SERVICE_INTERFACE, pid);
67
68         /* create a message */
69         msg = dbus_message_new_signal(
70                 TTS_CLIENT_SERVICE_OBJECT_PATH, /* object name of the signal */
71                 target_if_name,                         /* interface name of the signal */
72                 TTSD_METHOD_HELLO);                     /* name of the signal */
73
74         if (NULL == msg) {
75                 SLOG(LOG_ERROR, tts_tag(), "<<<< [Dbus ERROR] Fail to create hello message : uid(%u), ret(%d), credential_needed(%d)", uid, ret, credential_needed);
76                 return -1;
77         } else {
78                 SLOG(LOG_INFO, tts_tag(), "<<<< [Dbus] Send hello message : uid(%u), ret(%d), credential_needed(%d)", uid, ret, credential_needed);
79         }
80
81         dbus_message_append_args(msg,
82                         DBUS_TYPE_UINT32, &uid,
83                         DBUS_TYPE_INT32, &ret,
84                         DBUS_TYPE_INT32, &service_state,
85                         DBUS_TYPE_INT32, &credential_needed,
86                         DBUS_TYPE_INVALID);
87
88         if (1 != dbus_connection_send(g_conn_sender, msg, NULL)) {
89                 SLOG(LOG_ERROR, tts_tag(), "[Dbus ERROR] Fail to Send");
90                 return TTSD_ERROR_OPERATION_FAILED;
91         } else {
92                 SLOG(LOG_INFO, tts_tag(), "[Dbus] SUCCESS Send");
93                 dbus_connection_flush(g_conn_sender);
94         }
95
96         dbus_message_unref(msg);
97         return 0;
98 }
99
100 static int __send_message(int pid, unsigned int uid, int data, const char *method)
101 {
102         if (NULL == g_conn_sender) {
103                 SLOG(LOG_ERROR, tts_tag(), "[Dbus ERROR] Dbus connection is not available");
104                 return -1;
105         }
106
107         DBusMessage* msg = NULL;
108
109         char target_if_name[64];
110         snprintf(target_if_name, sizeof(target_if_name), "%s%d", TTS_CLIENT_SERVICE_INTERFACE, pid);
111
112         /* create a message */
113         msg = dbus_message_new_signal(
114                 TTS_CLIENT_SERVICE_OBJECT_PATH, /* object name of the signal */
115                 target_if_name,                         /* interface name of the signal */
116                 method);                        /* name of the signal */
117
118         if (NULL == msg) {
119                 SLOG(LOG_ERROR, tts_tag(), "[Dbus ERROR] Fail to create message : %s", method);
120                 return -1;
121         } else {
122                 SLOG(LOG_DEBUG, tts_tag(), "[Dbus] Send %s message : uid(%u) data(%d)", method, uid, data);
123         }
124
125         dbus_message_append_args(msg, DBUS_TYPE_UINT32, &uid, DBUS_TYPE_INT32, &data, DBUS_TYPE_INVALID);
126
127         if (1 != dbus_connection_send(g_conn_sender, msg, NULL)) {
128                 SLOG(LOG_ERROR, tts_tag(), "[Dbus ERROR] Fail to Send");
129                 return -1;
130         } else {
131                 SLOG(LOG_DEBUG, tts_tag(), "[Dbus] SUCCESS Send");
132                 dbus_connection_flush(g_conn_sender);
133         }
134
135         dbus_message_unref(msg);
136
137         return 0;
138 }
139
140 int ttsdc_dbus_send_utt_start_message(int pid, unsigned int uid, int uttid)
141 {
142         return __send_message(pid, uid, uttid, TTSD_METHOD_UTTERANCE_STARTED);
143 }
144
145 int ttsdc_dbus_send_utt_finish_message(int pid, unsigned int uid, int uttid)
146 {
147         return __send_message(pid, uid, uttid, TTSD_METHOD_UTTERANCE_COMPLETED);
148 }
149
150 int ttsdc_dbus_send_set_state_message(int pid, unsigned int uid, int state)
151 {
152         return __send_message(pid, uid, state, TTSD_METHOD_SET_STATE);
153 }
154
155 int ttsdc_dbus_send_set_service_state_message(int pid, unsigned int uid, int before_state, int current_state)
156 {
157         if (NULL == g_conn_sender) {
158                 SLOG(LOG_ERROR, tts_tag(), "[Dbus ERROR] Dbus connection is not available");
159                 return TTSD_ERROR_OPERATION_FAILED;
160         }
161
162         DBusMessage* msg = NULL;
163
164         char target_if_name[64];
165         snprintf(target_if_name, sizeof(target_if_name), "%s%d", TTS_CLIENT_SERVICE_INTERFACE, pid);
166
167         /* create a message */
168         msg = dbus_message_new_signal(
169                 TTS_CLIENT_SERVICE_OBJECT_PATH, /* object name of the signal */
170                 target_if_name,                         /* interface name of the signal */
171                 TTSD_METHOD_SET_SERVICE_STATE);                 /* name of the signal */
172
173         if (NULL == msg) {
174                 SLOG(LOG_ERROR, tts_tag(), "[Dbus ERROR] Fail to create message : %s", TTSD_METHOD_SET_SERVICE_STATE);
175                 return TTSD_ERROR_OPERATION_FAILED;
176         } else {
177                 SLOG(LOG_DEBUG, tts_tag(), "[Dbus] Send set service state message : uid(%u) before_state(%d), current_state(%d)", uid, before_state, current_state);
178         }
179
180         dbus_message_append_args(msg, DBUS_TYPE_UINT32, &uid, DBUS_TYPE_INT32, &before_state, DBUS_TYPE_INT32, &current_state, DBUS_TYPE_INVALID);
181
182         if (1 != dbus_connection_send(g_conn_sender, msg, NULL)) {
183                 SLOG(LOG_ERROR, tts_tag(), "[Dbus ERROR] Fail to Send");
184                 return TTSD_ERROR_OPERATION_FAILED;
185         } else {
186                 SLOG(LOG_DEBUG, tts_tag(), "[Dbus] SUCCESS Send");
187                 dbus_connection_flush(g_conn_sender);
188         }
189
190         dbus_message_unref(msg);
191
192         return TTSD_ERROR_NONE;
193 }
194
195 int ttsdc_dbus_send_pcm(int pid, unsigned int uid, int uttid, int event, const void* pcm_data, int pcm_data_size, ttse_audio_type_e audio_type, int sample_rate)
196 {
197         if (NULL == g_conn_sender) {
198                 SLOG(LOG_ERROR, tts_tag(), "[Dbus ERROR] Dbus connection is not available");
199                 return -1;
200         }
201
202         DBusMessage* msg = NULL;
203
204         char target_if_name[64];
205         snprintf(target_if_name, sizeof(target_if_name), "%s%d", TTS_CLIENT_SERVICE_INTERFACE, pid);
206
207         /* create a message */
208         msg = dbus_message_new_signal(
209                 TTS_CLIENT_SERVICE_OBJECT_PATH, /* object name of the signal */
210                 target_if_name,                         /* interface name of the signal */
211                 TTSD_METHOD_SEND_PCM);          /* name of the signal */
212
213         if (NULL == msg) {
214                 SLOG(LOG_ERROR, tts_tag(), "[Dbus ERROR] Fail to create error message : uid(%u)", uid);
215                 return -1;
216         }
217
218         dbus_message_append_args(msg,
219                 DBUS_TYPE_UINT32, &uid,
220                 DBUS_TYPE_INT32, &uttid,
221                 DBUS_TYPE_INT32, &event,
222                 DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &pcm_data, pcm_data_size,
223                 DBUS_TYPE_INT32, &audio_type,
224                 DBUS_TYPE_INT32, &sample_rate,
225                 DBUS_TYPE_INVALID);
226
227         if (1 != dbus_connection_send(g_conn_sender, msg, NULL)) {
228                 SLOG(LOG_ERROR, tts_tag(), "[Dbus ERROR] Fail to Send");
229                 return TTSD_ERROR_OPERATION_FAILED;
230         } else {
231                 SLOG(LOG_DEBUG, tts_tag(), "[Dbus] SUCCESS Send");
232                 dbus_connection_flush(g_conn_sender);
233         }
234
235         dbus_message_unref(msg);
236
237         return 0;
238 }
239
240 int ttsdc_dbus_send_error_message(int pid, unsigned int uid, int uttid, int reason, char* err_msg)
241 {
242         if (NULL == g_conn_sender) {
243                 SLOG(LOG_ERROR, tts_tag(), "[Dbus ERROR] Dbus connection is not available");
244                 return -1;
245         }
246
247         DBusMessage* msg = NULL;
248
249         char target_if_name[64];
250         snprintf(target_if_name, sizeof(target_if_name), "%s%d", TTS_CLIENT_SERVICE_INTERFACE, pid);
251
252         /* create a message */
253         msg = dbus_message_new_signal(
254                 TTS_CLIENT_SERVICE_OBJECT_PATH, /* object name of the signal */
255                 target_if_name,                         /* interface name of the signal */
256                 TTSD_METHOD_ERROR);             /* name of the signal */
257
258         if (NULL == msg) {
259                 SLOG(LOG_ERROR, tts_tag(), "[Dbus ERROR] Fail to create error message : uid(%u)", uid);
260                 return -1;
261         }
262
263         dbus_message_append_args(msg,
264                 DBUS_TYPE_UINT32, &uid,
265                 DBUS_TYPE_INT32, &uttid,
266                 DBUS_TYPE_INT32, &reason,
267                 DBUS_TYPE_STRING, &err_msg,
268                 DBUS_TYPE_INVALID);
269
270         dbus_message_set_no_reply(msg, TRUE);
271
272         if (!dbus_connection_send(g_conn_sender, msg, NULL)) {
273                 SLOG(LOG_ERROR, tts_tag(), "[Dbus ERROR] <<<< error message : Out Of Memory !");
274         } else {
275                 SLOG(LOG_DEBUG, tts_tag(), "<<<< Send error message : uid(%u), reason(%s), uttid(%d), err_msg(%s)",
276                          uid, __ttsd_get_error_code(reason), uttid, (NULL == err_msg) ? "NULL" : err_msg);
277                 dbus_connection_flush(g_conn_sender);
278         }
279
280         dbus_message_unref(msg);
281
282         return 0;
283 }
284
285 static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handler)
286 {
287         if (NULL == g_conn_listener)    return ECORE_CALLBACK_RENEW;
288
289         dbus_connection_read_write_dispatch(g_conn_listener, 50);
290
291         while (1) {
292                 DBusMessage* msg = NULL;
293                 msg = dbus_connection_pop_message(g_conn_listener);
294
295                 if (true != dbus_connection_get_is_connected(g_conn_listener)) {
296                         SLOG(LOG_ERROR, tts_tag(), "[ERROR] Connection is disconnected");
297                         return ECORE_CALLBACK_RENEW;
298                 }
299
300                 /* loop again if we haven't read a message */
301                 if (NULL == msg) {
302                         return ECORE_CALLBACK_RENEW;
303                 }
304
305                 /* client event */
306                 if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_HELLO)) {
307                         ttsd_dbus_server_hello(g_conn_listener, msg);
308
309                 } else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_HELLO_SYNC)) {
310                         ttsd_dbus_server_hello_sync(g_conn_listener, msg);
311
312                 } else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_INITIALIZE)) {
313                         ttsd_dbus_server_initialize(g_conn_listener, msg);
314
315                 } else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_FINALIZE)) {
316                         ttsd_dbus_server_finalize(g_conn_listener, msg);
317
318                 } else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_GET_SUPPORT_VOICES)) {
319                         ttsd_dbus_server_get_support_voices(g_conn_listener, msg);
320
321                 } else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_GET_CURRENT_VOICE)) {
322                         ttsd_dbus_server_get_current_voice(g_conn_listener, msg);
323
324                 } else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_ADD_TEXT)) {
325                         ttsd_dbus_server_add_text(g_conn_listener, msg);
326
327                 } else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_PLAY)) {
328                         ttsd_dbus_server_play(g_conn_listener, msg);
329
330                 } else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_STOP)) {
331                         ttsd_dbus_server_stop(g_conn_listener, msg);
332
333                 } else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_PAUSE)) {
334                         ttsd_dbus_server_pause(g_conn_listener, msg);
335
336                 } else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_SET_PRIVATE_DATA)) {
337                         ttsd_dbus_server_set_private_data(g_conn_listener, msg);
338
339                 } else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_GET_PRIVATE_DATA)) {
340                         ttsd_dbus_server_get_private_data(g_conn_listener, msg);
341
342                 } else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_PLAY_PCM)) {
343                         ttsd_dbus_server_play_pcm(g_conn_listener, msg);
344
345                 } else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_STOP_PCM)) {
346                         ttsd_dbus_server_stop_pcm(g_conn_listener, msg);
347
348                 } else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_ADD_PCM)) {
349                         ttsd_dbus_server_add_pcm(g_conn_listener, msg);
350
351                 } else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_GET_SERVICE_STATE)) {
352                         ttsd_dbus_server_get_service_state(g_conn_listener, msg);
353
354                 } else {
355                         SLOG(LOG_DEBUG, tts_tag(), "Message is NOT valid");
356                         /* Invalid method */
357                 }
358                 /* free the message */
359                 dbus_message_unref(msg);
360         }
361
362         return ECORE_CALLBACK_RENEW;
363 }
364
365 void __ttsd_dbus_service_free()
366 {
367         if (NULL != g_service_name) {
368                 free(g_service_name);
369                 g_service_name = NULL;
370         }
371
372         if (NULL != g_service_object) {
373                 free(g_service_object);
374                 g_service_object = NULL;
375         }
376
377         if (NULL != g_service_interface) {
378                 free(g_service_interface);
379                 g_service_interface = NULL;
380         }
381 }
382
383 void __ttsd_dbus_connection_free()
384 {
385         if (NULL != g_conn_listener) {
386                 dbus_connection_close(g_conn_listener);
387                 dbus_connection_unref(g_conn_listener);
388                 g_conn_listener = NULL;
389         }
390         if (NULL != g_conn_sender) {
391                 dbus_connection_close(g_conn_sender);
392                 dbus_connection_unref(g_conn_sender);
393                 g_conn_sender = NULL;
394         }
395 }
396
397 int ttsd_dbus_open_connection()
398 {
399         SLOG(LOG_DEBUG, tts_tag(), "@@@ start dbus open connection");
400         DBusError err;
401         dbus_error_init(&err);
402
403         int ret;
404
405         /* Create connection for sender */
406         g_conn_sender = dbus_bus_get_private(DBUS_BUS_SYSTEM, &err);
407         if (dbus_error_is_set(&err)) {
408                 SLOG(LOG_ERROR, tts_tag(), "[Dbus ERROR] Fail dbus_bus_get : %s", err.message);
409                 dbus_error_free(&err);
410         }
411
412         if (NULL == g_conn_sender) {
413                 SLOG(LOG_ERROR, tts_tag(), "[Dbus ERROR] Fail to get dbus connection sender");
414                 return -1;
415         }
416
417         dbus_connection_set_exit_on_disconnect(g_conn_sender, false);
418
419         /* connect to the bus and check for errors */
420         g_conn_listener = dbus_bus_get_private(DBUS_BUS_SYSTEM, &err);
421         if (dbus_error_is_set(&err)) {
422                 SLOG(LOG_ERROR, tts_tag(), "[Dbus ERROR] Fail dbus_bus_get : %s", err.message);
423                 dbus_error_free(&err);
424                 __ttsd_dbus_connection_free();
425                 return -1;
426         }
427
428         if (NULL == g_conn_listener) {
429                 SLOG(LOG_ERROR, tts_tag(), "[Dbus ERROR] Fail to get dbus connection");
430                 __ttsd_dbus_connection_free();
431                 return -1;
432         }
433
434         dbus_connection_set_exit_on_disconnect(g_conn_listener, false);
435
436         __ttsd_dbus_service_free();
437
438         g_service_name = (char*)calloc(strlen(TTS_SERVER_SERVICE_NAME) + 1, sizeof(char));
439         g_service_object = (char*)calloc(strlen(TTS_SERVER_SERVICE_OBJECT_PATH) + 1, sizeof(char));
440         g_service_interface = (char*)calloc(strlen(TTS_SERVER_SERVICE_INTERFACE) + 1, sizeof(char));
441
442         if (NULL == g_service_name || NULL == g_service_object || NULL == g_service_interface) {
443                 SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to allocate memory");
444                 __ttsd_dbus_service_free();
445                 __ttsd_dbus_connection_free();
446                 return -1;
447         }
448
449         snprintf(g_service_name, strlen(TTS_SERVER_SERVICE_NAME) + 1, "%s", TTS_SERVER_SERVICE_NAME);
450         snprintf(g_service_object, strlen(TTS_SERVER_SERVICE_OBJECT_PATH) + 1, "%s", TTS_SERVER_SERVICE_OBJECT_PATH);
451         snprintf(g_service_interface, strlen(TTS_SERVER_SERVICE_INTERFACE) + 1, "%s", TTS_SERVER_SERVICE_INTERFACE);
452
453         /* request our name on the bus and check for errors */
454         ret = dbus_bus_request_name(g_conn_listener, g_service_name, DBUS_NAME_FLAG_REPLACE_EXISTING, &err);
455         if (DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret) {
456                 SLOG(LOG_ERROR, tts_tag(), "[Dbus ERROR] Fail to be primary owner");
457                 __ttsd_dbus_connection_free();
458                 return -1;
459         }
460
461         if (dbus_error_is_set(&err)) {
462                 SLOG(LOG_ERROR, tts_tag(), "[Dbus ERROR] Fail to request dbus name : %s", err.message);
463                 dbus_error_free(&err);
464                 __ttsd_dbus_connection_free();
465                 return -1;
466         }
467
468         /* Flush messages which are received before fd event handler registration */
469         while (DBUS_DISPATCH_DATA_REMAINS == dbus_connection_get_dispatch_status(g_conn_listener)) {
470                 listener_event_callback(NULL, NULL);
471         }
472
473         /* add a rule for getting signal */
474         char rule[128];
475         snprintf(rule, 128, "type='method_call',interface='%s'", g_service_interface);
476
477         /* add a rule for which messages we want to see */
478         dbus_bus_add_match(g_conn_listener, rule, &err);/* see signals from the given interface */
479         dbus_connection_flush(g_conn_listener);
480
481         if (dbus_error_is_set(&err)) {
482                 SLOG(LOG_ERROR, tts_tag(), "[Dbus ERROR] dbus_bus_add_match() : %s", err.message);
483                 __ttsd_dbus_connection_free();
484                 return -1;
485         }
486
487         int fd = 0;
488         dbus_connection_get_unix_fd(g_conn_listener, &fd);
489
490         g_dbus_fd_handler = ecore_main_fd_handler_add(fd, ECORE_FD_READ, (Ecore_Fd_Cb)listener_event_callback, g_conn_listener, NULL, NULL);
491         if (NULL == g_dbus_fd_handler) {
492                 SLOG(LOG_ERROR, tts_tag(), "[Dbus ERROR] Fail to get fd handler");
493                 __ttsd_dbus_connection_free();
494                 return -1;
495         }
496
497         SLOG(LOG_DEBUG, tts_tag(), "@@@");
498         return 0;
499 }
500
501 int ttsd_dbus_close_connection()
502 {
503         SLOG(LOG_DEBUG, tts_tag(), "@@@ start dbus close connection");
504         DBusError err;
505         dbus_error_init(&err);
506
507         if (NULL != g_dbus_fd_handler) {
508                 ecore_main_fd_handler_del(g_dbus_fd_handler);
509                 g_dbus_fd_handler = NULL;
510         }
511
512         if (NULL != g_conn_listener) {
513                 dbus_bus_release_name(g_conn_listener, g_service_name, &err);
514                 if (dbus_error_is_set(&err)) {
515                         SLOG(LOG_ERROR, tts_tag(), "[Dbus ERROR] dbus_bus_release_name() : %s", err.message);
516                         dbus_error_free(&err);
517                 }
518         }
519
520         __ttsd_dbus_connection_free();
521         __ttsd_dbus_service_free();
522
523         SLOG(LOG_DEBUG, tts_tag(), "@@@");
524
525         return 0;
526 }