static int __tts_get_feature_enabled()
{
- if (0 == g_feature_enabled) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] TTS feature NOT supported");
+ RETV_IF(1 == g_feature_enabled, TTS_ERROR_NONE);
+ RETVM_IF(0 == g_feature_enabled, TTS_ERROR_NOT_SUPPORTED, "[ERROR] TTS feature NOT supported");
+
+ bool tts_supported = false;
+ if (SYSTEM_INFO_ERROR_NONE != system_info_get_platform_bool(TTS_FEATURE_PATH, &tts_supported)) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to get feature value");
return TTS_ERROR_NOT_SUPPORTED;
- } else if (-1 == g_feature_enabled) {
- bool tts_supported = false;
- if (0 == system_info_get_platform_bool(TTS_FEATURE_PATH, &tts_supported)) {
- if (false == tts_supported) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] TTS feature NOT supported");
- g_feature_enabled = 0;
- return TTS_ERROR_NOT_SUPPORTED;
- }
+ }
- g_feature_enabled = 1;
- } else {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to get feature value");
- return TTS_ERROR_NOT_SUPPORTED;
- }
+ if (false == tts_supported) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] TTS feature NOT supported");
+ g_feature_enabled = 0;
+ return TTS_ERROR_NOT_SUPPORTED;
}
- return 0;
+ g_feature_enabled = 1;
+ return TTS_ERROR_NONE;
}
// TODO: move into tts_core to make common function
tts_core_notify_screen_reader_changed(client, value);
}
+static int __initialize_tts_config(unsigned int uid, tts_h new_tts)
+{
+ int ret = tts_config_mgr_initialize(uid, TTS_CONFIG_CLIENT_TYPE_DEFAULT);
+ if (TTS_CONFIG_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to init config manager : %d", ret);
+ return __tts_convert_config_error_code(ret);
+ }
+
+ ret = tts_config_mgr_set_callback(uid, __tts_config_engine_changed_cb, __tts_config_voice_changed_cb, NULL, NULL, NULL, new_tts);
+ if (TTS_CONFIG_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to set config changed : %d", ret);
+ tts_config_mgr_finalize(uid, TTS_CONFIG_CLIENT_TYPE_DEFAULT);
+ return __tts_convert_config_error_code(ret);
+ }
+
+ ret = tts_config_mgr_set_screen_reader_callback(uid, __tts_config_screen_reader_changed_cb, new_tts);
+ if (TTS_CONFIG_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to set config changed : %d", ret);
+ tts_config_mgr_finalize(uid, TTS_CONFIG_CLIENT_TYPE_DEFAULT);
+ return __tts_convert_config_error_code(ret);
+ }
+
+ return TTS_ERROR_NONE;
+}
+
int tts_create(tts_h* tts)
{
RETV_IF(TTS_ERROR_NONE != __tts_get_feature_enabled(), TTS_ERROR_NOT_SUPPORTED);
return TTS_ERROR_OPERATION_FAILED;
}
- int ret = tts_config_mgr_initialize(uid, TTS_CONFIG_CLIENT_TYPE_DEFAULT);
- if (0 != ret) {
+ int ret = __initialize_tts_config(uid, new_tts);
+ if (TTS_ERROR_NONE != ret) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to init config manager : %d", ret);
tts_client_destroy(new_tts);
- return __tts_convert_config_error_code(ret);
- }
-
- ret = tts_config_mgr_set_callback(uid, __tts_config_engine_changed_cb, __tts_config_voice_changed_cb, NULL, NULL, NULL, new_tts);
- if (0 != ret) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to set config changed : %d", ret);
- tts_config_mgr_finalize(uid, TTS_CONFIG_CLIENT_TYPE_DEFAULT);
- tts_client_destroy(new_tts);
- return __tts_convert_config_error_code(ret);
- }
-
- ret = tts_config_mgr_set_screen_reader_callback(uid, __tts_config_screen_reader_changed_cb, new_tts);
- if (0 != ret) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to set config changed : %d", ret);
- tts_config_mgr_finalize(uid, TTS_CONFIG_CLIENT_TYPE_DEFAULT);
- tts_client_destroy(new_tts);
- return __tts_convert_config_error_code(ret);
+ return ret;
}
if (is_first_client) {