From 76b5da0f0dc6482e794a1588a22d6fe89b42c277 Mon Sep 17 00:00:00 2001 From: ejurgensen Date: Fri, 3 Jan 2025 10:13:02 +0100 Subject: [PATCH] [settings] Make settings convenience macros more convenient --- src/player.c | 14 ++++++-------- src/settings.c | 1 + src/settings.h | 12 ++++++------ 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/player.c b/src/player.c index 430a164b..bcbbcb7c 100644 --- a/src/player.c +++ b/src/player.c @@ -308,7 +308,6 @@ static int player_flush_pending; // Config values and player settings category static int speaker_autoselect; static int clear_queue_on_stop_disabled; -static struct settings_category *player_settings_category; // Player status static enum play_status player_state; @@ -3161,7 +3160,7 @@ repeat_set(void *arg, int *retval) } // Persist - SETTINGS_SETINT(player_settings_category, PLAYER_SETTINGS_MODE_REPEAT, repeat); + SETTINGS_SETINT("player", PLAYER_SETTINGS_MODE_REPEAT, repeat); if (repeat == REPEAT_ALL || repeat == REPEAT_SONG) { @@ -3203,7 +3202,7 @@ shuffle_set(void *arg, int *retval) shuffle = new_shuffle; // Persist - SETTINGS_SETBOOL(player_settings_category, PLAYER_SETTINGS_MODE_SHUFFLE, shuffle); + SETTINGS_SETBOOL("player", PLAYER_SETTINGS_MODE_SHUFFLE, shuffle); out: *retval = 0; @@ -3219,7 +3218,7 @@ consume_set(void *arg, int *retval) consume = cmdarg->intval; // Persist - SETTINGS_SETBOOL(player_settings_category, PLAYER_SETTINGS_MODE_CONSUME, consume); + SETTINGS_SETBOOL("player", PLAYER_SETTINGS_MODE_CONSUME, consume); if (consume) { @@ -3879,11 +3878,10 @@ player_init(void) clear_queue_on_stop_disabled = cfg_getbool(cfg_getsec(cfg, "mpd"), "clear_queue_on_stop_disable"); } - CHECK_NULL(L_PLAYER, player_settings_category = settings_category_get("player")); - ret = SETTINGS_GETINT(player_settings_category, PLAYER_SETTINGS_MODE_REPEAT); + ret = SETTINGS_GETINT("player", PLAYER_SETTINGS_MODE_REPEAT); repeat = (ret > 0) ? ret : REPEAT_OFF; - shuffle = SETTINGS_GETBOOL(player_settings_category, PLAYER_SETTINGS_MODE_SHUFFLE); - consume = SETTINGS_GETBOOL(player_settings_category, PLAYER_SETTINGS_MODE_CONSUME); + shuffle = SETTINGS_GETBOOL("player", PLAYER_SETTINGS_MODE_SHUFFLE); + consume = SETTINGS_GETBOOL("player", PLAYER_SETTINGS_MODE_CONSUME); player_state = PLAY_STOPPED; diff --git a/src/settings.c b/src/settings.c index 2ad947fa..8bb13fa0 100644 --- a/src/settings.c +++ b/src/settings.c @@ -55,6 +55,7 @@ static struct settings_option misc_options[] = { { "streamurl_keywords_artwork_url", SETTINGS_TYPE_STR }, { "streamurl_keywords_length", SETTINGS_TYPE_STR }, + { "streamurl_ignore", SETTINGS_TYPE_BOOL }, }; static struct settings_option player_options[] = diff --git a/src/settings.h b/src/settings.h index 852fa658..3e3d4693 100644 --- a/src/settings.h +++ b/src/settings.h @@ -59,9 +59,9 @@ settings_option_getbool(struct settings_option *option); char * settings_option_getstr(struct settings_option *option); -#define SETTINGS_GETINT(category, name) settings_option_getint(settings_option_get((category), (name))) -#define SETTINGS_GETBOOL(category, name) settings_option_getbool(settings_option_get((category), (name))) -#define SETTINGS_GETSTR(category, name) settings_option_getstr(settings_option_get((category), (name))) +#define SETTINGS_GETINT(category, name) settings_option_getint(settings_option_get(settings_category_get(category), (name))) +#define SETTINGS_GETBOOL(category, name) settings_option_getbool(settings_option_get(settings_category_get(category), (name))) +#define SETTINGS_GETSTR(category, name) settings_option_getstr(settings_option_get(settings_category_get(category), (name))) int settings_option_setint(struct settings_option *option, int value); @@ -72,9 +72,9 @@ settings_option_setbool(struct settings_option *option, bool value); int settings_option_setstr(struct settings_option *option, const char *value); -#define SETTINGS_SETINT(category, name, value) settings_option_setint(settings_option_get((category), (name)), (value)) -#define SETTINGS_SETBOOL(category, name, value) settings_option_setbool(settings_option_get((category), (name)), (value)) -#define SETTINGS_SETSTR(category, name, value) settings_option_setstr(settings_option_get((category), (name)), (value)) +#define SETTINGS_SETINT(category, name, value) settings_option_setint(settings_option_get(settings_category_get(category), (name)), (value)) +#define SETTINGS_SETBOOL(category, name, value) settings_option_setbool(settings_option_get(settings_category_get(category), (name)), (value)) +#define SETTINGS_SETSTR(category, name, value) settings_option_setstr(settings_option_get(settings_category_get(category), (name)), (value)) int