From: Yunhee Seo Date: Fri, 24 Nov 2023 08:23:08 +0000 (+0900) Subject: sound: Fix checking default theme duplication X-Git-Tag: accepted/tizen/unified/20231211.171503~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7e99ab418cbb6ab91e75b1ee0a64ec5d2fba432f;p=platform%2Fcore%2Fsystem%2Flibsvi.git sound: Fix checking default theme duplication Previously, the default theme was not checked properly as intended. It is necessary to check default sound theme duplication. Change-Id: I72db18631047e32c564615e6fcca7867adf0bc88 Signed-off-by: Yunhee Seo --- diff --git a/src/sound-parser.c b/src/sound-parser.c index b2ee00c..7a367e3 100644 --- a/src/sound-parser.c +++ b/src/sound-parser.c @@ -51,6 +51,13 @@ static bool is_sound_theme_id_duplicated(int sound_theme_id) return false; } +static bool is_default_theme_id_set(void) +{ + if (default_sound_theme_id == INITIAL_DEFAULT_SOUND_THEME_ID) + return false; + return true; +} + static int parse_sound_theme_property(gpointer data, gpointer user_data) { struct section_property *prop = (struct section_property *) data; @@ -100,17 +107,16 @@ static int parse_sound_theme_section(const struct parse_result *result, void *da goto out_parsing_fail; } - if (sound_theme_elem.is_default && (sound_theme_elem.id == default_sound_theme_id)) { - _E("Failed to parse sound conf file, default sound theme is duplicated."); - goto out_parsing_fail; - } - if (is_sound_theme_id_duplicated(sound_theme_elem.id)) { _E("Failed to parse sound conf file, sound theme id is duplicated."); goto out_parsing_fail; } if (sound_theme_elem.is_default) { + if (is_default_theme_id_set()) { + _E("Failed to parse sound conf file, default sound theme is duplicated."); + goto out_parsing_fail; + } default_sound_theme_id = sound_theme_elem.id; sound_thememan_set_default_sound_theme_id(default_sound_theme_id); } @@ -133,14 +139,13 @@ out_parsing_fail: int sound_parser_init(const char* sound_file_path) { int ret = 0; - default_sound_theme_id = INITIAL_DEFAULT_SOUND_THEME_ID; g_hash_table_to_check_id_duplicated = g_hash_table_new_full(g_int_hash, g_int_equal, g_free, g_free); ret = syscommon_config_parse_by_section(sound_file_path, parse_sound_theme_section, NULL); - if (default_sound_theme_id == INITIAL_DEFAULT_SOUND_THEME_ID) { + if (!is_default_theme_id_set()) { _E("Failed to parse sound conf file. There is no default sound theme id"); ret = -EPERM; } @@ -152,4 +157,9 @@ int sound_parser_init(const char* sound_file_path) return ret; return 0; +} + +void sound_parser_exit(void) +{ + default_sound_theme_id = INITIAL_DEFAULT_SOUND_THEME_ID; } \ No newline at end of file diff --git a/src/sound-parser.h b/src/sound-parser.h index b25bc81..f72791d 100644 --- a/src/sound-parser.h +++ b/src/sound-parser.h @@ -19,5 +19,6 @@ #define __SOUND_PARSER_H__ int sound_parser_init(const char* sound_file_path); +void sound_parser_exit(void); #endif \ No newline at end of file diff --git a/src/sound.c b/src/sound.c index 69dc83d..d73f423 100644 --- a/src/sound.c +++ b/src/sound.c @@ -153,6 +153,7 @@ static void sound_init(void) if (ret < 0) { _E("Failed to parsing sound config file(%d)", ret); sound_thememan_exit(); + sound_parser_exit(); } sound_thememan_get_default_sound_theme_id(¤t_theme_id); @@ -189,6 +190,7 @@ static void sound_exit(void) { int ret; + sound_parser_exit(); sound_thememan_exit(); /* remove watch */