diff --git a/audio/audio_driver.c b/audio/audio_driver.c index 0aa44c1f90..5f8b0d6e22 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -449,26 +449,6 @@ error: return audio_driver_ctl(RARCH_AUDIO_CTL_DEINIT, NULL); } -bool audio_driver_mute_toggle(void) -{ - driver_t *driver = driver_get_ptr(); - settings_t *settings = config_get_ptr(); - - if (!driver->audio_data || !driver->audio_active) - return false; - - settings->audio.mute_enable = !settings->audio.mute_enable; - - if (settings->audio.mute_enable) - event_command(EVENT_CMD_AUDIO_STOP); - else if (!event_command(EVENT_CMD_AUDIO_START)) - { - driver->audio_active = false; - return false; - } - - return true; -} /* * audio_driver_readjust_input_rate: @@ -841,6 +821,7 @@ bool audio_driver_ctl(enum rarch_audio_ctl_state state, void *data) driver_t *driver = driver_get_ptr(); const audio_driver_t *audio = driver ? (const audio_driver_t*)driver->audio : NULL; + settings_t *settings = config_get_ptr(); switch (state) { @@ -850,6 +831,20 @@ bool audio_driver_ctl(enum rarch_audio_ctl_state state, void *data) return init_audio(); case RARCH_AUDIO_CTL_DEINIT: return uninit_audio(); + case RARCH_AUDIO_CTL_MUTE_TOGGLE: + if (!driver->audio_data || !driver->audio_active) + return false; + + settings->audio.mute_enable = !settings->audio.mute_enable; + + if (settings->audio.mute_enable) + event_command(EVENT_CMD_AUDIO_STOP); + else if (!event_command(EVENT_CMD_AUDIO_START)) + { + driver->audio_active = false; + return false; + } + return true; case RARCH_AUDIO_CTL_ALIVE: return audio->alive(driver->audio_data); case RARCH_AUDIO_CTL_START: diff --git a/audio/audio_driver.h b/audio/audio_driver.h index 3eaf9a5616..aa66f32d84 100644 --- a/audio/audio_driver.h +++ b/audio/audio_driver.h @@ -79,6 +79,7 @@ enum rarch_audio_ctl_state RARCH_AUDIO_CTL_DEINIT, RARCH_AUDIO_CTL_START, RARCH_AUDIO_CTL_STOP, + RARCH_AUDIO_CTL_MUTE_TOGGLE, RARCH_AUDIO_CTL_ALIVE }; @@ -102,8 +103,6 @@ const void *audio_driver_find_handle(int index); **/ const char *audio_driver_find_ident(int index); -bool audio_driver_mute_toggle(void); - /* * audio_driver_readjust_input_rate: * diff --git a/command_event.c b/command_event.c index 82d949c9c9..7784f4c08d 100644 --- a/command_event.c +++ b/command_event.c @@ -1325,7 +1325,7 @@ bool event_command(enum event_command cmd) msg_hash_to_str(MSG_AUDIO_MUTED): msg_hash_to_str(MSG_AUDIO_UNMUTED); - if (!audio_driver_mute_toggle()) + if (!audio_driver_ctl(RARCH_AUDIO_CTL_MUTE_TOGGLE, NULL)) { RARCH_ERR("%s.\n", msg_hash_to_str(MSG_FAILED_TO_UNMUTE_AUDIO));