mirror of
https://github.com/libretro/RetroArch
synced 2025-01-29 18:32:44 +00:00
Create audio_driver_mute_toggle
This commit is contained in:
parent
1805068440
commit
889860f791
@ -391,3 +391,21 @@ void init_audio(void)
|
||||
driver.audio->start(driver.audio_data);
|
||||
}
|
||||
}
|
||||
|
||||
bool audio_driver_mute_toggle(void)
|
||||
{
|
||||
if (!driver.audio_data || !driver.audio_active)
|
||||
return false;
|
||||
|
||||
g_settings.audio.mute_enable = !g_settings.audio.mute_enable;
|
||||
|
||||
if (g_settings.audio.mute_enable)
|
||||
rarch_main_command(RARCH_CMD_AUDIO_STOP);
|
||||
else if (!rarch_main_command(RARCH_CMD_AUDIO_START))
|
||||
{
|
||||
driver.audio_active = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -110,6 +110,8 @@ const void *audio_driver_find_handle(int index);
|
||||
**/
|
||||
const char *audio_driver_find_ident(int index);
|
||||
|
||||
bool audio_driver_mute_toggle(void);
|
||||
|
||||
/**
|
||||
* config_get_audio_driver_options:
|
||||
*
|
||||
|
16
retroarch.c
16
retroarch.c
@ -2320,22 +2320,14 @@ bool rarch_main_command(unsigned cmd)
|
||||
const char *msg = !g_settings.audio.mute_enable ?
|
||||
"Audio muted." : "Audio unmuted.";
|
||||
|
||||
if (!driver.audio_data || !driver.audio_active)
|
||||
if (!audio_driver_mute_toggle())
|
||||
{
|
||||
RARCH_ERR("Failed to unmute audio.\n");
|
||||
return false;
|
||||
|
||||
g_settings.audio.mute_enable = !g_settings.audio.mute_enable;
|
||||
}
|
||||
|
||||
msg_queue_clear(g_extern.msg_queue);
|
||||
msg_queue_push(g_extern.msg_queue, msg, 1, 180);
|
||||
|
||||
if (g_settings.audio.mute_enable)
|
||||
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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user