mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-16 15:27:41 +00:00
Create RARCH_CMD_AUDIO_MUTE_TOGGLE
This commit is contained in:
parent
57cc2ea18d
commit
35cda4b78b
@ -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,
|
||||
|
24
retroarch.c
24
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)
|
||||
|
26
runloop.c
26
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);
|
||||
|
Loading…
Reference in New Issue
Block a user