}
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 {
~AudioStream();
int setAudioFormat(ttse_audio_type_e type, int rate);
- int acquireSoundFocus(const char* extra_info);
+ int acquireSoundFocus();
int releaseSoundFocus();
int prepareAudioOut();
int unprepareAudioOut();
bool __prepared;
sound_stream_info_h __streamInfo;
- std::string __currentExtraInfo;
bool __focusAquired;
AudioState __state;
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;
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;
}
__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) {
return "ttsd";
}
-ttsd_mode_e ttsd_get_mode()
-{
- return TTSD_MODE_DEFAULT;
-}
/*
-* 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
} 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();
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);
}
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) {
#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()
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");
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();