diff --git a/audio/audio_driver.c b/audio/audio_driver.c index 1ba1daef1b..c444d3858f 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -150,6 +150,7 @@ static void *audio_driver_resampler_data = NULL; static const audio_driver_t *current_audio = NULL; static void *audio_driver_context_audio_data = NULL; +static bool audio_driver_mute_enable = false; static bool audio_driver_use_float = false; static bool audio_driver_active = false; static bool audio_driver_data_own = false; @@ -531,7 +532,7 @@ static bool audio_driver_flush(const int16_t *data, size_t samples) runloop_get_status(&is_paused, &is_idle, &is_slowmotion, &is_perfcnt_enable); - if (is_paused || settings->bools.audio_mute_enable) + if (is_paused || audio_driver_mute_enable) return true; if (!audio_driver_active || !audio_driver_input_data) return false; @@ -947,14 +948,13 @@ bool audio_driver_has_callback(void) bool audio_driver_toggle_mute(void) { settings_t *settings = config_get_ptr(); - bool new_mute_state = !settings->bools.audio_mute_enable; + bool new_mute_state = !audio_driver_mute_enable; if (!audio_driver_context_audio_data) return false; if (!audio_driver_active) return false; - configuration_set_bool(settings, - settings->bools.audio_mute_enable, new_mute_state); + audio_driver_mute_enable = new_mute_state; if (new_mute_state) command_event(CMD_EVENT_AUDIO_STOP, NULL); @@ -1048,3 +1048,16 @@ void audio_driver_destroy(void) audio_driver_data_own = false; current_audio = NULL; } + +bool *audio_get_bool_ptr(enum audio_action action) +{ + switch (action) + { + case AUDIO_ACTION_MUTE_ENABLE: + return &audio_driver_mute_enable; + case AUDIO_ACTION_NONE: + break; + } + + return NULL; +} diff --git a/audio/audio_driver.h b/audio/audio_driver.h index 4e4bc795cd..b83c93c319 100644 --- a/audio/audio_driver.h +++ b/audio/audio_driver.h @@ -33,6 +33,12 @@ RETRO_BEGIN_DECLS #define AUDIO_MAX_RATIO 16 +enum audio_action +{ + AUDIO_ACTION_NONE = 0, + AUDIO_ACTION_MUTE_ENABLE +}; + typedef struct audio_driver { /* Creates and initializes handle to audio driver. @@ -209,6 +215,8 @@ void audio_driver_unset_callback(void); void audio_driver_frame_is_reverse(void); +bool *audio_get_bool_ptr(enum audio_action action); + bool audio_driver_deinit(void); bool audio_driver_init(void); diff --git a/command.c b/command.c index 19647df0d0..f2b426a106 100644 --- a/command.c +++ b/command.c @@ -2060,7 +2060,8 @@ bool command_event(enum event_command cmd, void *data) case CMD_EVENT_AUDIO_MUTE_TOGGLE: { settings_t *settings = config_get_ptr(); - const char *msg = !settings->bools.audio_mute_enable ? + bool audio_mute_enable = *(audio_get_bool_ptr(AUDIO_ACTION_MUTE_ENABLE)); + const char *msg = !audio_mute_enable ? msg_hash_to_str(MSG_AUDIO_MUTED): msg_hash_to_str(MSG_AUDIO_UNMUTED); diff --git a/configuration.c b/configuration.c index 066b3b8c07..6d4f1378a8 100644 --- a/configuration.c +++ b/configuration.c @@ -1152,7 +1152,7 @@ static struct config_bool_setting *populate_settings_bool(settings_t *settings, SETTING_BOOL("keyboard_gamepad_enable", &settings->bools.input_keyboard_gamepad_enable, true, true, false); SETTING_BOOL("core_set_supports_no_game_enable", &settings->bools.set_supports_no_game_enable, true, true, false); SETTING_BOOL("audio_enable", &settings->bools.audio_enable, true, audio_enable, false); - SETTING_BOOL("audio_mute_enable", &settings->bools.audio_mute_enable, true, false, false); + SETTING_BOOL("audio_mute_enable", audio_get_bool_ptr(AUDIO_ACTION_MUTE_ENABLE), true, false, false); SETTING_BOOL("location_allow", &settings->bools.location_allow, true, false, false); SETTING_BOOL("video_font_enable", &settings->bools.video_font_enable, true, font_enable, false); SETTING_BOOL("core_updater_auto_extract_archive", &settings->bools.network_buildbot_auto_extract_archive, true, true, false); diff --git a/configuration.h b/configuration.h index 8d9516709e..bdee6088d3 100644 --- a/configuration.h +++ b/configuration.h @@ -74,7 +74,6 @@ typedef struct settings /* Audio */ bool audio_enable; - bool audio_mute_enable; bool audio_sync; bool audio_rate_control; #ifdef HAVE_WASAPI diff --git a/menu/menu_setting.c b/menu/menu_setting.c index c8f76e1a59..f4b4cacc4a 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -3761,7 +3761,7 @@ static bool setting_append_list( CONFIG_BOOL( list, list_info, - &settings->bools.audio_mute_enable, + audio_get_bool_ptr(AUDIO_ACTION_MUTE_ENABLE), MENU_ENUM_LABEL_AUDIO_MUTE, MENU_ENUM_LABEL_VALUE_AUDIO_MUTE, false,