From 35cda4b78bbe27605f217b92f44a66a10ccee25b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 8 Oct 2014 16:07:19 +0200 Subject: [PATCH] Create RARCH_CMD_AUDIO_MUTE_TOGGLE --- general.h | 1 + retroarch.c | 24 ++++++++++++++++++++++++ runloop.c | 26 +------------------------- 3 files changed, 26 insertions(+), 25 deletions(-) diff --git a/general.h b/general.h index 5b6980ba75..ef471b7e51 100644 --- a/general.h +++ b/general.h @@ -108,6 +108,7 @@ enum basic_event RARCH_CMD_AUTOSAVE_STATE, RARCH_CMD_AUDIO_STOP, RARCH_CMD_AUDIO_START, + RARCH_CMD_AUDIO_MUTE_TOGGLE, RARCH_CMD_OVERLAY_INIT, RARCH_CMD_OVERLAY_DEINIT, RARCH_CMD_OVERLAY_SET_SCALE_FACTOR, diff --git a/retroarch.c b/retroarch.c index 5d2f4883f0..66d336595f 100644 --- a/retroarch.c +++ b/retroarch.c @@ -2307,6 +2307,30 @@ bool rarch_main_command(unsigned cmd) driver.audio_active = false; } break; + case RARCH_CMD_AUDIO_MUTE_TOGGLE: + { + const char *msg = !g_extern.audio_data.mute ? + "Audio muted." : "Audio unmuted."; + + if (!driver.audio_data || !driver.audio_active) + return; + + g_extern.audio_data.mute = !g_extern.audio_data.mute; + + msg_queue_clear(g_extern.msg_queue); + msg_queue_push(g_extern.msg_queue, msg, 1, 180); + + if (g_extern.audio_data.mute) + rarch_main_command(RARCH_CMD_AUDIO_STOP); + else if (!rarch_main_command(RARCH_CMD_AUDIO_START)) + { + RARCH_ERR("Failed to unmute audio.\n"); + driver.audio_active = false; + } + + RARCH_LOG("%s\n", msg); + } + break; case RARCH_CMD_OVERLAY_DEINIT: #ifdef HAVE_OVERLAY if (driver.overlay) diff --git a/runloop.c b/runloop.c index dd5a052883..a52d3c062c 100644 --- a/runloop.c +++ b/runloop.c @@ -24,30 +24,6 @@ #include "frontend/menu/menu_common.h" #endif -static void check_mute(void) -{ - const char *msg = !g_extern.audio_data.mute ? - "Audio muted." : "Audio unmuted."; - - if (!driver.audio_data || !driver.audio_active) - return; - - g_extern.audio_data.mute = !g_extern.audio_data.mute; - - msg_queue_clear(g_extern.msg_queue); - msg_queue_push(g_extern.msg_queue, msg, 1, 180); - - if (g_extern.audio_data.mute) - rarch_main_command(RARCH_CMD_AUDIO_STOP); - else if (!rarch_main_command(RARCH_CMD_AUDIO_START)) - { - RARCH_ERR("Failed to unmute audio.\n"); - driver.audio_active = false; - } - - RARCH_LOG("%s\n", msg); -} - static void set_volume(float gain) { char msg[256]; @@ -425,7 +401,7 @@ static int do_state_checks( rarch_main_command(RARCH_CMD_TAKE_SCREENSHOT); if (BIT64_GET(trigger_input, RARCH_MUTE)) - check_mute(); + rarch_main_command(RARCH_CMD_AUDIO_MUTE_TOGGLE); if (BIT64_GET(input, RARCH_VOLUME_UP)) set_volume(0.5f);