From: Suyeon Hwang Date: Wed, 19 Jan 2022 07:02:39 +0000 (+0900) Subject: Remove code for mode of service engine X-Git-Tag: submit/tizen/20220325.021820~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=17fd0e26e815314de853a7f9c5bfbfba8ff29aa7;p=platform%2Fcore%2Fuifw%2Ftts.git Remove code for mode of service engine Change-Id: I49ca352cd1dc35a9404903079467277445a35af8 Signed-off-by: Suyeon Hwang --- diff --git a/server/AudioStream.cpp b/server/AudioStream.cpp index 8c7b98b..e90704a 100644 --- a/server/AudioStream.cpp +++ b/server/AudioStream.cpp @@ -90,23 +90,16 @@ int AudioStream::setAudioFormat(ttse_audio_type_e type, int rate) } if (__focusAquired) { - const char* extra_info = __currentExtraInfo.empty() ? nullptr : __currentExtraInfo.c_str(); - acquireSoundFocus(extra_info); + acquireSoundFocus(); } __state = AUDIO_STATE_READY; return TTSD_ERROR_NONE; } -int AudioStream::acquireSoundFocus(const char* extra_info) +int AudioStream::acquireSoundFocus() { - if (nullptr == extra_info) { - __currentExtraInfo.clear(); - } else { - __currentExtraInfo.assign(extra_info); - } - - int ret = sound_manager_acquire_focus(__streamInfo, SOUND_STREAM_FOCUS_FOR_PLAYBACK, SOUND_BEHAVIOR_NONE, extra_info); + int ret = sound_manager_acquire_focus(__streamInfo, SOUND_STREAM_FOCUS_FOR_PLAYBACK, SOUND_BEHAVIOR_NONE, nullptr); if (SOUND_MANAGER_ERROR_NONE != ret) { SLOG(LOG_WARN, tts_tag(), "[AudioStream] Fail to acquire focus. ret(%s)", get_error_message(ret)); } else { diff --git a/server/AudioStream.h b/server/AudioStream.h index 36dcc11..332eae9 100644 --- a/server/AudioStream.h +++ b/server/AudioStream.h @@ -35,7 +35,7 @@ public: ~AudioStream(); int setAudioFormat(ttse_audio_type_e type, int rate); - int acquireSoundFocus(const char* extra_info); + int acquireSoundFocus(); int releaseSoundFocus(); int prepareAudioOut(); int unprepareAudioOut(); @@ -61,7 +61,6 @@ private: bool __prepared; sound_stream_info_h __streamInfo; - std::string __currentExtraInfo; bool __focusAquired; AudioState __state; diff --git a/server/ttsd_config.c b/server/ttsd_config.c index ee00405..e5bd49b 100644 --- a/server/ttsd_config.c +++ b/server/ttsd_config.c @@ -100,9 +100,7 @@ int ttsd_config_initialize(ttsd_config_changed_cb config_cb) g_callback = config_cb; g_sr_callback = NULL; - int ret = -1; - tts_config_client_type_e type = TTSD_MODE_INTERRUPT == ttsd_get_mode() ? TTS_CONFIG_CLIENT_TYPE_INTERRUPT : TTS_CONFIG_CLIENT_TYPE_SERVER; - ret = tts_config_mgr_initialize(getpid(), type); + int ret = tts_config_mgr_initialize(getpid(), TTS_CONFIG_CLIENT_TYPE_SERVER); if (0 != ret) { SLOG(LOG_ERROR, tts_tag(), "[Config] Fail to initialize config manager"); return -1; @@ -121,9 +119,7 @@ int ttsd_config_initialize(ttsd_config_changed_cb config_cb) int ttsd_config_finalize() { tts_config_mgr_unset_screen_reader_callback(getpid()); - - tts_config_client_type_e type = TTSD_MODE_INTERRUPT == ttsd_get_mode() ? TTS_CONFIG_CLIENT_TYPE_INTERRUPT : TTS_CONFIG_CLIENT_TYPE_SERVER; - tts_config_mgr_finalize(getpid(), type); + tts_config_mgr_finalize(getpid(), TTS_CONFIG_CLIENT_TYPE_SERVER); return 0; } diff --git a/server/ttsd_dbus.c b/server/ttsd_dbus.c index fe19cf4..57ced0b 100644 --- a/server/ttsd_dbus.c +++ b/server/ttsd_dbus.c @@ -345,68 +345,21 @@ int ttsd_dbus_open_connection() __ttsd_dbus_service_free(); - if (TTSD_MODE_SCREEN_READER == ttsd_get_mode()) { - g_service_name = (char*)calloc(strlen(TTS_SR_SERVER_SERVICE_NAME) + 1, sizeof(char)); - g_service_object = (char*)calloc(strlen(TTS_SR_SERVER_SERVICE_OBJECT_PATH) + 1, sizeof(char)); - g_service_interface = (char*)calloc(strlen(TTS_SR_SERVER_SERVICE_INTERFACE) + 1, sizeof(char)); - - if (NULL == g_service_name || NULL == g_service_object || NULL == g_service_interface) { - SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to allocate memory"); - __ttsd_dbus_service_free(); - __ttsd_dbus_connection_free(); - return -1; - } - - snprintf(g_service_name, strlen(TTS_SR_SERVER_SERVICE_NAME) + 1, "%s", TTS_SR_SERVER_SERVICE_NAME); - snprintf(g_service_object, strlen(TTS_SR_SERVER_SERVICE_OBJECT_PATH) + 1, "%s", TTS_SR_SERVER_SERVICE_OBJECT_PATH); - snprintf(g_service_interface, strlen(TTS_SR_SERVER_SERVICE_INTERFACE) + 1, "%s", TTS_SR_SERVER_SERVICE_INTERFACE); - } else if (TTSD_MODE_NOTIFICATION == ttsd_get_mode()) { - g_service_name = (char*)calloc(strlen(TTS_NOTI_SERVER_SERVICE_NAME) + 1, sizeof(char)); - g_service_object = (char*)calloc(strlen(TTS_NOTI_SERVER_SERVICE_OBJECT_PATH) + 1, sizeof(char)); - g_service_interface = (char*)calloc(strlen(TTS_NOTI_SERVER_SERVICE_INTERFACE) + 1, sizeof(char)); - - if (NULL == g_service_name || NULL == g_service_object || NULL == g_service_interface) { - SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to allocate memory"); - __ttsd_dbus_service_free(); - __ttsd_dbus_connection_free(); - return -1; - } + g_service_name = (char*)calloc(strlen(TTS_SERVER_SERVICE_NAME) + 1, sizeof(char)); + g_service_object = (char*)calloc(strlen(TTS_SERVER_SERVICE_OBJECT_PATH) + 1, sizeof(char)); + g_service_interface = (char*)calloc(strlen(TTS_SERVER_SERVICE_INTERFACE) + 1, sizeof(char)); - snprintf(g_service_name, strlen(TTS_NOTI_SERVER_SERVICE_NAME) + 1, "%s", TTS_NOTI_SERVER_SERVICE_NAME); - snprintf(g_service_object, strlen(TTS_NOTI_SERVER_SERVICE_OBJECT_PATH) + 1, "%s", TTS_NOTI_SERVER_SERVICE_OBJECT_PATH); - snprintf(g_service_interface, strlen(TTS_NOTI_SERVER_SERVICE_INTERFACE) + 1, "%s", TTS_NOTI_SERVER_SERVICE_INTERFACE); - } else if (TTSD_MODE_INTERRUPT == ttsd_get_mode()) { - g_service_name = (char*)calloc(strlen(TTS_INTERRUPT_SERVER_SERVICE_NAME) + 1, sizeof(char)); - g_service_object = (char*)calloc(strlen(TTS_INTERRUPT_SERVER_SERVICE_OBJECT_PATH) + 1, sizeof(char)); - g_service_interface = (char*)calloc(strlen(TTS_INTERRUPT_SERVER_SERVICE_INTERFACE) + 1, sizeof(char)); - - if (NULL == g_service_name || NULL == g_service_object || NULL == g_service_interface) { - SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to allocate memory"); - __ttsd_dbus_service_free(); - __ttsd_dbus_connection_free(); - return -1; - } - - snprintf(g_service_name, strlen(TTS_INTERRUPT_SERVER_SERVICE_NAME) + 1, "%s", TTS_INTERRUPT_SERVER_SERVICE_NAME); - snprintf(g_service_object, strlen(TTS_INTERRUPT_SERVER_SERVICE_OBJECT_PATH) + 1, "%s", TTS_INTERRUPT_SERVER_SERVICE_OBJECT_PATH); - snprintf(g_service_interface, strlen(TTS_INTERRUPT_SERVER_SERVICE_INTERFACE) + 1, "%s", TTS_INTERRUPT_SERVER_SERVICE_INTERFACE); - } else { - g_service_name = (char*)calloc(strlen(TTS_SERVER_SERVICE_NAME) + 1, sizeof(char)); - g_service_object = (char*)calloc(strlen(TTS_SERVER_SERVICE_OBJECT_PATH) + 1, sizeof(char)); - g_service_interface = (char*)calloc(strlen(TTS_SERVER_SERVICE_INTERFACE) + 1, sizeof(char)); - - if (NULL == g_service_name || NULL == g_service_object || NULL == g_service_interface) { - SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to allocate memory"); - __ttsd_dbus_service_free(); - __ttsd_dbus_connection_free(); - return -1; - } - - snprintf(g_service_name, strlen(TTS_SERVER_SERVICE_NAME) + 1, "%s", TTS_SERVER_SERVICE_NAME); - snprintf(g_service_object, strlen(TTS_SERVER_SERVICE_OBJECT_PATH) + 1, "%s", TTS_SERVER_SERVICE_OBJECT_PATH); - snprintf(g_service_interface, strlen(TTS_SERVER_SERVICE_INTERFACE) + 1, "%s", TTS_SERVER_SERVICE_INTERFACE); + if (NULL == g_service_name || NULL == g_service_object || NULL == g_service_interface) { + SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to allocate memory"); + __ttsd_dbus_service_free(); + __ttsd_dbus_connection_free(); + return -1; } + snprintf(g_service_name, strlen(TTS_SERVER_SERVICE_NAME) + 1, "%s", TTS_SERVER_SERVICE_NAME); + snprintf(g_service_object, strlen(TTS_SERVER_SERVICE_OBJECT_PATH) + 1, "%s", TTS_SERVER_SERVICE_OBJECT_PATH); + snprintf(g_service_interface, strlen(TTS_SERVER_SERVICE_INTERFACE) + 1, "%s", TTS_SERVER_SERVICE_INTERFACE); + /* request our name on the bus and check for errors */ ret = dbus_bus_request_name(g_conn_listener, g_service_name, DBUS_NAME_FLAG_REPLACE_EXISTING, &err); if (DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret) { diff --git a/server/ttsd_main.c b/server/ttsd_main.c index d39f657..3892402 100644 --- a/server/ttsd_main.c +++ b/server/ttsd_main.c @@ -27,7 +27,3 @@ const char* tts_tag() return "ttsd"; } -ttsd_mode_e ttsd_get_mode() -{ - return TTSD_MODE_DEFAULT; -} diff --git a/server/ttsd_main.h b/server/ttsd_main.h index 306e799..4aef762 100644 --- a/server/ttsd_main.h +++ b/server/ttsd_main.h @@ -1,5 +1,5 @@ /* -* Copyright (c) 2011-2016 Samsung Electronics Co., Ltd All Rights Reserved +* Copyright (c) 2011-2016 Samsung Electronics Co., Ltd All Rights Reserved * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -101,9 +101,6 @@ typedef struct { } tts_engine_callback_s; -/* get daemon mode : default, notification or screen reader */ -ttsd_mode_e ttsd_get_mode(); - /* Get log tag : default, notification, screen reader */ //const char* get_tag(); const char* tts_tag(); diff --git a/server/ttsd_player.cpp b/server/ttsd_player.cpp index a8332e4..2e59bc4 100644 --- a/server/ttsd_player.cpp +++ b/server/ttsd_player.cpp @@ -130,12 +130,7 @@ static void __write_buffer_dump_file(const void* buffer, size_t length) static void __set_policy_for_playing(void) { - const char* extra_info = nullptr; - if (TTSD_MODE_INTERRUPT == ttsd_get_mode()) { - extra_info = "TTSD_MODE_INTERRUPT"; - } - - g_audio_stream->acquireSoundFocus(extra_info); + g_audio_stream->acquireSoundFocus(); g_background_volume->applyVolumeRatio(); g_is_set_policy = true; SLOG(LOG_ERROR, tts_tag(), "[BG] g_is_set_policy(%d)", g_is_set_policy); diff --git a/server/ttsd_server.c b/server/ttsd_server.c index 83218dd..c310737 100644 --- a/server/ttsd_server.c +++ b/server/ttsd_server.c @@ -515,10 +515,7 @@ int ttsd_initialize(ttse_request_callback_s *callback) } ttsd_set_synth_control(TTSD_SYNTHESIS_CONTROL_EXPIRED); - -// if (TTSD_MODE_SCREEN_READER == ttsd_get_mode()) { - ttsd_config_set_screen_reader_callback(__screen_reader_changed_cb); -// } + 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); if (NULL == g_check_client_timer) { diff --git a/server/ttse.c b/server/ttse.c index 8aa277d..89fd48e 100755 --- a/server/ttse.c +++ b/server/ttse.c @@ -27,31 +27,11 @@ #include "ttse.h" -static ttsd_mode_e g_tts_mode = TTSD_MODE_DEFAULT; static bool g_is_terminated = false; const char* tts_tag() { - if (TTSD_MODE_NOTIFICATION == g_tts_mode) { - return "ttsdnoti"; - } else if (TTSD_MODE_SCREEN_READER == g_tts_mode) { - return "ttsdsr"; - } else if (TTSD_MODE_INTERRUPT == g_tts_mode) { - return "ttsdinterrupt"; - } else { - return "ttsd"; - } -} - -ttsd_mode_e ttsd_get_mode() -{ - return g_tts_mode; -} - -void ttsd_set_mode(ttsd_mode_e mode) -{ - g_tts_mode = mode; - return; + return "ttsd"; } static bool __is_default_engine() @@ -77,42 +57,6 @@ static bool __is_default_engine() return FALSE; } -static ttsd_mode_e __get_mode_from_appid() -{ - int pid = getpid(); - char* appid = NULL; - int ret = app_manager_get_app_id(pid, &appid); - - if (0 != ret || NULL == appid) { - return TTSD_MODE_DEFAULT; - } - - SLOG(LOG_WARN, tts_tag(), "[WARNING] appid (%s)", appid); - char* token = strtok(appid, "-"); - char* last = NULL; - while (NULL != token) { - last = token; - token = strtok(NULL, "-"); - } - - ttsd_mode_e mode = TTSD_MODE_DEFAULT; - if (NULL != last) { - if (!strncmp("noti", last, strlen(last))) { - mode = TTSD_MODE_NOTIFICATION; - } else if (!strncmp("sr", last, strlen(last))) { - mode = TTSD_MODE_SCREEN_READER; - } else if (!strncmp("interrupt", last, strlen(last))) { - mode = TTSD_MODE_INTERRUPT; - } else { - SLOG(LOG_INFO, tts_tag(), "[INFO] mode (%s)", last); - } - } - - free(appid); - - return mode; -} - static void __engine_changed_cb(keynode_t* key, void* data) { SLOG(LOG_INFO, tts_tag(), "[INFO] TTS engine vconfkey is changed"); @@ -150,49 +94,14 @@ static bool __is_test_app() int ttse_main(int argc, char** argv, ttse_request_callback_s *callback) { - bundle *b = NULL; - ttsd_mode_e mode = TTSD_MODE_DEFAULT; - int ret = TTSE_ERROR_NONE; g_is_terminated = false; - b = bundle_import_from_argv(argc, argv); - if (NULL != b) { - char *val = NULL; - if (0 == bundle_get_str(b, "mode", &val)) { - if (NULL != val) { - if (!strcmp("noti", val)) { - mode = TTSD_MODE_NOTIFICATION; - } else if (!strcmp("sr", val)) { - mode = TTSD_MODE_SCREEN_READER; - } else if (!strcmp("interrupt", val)) { - mode = TTSD_MODE_INTERRUPT; - } else { - SLOG(LOG_WARN, tts_tag(), "[WARNING] mode (%s)", val); - } - } else { - SLOG(LOG_ERROR, tts_tag(), "[ERROR] NULL data"); - } - } else { - SLOG(LOG_INFO, tts_tag(), "[INFO] Get mode value from app ID"); - mode = __get_mode_from_appid(); - } - - bundle_free(b); - val = NULL; - } else { - SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to get bundle"); - } - - ttsd_set_mode(mode); - - SLOG(LOG_DEBUG, tts_tag(), "Start engine as [%d] mode", mode); - if (!ecore_init()) { SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to initialize Ecore"); return TTSE_ERROR_OPERATION_FAILED; } - ret = ttsd_initialize(callback); + int ret = ttsd_initialize(callback); if (0 != ret) { SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to initialize"); ecore_shutdown();