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.
15 #include "ttsd_main.h"
16 #include "ttsd_dbus.h"
17 #include "ttsd_dbus_server.h"
18 #include "ttsd_server.h"
20 extern int ttsd_data_get_pid(const int uid);
23 * Dbus Client-Daemon Server
25 int ttsd_dbus_server_hello(DBusConnection* conn, DBusMessage* msg)
27 SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS Hello");
30 dbus_error_init(&err);
34 dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID);
36 if (dbus_error_is_set(&err)) {
37 SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] ttsd Hello : get arguments error (%s)", err.message);
38 dbus_error_free(&err);
40 SLOG(LOG_INFO, tts_tag(), "[IN] ttsd hello : pid(%d), uid(%d)", pid, uid);
41 bool is_initialized = false;
42 bool credential_needed = 0;
44 ttsd_server_is_already_initialized(pid, uid, &is_initialized);
45 if (false == is_initialized) {
46 ret = ttsd_server_initialize(pid, uid, &credential_needed);
48 SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] ttsd Hello : server initialize, ret(%d)", ret);
51 SLOG(LOG_INFO, tts_tag(), "[IN] ttsd hello : already initialized. pid(%d), uid(%d)", pid, uid);
52 ret = TTS_ERROR_ALREADY_INITIALIZED;
53 credential_needed = TTS_CREDENTIAL_NEEDED_ALREADY_INITIALIZED;
55 ttsdc_send_hello(pid, uid, ret, (int)credential_needed);
61 int ttsd_dbus_server_hello_sync(DBusConnection* conn, DBusMessage* msg)
63 SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS Hello");
66 reply = dbus_message_new_method_return(msg);
69 if (!dbus_connection_send(conn, reply, NULL)) {
70 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] Out Of Memory!");
73 dbus_connection_flush(conn);
74 dbus_message_unref(reply);
76 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] Fail to create reply message!!");
82 int ttsd_dbus_server_initialize(DBusConnection* conn, DBusMessage* msg)
85 dbus_error_init(&err);
88 bool credential_needed = 0;
91 dbus_message_get_args(msg, &err,
92 DBUS_TYPE_INT32, &pid,
93 DBUS_TYPE_INT32, &uid,
96 SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS INITIALIZE");
98 if (dbus_error_is_set(&err)) {
99 SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] tts initialize : get arguments error (%s)", err.message);
100 dbus_error_free(&err);
101 ret = TTSD_ERROR_OPERATION_FAILED;
104 SECURE_SLOG(LOG_DEBUG, tts_tag(), "[IN] tts initialize : pid(%d), uid(%d)", pid , uid);
105 ret = ttsd_server_initialize(pid, uid, &credential_needed);
109 reply = dbus_message_new_method_return(msg);
111 int temp = (int)credential_needed;
112 SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts initialize : result(%d), credential_needed(%d)", ret, (int)credential_needed);
114 dbus_message_append_args(reply,
115 DBUS_TYPE_INT32, &ret,
116 DBUS_TYPE_INT32, &temp,
120 SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts initialize : result(%d), credential_needed(%d)", ret, credential_needed);
122 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts initialize : result(%d)", ret);
125 if (!dbus_connection_send(conn, reply, NULL)) {
126 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts initialize : Out Of Memory!");
129 dbus_connection_flush(conn);
130 dbus_message_unref(reply);
132 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts initialize : Fail to create reply message!!");
138 int ttsd_dbus_server_finalize(DBusConnection* conn, DBusMessage* msg)
141 dbus_error_init(&err);
146 dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID);
148 SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS FINALIZE");
150 if (dbus_error_is_set(&err)) {
151 SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] tts finalize : get arguments error (%s)", err.message);
152 dbus_error_free(&err);
153 ret = TTSD_ERROR_OPERATION_FAILED;
155 SECURE_SLOG(LOG_DEBUG, tts_tag(), "[IN] tts finalize : uid(%d)", uid);
156 ret = ttsd_server_finalize(uid);
160 reply = dbus_message_new_method_return(msg);
163 dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
166 SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts finalize : result(%d)", ret);
168 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts finalize : result(%d)", ret);
171 if (!dbus_connection_send(conn, reply, NULL)) {
172 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts finalize : Out Of Memory!");
175 dbus_connection_flush(conn);
176 dbus_message_unref(reply);
178 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts finalize : Fail to create reply message!!");
184 int ttsd_dbus_server_get_support_voices(DBusConnection* conn, DBusMessage* msg)
187 dbus_error_init(&err);
191 GList* voice_list = NULL;
193 dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID);
195 SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS GET VOICES");
197 if (dbus_error_is_set(&err)) {
198 SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] tts get supported voices : get arguments error (%s)", err.message);
199 dbus_error_free(&err);
200 ret = TTSD_ERROR_OPERATION_FAILED;
202 SECURE_SLOG(LOG_DEBUG, tts_tag(), "[IN] get supported voices : uid(%d)", uid);
203 ret = ttsd_server_get_support_voices(uid, &voice_list);
207 reply = dbus_message_new_method_return(msg);
210 DBusMessageIter args;
211 dbus_message_iter_init_append(reply, &args);
214 dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(ret));
217 /* Append voice size */
218 int size = g_list_length(voice_list);
220 if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(size))) {
221 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts supported voices : Fail to append type");
222 ret = TTSD_ERROR_OPERATION_FAILED;
228 iter = g_list_first(voice_list);
230 while (NULL != iter) {
234 dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(voice->language));
235 dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(voice->type));
237 if (NULL != voice->language)
238 g_free(voice->language);
243 voice_list = g_list_remove_link(voice_list, iter);
245 iter = g_list_first(voice_list);
248 SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts supported voices : result(%d)", ret);
250 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts supported voices : result(%d)", ret);
253 if (!dbus_connection_send(conn, reply, NULL)) {
254 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] error : Out Of Memory!");
257 dbus_connection_flush(conn);
258 dbus_message_unref(reply);
260 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts supported voices : Fail to create reply message!!");
266 int ttsd_dbus_server_get_current_voice(DBusConnection* conn, DBusMessage* msg)
269 dbus_error_init(&err);
276 dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID);
278 SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS GET DEFAULT VOICE");
280 if (dbus_error_is_set(&err)) {
281 SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] tts get default voice : Get arguments error (%s)", err.message);
282 dbus_error_free(&err);
283 ret = TTSD_ERROR_OPERATION_FAILED;
285 SECURE_SLOG(LOG_DEBUG, tts_tag(), "[IN] tts get default voice : uid(%d)", uid);
286 ret = ttsd_server_get_current_voice(uid, &lang, &voice_type);
290 reply = dbus_message_new_method_return(msg);
294 /* Append result and voice */
295 dbus_message_append_args(reply,
296 DBUS_TYPE_INT32, &ret,
297 DBUS_TYPE_STRING, &lang,
298 DBUS_TYPE_INT32, &voice_type,
300 SECURE_SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts default voice : lang(%s), vctype(%d)", lang, voice_type);
302 dbus_message_append_args(reply,
303 DBUS_TYPE_INT32, &ret,
305 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts default voice : result(%d)", ret);
308 if (!dbus_connection_send(conn, reply, NULL)) {
309 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts default voice : Out Of Memory!");
312 dbus_connection_flush(conn);
313 dbus_message_unref(reply);
315 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts default voice : Fail to create reply message!!");
318 if (NULL != lang) free(lang);
322 int ttsd_dbus_server_add_text(DBusConnection* conn, DBusMessage* msg)
325 dbus_error_init(&err);
327 int uid, voicetype, speed, uttid;
328 char *text, *lang, *credential;
331 dbus_message_get_args(msg, &err,
332 DBUS_TYPE_INT32, &uid,
333 DBUS_TYPE_STRING, &text,
334 DBUS_TYPE_STRING, &lang,
335 DBUS_TYPE_INT32, &voicetype,
336 DBUS_TYPE_INT32, &speed,
337 DBUS_TYPE_INT32, &uttid,
338 DBUS_TYPE_STRING, &credential,
341 SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS ADD TEXT");
343 if (dbus_error_is_set(&err)) {
344 SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] tts add text : Get arguments error (%s)", err.message);
345 dbus_error_free(&err);
346 ret = TTSD_ERROR_OPERATION_FAILED;
348 SECURE_SLOG(LOG_DEBUG, tts_tag(), "[IN] tts add text : uid(%d), text(%s), lang(%s), type(%d), speed(%d), uttid(%d), credential(%s)",
349 uid, (NULL == text) ? "NULL" : text, (NULL == lang) ? "NULL" : lang, voicetype, speed, uttid, (NULL == credential) ? "NULL" : credential);
350 ret = ttsd_server_add_queue(uid, text, lang, voicetype, speed, uttid, credential);
354 reply = dbus_message_new_method_return(msg);
357 dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
360 SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts add text : result(%d)", ret);
362 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts add text : result(%d)", ret);
365 if (!dbus_connection_send(conn, reply, NULL)) {
366 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts add text : Out Of Memory!");
369 dbus_connection_flush(conn);
370 dbus_message_unref(reply);
372 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts add text : Fail to create reply message!!");
375 SLOG(LOG_DEBUG, tts_tag(), "<<<<<");
376 SLOG(LOG_DEBUG, tts_tag(), " ");
381 int ttsd_dbus_server_play(DBusConnection* conn, DBusMessage* msg)
384 dbus_error_init(&err);
390 dbus_message_get_args(msg, &err,
391 DBUS_TYPE_INT32, &uid,
392 DBUS_TYPE_STRING, &credential,
395 SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS PLAY");
397 if (dbus_error_is_set(&err)) {
398 SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] tts play : Get arguments error (%s)", err.message);
399 dbus_error_free(&err);
400 ret = TTSD_ERROR_OPERATION_FAILED;
402 SECURE_SLOG(LOG_DEBUG, tts_tag(), "[IN] tts play : uid(%d), credential(%s)", uid, (NULL == credential) ? "NULL" : credential);
403 ret = ttsd_server_play(uid, credential);
407 reply = dbus_message_new_method_return(msg);
410 dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
413 SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts play : result(%d)", ret);
415 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts play : result(%d)", ret);
418 if (!dbus_connection_send(conn, reply, NULL)) {
419 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts play : Out Of Memory!");
422 dbus_connection_flush(conn);
423 dbus_message_unref(reply);
425 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts play : Fail to create reply message!!");
428 SLOG(LOG_DEBUG, tts_tag(), "<<<<<");
429 SLOG(LOG_DEBUG, tts_tag(), " ");
434 int ttsd_dbus_server_stop(DBusConnection* conn, DBusMessage* msg)
437 dbus_error_init(&err);
441 dbus_message_get_args(msg, &err,
442 DBUS_TYPE_INT32, &uid,
445 SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS STOP");
447 if (dbus_error_is_set(&err)) {
448 SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] tts stop : Get arguments error (%s)", err.message);
449 dbus_error_free(&err);
450 ret = TTSD_ERROR_OPERATION_FAILED;
452 SECURE_SLOG(LOG_DEBUG, tts_tag(), "[IN] tts stop : uid(%d)", uid);
453 ret = ttsd_server_stop(uid);
457 reply = dbus_message_new_method_return(msg);
460 dbus_message_append_args(reply,
461 DBUS_TYPE_INT32, &ret,
465 SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts stop : result(%d)", ret);
467 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts stop : result(%d)", ret);
470 if (!dbus_connection_send(conn, reply, NULL)) {
471 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts stop : Out Of Memory!");
474 dbus_connection_flush(conn);
475 dbus_message_unref(reply);
477 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts stop : Fail to create reply message!!");
480 SLOG(LOG_DEBUG, tts_tag(), "<<<<<");
481 SLOG(LOG_DEBUG, tts_tag(), " ");
486 int ttsd_dbus_server_pause(DBusConnection* conn, DBusMessage* msg)
489 dbus_error_init(&err);
494 dbus_message_get_args(msg, &err,
495 DBUS_TYPE_INT32, &uid,
498 SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS PAUSE");
500 if (dbus_error_is_set(&err)) {
501 SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] tts pause : Get arguments error (%s)", err.message);
502 dbus_error_free(&err);
503 ret = TTSD_ERROR_OPERATION_FAILED;
505 SECURE_SLOG(LOG_DEBUG, tts_tag(), "[IN] tts pause : uid(%d)", uid);
506 ret = ttsd_server_pause(uid, &uttid);
510 reply = dbus_message_new_method_return(msg);
513 dbus_message_append_args(reply,
514 DBUS_TYPE_INT32, &ret,
518 SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts pause : result(%d)", ret);
520 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts pause : result(%d)", ret);
523 if (!dbus_connection_send(conn, reply, NULL)) {
524 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts pause : Out Of Memory!");
527 dbus_connection_flush(conn);
528 dbus_message_unref(reply);
530 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts pause : Fail to create reply message!!");
533 SLOG(LOG_DEBUG, tts_tag(), "<<<<<");
534 SLOG(LOG_DEBUG, tts_tag(), " ");
539 int ttsd_dbus_server_set_private_data(DBusConnection* conn, DBusMessage* msg)
542 dbus_error_init(&err);
548 dbus_message_get_args(msg, &err,
549 DBUS_TYPE_INT32, &uid,
550 DBUS_TYPE_STRING, &key,
551 DBUS_TYPE_STRING, &data,
554 SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS set private data");
556 if (dbus_error_is_set(&err)) {
557 SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] Fail to get arguments (%s)", err.message);
558 dbus_error_free(&err);
559 ret = TTSD_ERROR_OPERATION_FAILED;
561 SLOG(LOG_DEBUG, tts_tag(), "[IN] tts set private data(%d)", uid);
562 ret = ttsd_server_set_private_data(uid, key, data);
566 reply = dbus_message_new_method_return(msg);
569 dbus_message_append_args(reply,
570 DBUS_TYPE_INT32, &ret,
574 SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts set private data : (%d)", ret);
576 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts set private data : (%d)", ret);
579 if (!dbus_connection_send(conn, reply, NULL)) {
580 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] Fail to send reply");
583 dbus_connection_flush(conn);
584 dbus_message_unref(reply);
586 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] Fail to create reply message");
589 SLOG(LOG_DEBUG, tts_tag(), "<<<<<");
590 SLOG(LOG_DEBUG, tts_tag(), "");
595 int ttsd_dbus_server_get_private_data(DBusConnection* conn, DBusMessage* msg)
598 dbus_error_init(&err);
604 dbus_message_get_args(msg, &err,
605 DBUS_TYPE_INT32, &uid,
606 DBUS_TYPE_STRING, &key,
609 SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS get private data");
611 if (dbus_error_is_set(&err)) {
612 SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] Fail to get arguments (%s)", err.message);
613 dbus_error_free(&err);
614 ret = TTSD_ERROR_OPERATION_FAILED;
616 SLOG(LOG_DEBUG, tts_tag(), "[IN] tts get private data(%d)", uid);
617 ret = ttsd_server_get_private_data(uid, key, &data);
621 reply = dbus_message_new_method_return(msg);
624 dbus_message_append_args(reply,
625 DBUS_TYPE_INT32, &ret,
626 DBUS_TYPE_STRING, &data,
630 SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts get private data : Result(%d), data(%s)", ret, (NULL == data) ? "NULL" : data);
632 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts get private data : (%d)", ret);
635 if (!dbus_connection_send(conn, reply, NULL)) {
636 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] Fail to send reply");
639 dbus_connection_flush(conn);
640 dbus_message_unref(reply);
642 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] Fail to create reply message");
645 SLOG(LOG_DEBUG, tts_tag(), "<<<<<");
646 SLOG(LOG_DEBUG, tts_tag(), "");
656 int ttsd_dbus_server_play_pcm(DBusConnection* conn, DBusMessage* msg)
659 dbus_error_init(&err);
664 dbus_message_get_args(msg, &err,
665 DBUS_TYPE_INT32, &uid,
668 SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS PLAY PCM");
670 if (dbus_error_is_set(&err)) {
671 SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] tts play pcm : Get arguments error (%s)", err.message);
672 dbus_error_free(&err);
673 ret = TTSD_ERROR_OPERATION_FAILED;
675 SECURE_SLOG(LOG_DEBUG, tts_tag(), "[IN] tts play pcm : uid(%d)", uid);
676 ret = ttsd_server_play_pcm(uid);
680 reply = dbus_message_new_method_return(msg);
683 dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
686 SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts play pcm : result(%d)", ret);
688 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts play pcm : result(%d)", ret);
691 if (!dbus_connection_send(conn, reply, NULL)) {
692 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts play pcm : Out Of Memory!");
695 dbus_connection_flush(conn);
696 dbus_message_unref(reply);
698 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts play pcm : Fail to create reply message!!");
701 SLOG(LOG_DEBUG, tts_tag(), "<<<<<");
702 SLOG(LOG_DEBUG, tts_tag(), " ");
707 int ttsd_dbus_server_stop_pcm(DBusConnection* conn, DBusMessage* msg)
710 dbus_error_init(&err);
715 dbus_message_get_args(msg, &err,
716 DBUS_TYPE_INT32, &uid,
719 SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS STOP PCM");
721 if (dbus_error_is_set(&err)) {
722 SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] tts stop pcm : Get arguments error (%s)", err.message);
723 dbus_error_free(&err);
724 ret = TTSD_ERROR_OPERATION_FAILED;
726 SECURE_SLOG(LOG_DEBUG, tts_tag(), "[IN] tts stop pcm : uid(%d)", uid);
727 ret = ttsd_server_stop_pcm(uid);
731 reply = dbus_message_new_method_return(msg);
734 dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
737 SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts stop pcm : result(%d)", ret);
739 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts stop pcm : result(%d)", ret);
742 if (!dbus_connection_send(conn, reply, NULL)) {
743 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts stop pcm : Out Of Memory!");
746 dbus_connection_flush(conn);
747 dbus_message_unref(reply);
749 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts stop pcm : Fail to create reply message!!");
752 SLOG(LOG_DEBUG, tts_tag(), "<<<<<");
753 SLOG(LOG_DEBUG, tts_tag(), " ");
758 int ttsd_dbus_server_add_pcm(DBusConnection* conn, DBusMessage* msg)
761 dbus_error_init(&err);
771 dbus_message_get_args(msg, &err,
772 DBUS_TYPE_INT32, &uid,
773 DBUS_TYPE_INT32, &event,
774 DBUS_TYPE_INT32, &audio_type,
775 DBUS_TYPE_INT32, &rate,
776 //DBUS_TYPE_STRING, &data,
777 //DBUS_TYPE_INT32, &data_size,
778 DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE,
782 SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS ADD PCM");
784 if (dbus_error_is_set(&err)) {
785 SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] tts add pcm : Get arguments error (%s)", err.message);
786 dbus_error_free(&err);
787 ret = TTSD_ERROR_OPERATION_FAILED;
789 SECURE_SLOG(LOG_DEBUG, tts_tag(), "[IN] tts add pcm : uid(%d)", uid);
790 ret = ttsd_server_add_pcm(uid, event, (void*)data, data_size, audio_type, rate);
794 reply = dbus_message_new_method_return(msg);
797 dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
800 SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts add pcm : result(%d)", ret);
802 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts add pcm : result(%d)", ret);
805 if (!dbus_connection_send(conn, reply, NULL)) {
806 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts add pcm : Out Of Memory!");
809 dbus_connection_flush(conn);
810 dbus_message_unref(reply);
812 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts add pcm : Fail to create reply message!!");
815 SLOG(LOG_DEBUG, tts_tag(), "<<<<<");
816 SLOG(LOG_DEBUG, tts_tag(), " ");