From: Suyeon Hwang Date: Fri, 16 Feb 2024 11:35:46 +0000 (+0900) Subject: Save volume ratio as integer value to the config file X-Git-Tag: accepted/tizen/8.0/unified/20240222.093838~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5d5c4f839e1b659d02c8e93a8c2a80552363d077;p=platform%2Fcore%2Fuifw%2Ftts.git Save volume ratio as integer value to the config file - Issue: According to the app locale, sometimes the framework can fail to get proper background volume ratio value from the configuration file. - Solution: This patch fixes the logic for saving background volume ratio value. According to the spec. of snprintf() and atof(), these functions are affected by the app locale. Thus, the app can represent the floating point value with different way by the locale. And this can cause the failure of getting proper value. To avoid this situation, this patch converts the volume ratio as integer value. Through this change, the locale will not affect the representation for the volume ratio. Change-Id: Ieb5c80098b91d56801b98183e8c524db6cf1b0bc Signed-off-by: Suyeon Hwang --- diff --git a/common/tts_config_parser.c b/common/tts_config_parser.c index 901b09ad..eb1f1030 100644 --- a/common/tts_config_parser.c +++ b/common/tts_config_parser.c @@ -45,6 +45,7 @@ #define TTS_TAG_VOICE_TYPE_CHILD "child" #define TTS_MAX_TEXT_SIZE 2000 +#define VOLUME_BASE_VALUE 1000.0 static xmlDocPtr g_config_doc = NULL; char g_engine_id[128] = {0,}; @@ -540,7 +541,7 @@ int tts_parser_load_config(void) } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)TTS_TAG_CONFIG_BACKGROUND_VOLUME_RATIO)) { xmlChar *key = xmlNodeGetContent(cur); if (NULL != key) { - temp->bg_volume_ratio = atof((char*)key); + temp->bg_volume_ratio = atoi((char*)key) / VOLUME_BASE_VALUE; xmlFree(key); key = NULL; } else { @@ -859,7 +860,7 @@ int tts_parser_set_bg_volume_ratio(double value) { char temp[10]; memset(temp, '\0', 10); - snprintf(temp, 10, "%lf", value); + snprintf(temp, 10, "%d", (int)(value * VOLUME_BASE_VALUE)); if (0 != __set_value_into_configuration(TTS_TAG_CONFIG_BACKGROUND_VOLUME_RATIO, temp)) { return -1; @@ -1100,7 +1101,7 @@ int tts_parser_find_config_changed(char** engine, char**setting, bool* auto_voic if (0 != xmlStrcmp(key_old, key_new)) { SLOG(LOG_DEBUG, TAG_TTSCONFIG, "Old bg volume ratio(%s), New bg volume ratio(%s)", (char*)key_old, (char*)key_new); - *bg_volume_ratio = atof((char*)key_new); + *bg_volume_ratio = atoi((char*)key_new) / VOLUME_BASE_VALUE; } xmlFree(key_new); key_new = NULL; diff --git a/tts-config.xml b/tts-config.xml index 9d2696f1..1323564f 100644 --- a/tts-config.xml +++ b/tts-config.xml @@ -7,5 +7,5 @@ female 8 8 - 0.4 + 400