Create audio_driver_mute_toggle

This commit is contained in:
twinaphex 2015-02-10 21:16:26 +01:00
parent 1805068440
commit 889860f791
3 changed files with 24 additions and 12 deletions

View File

@ -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;
}

View File

@ -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:
*

View File

@ -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;