mirror of
https://github.com/libretro/RetroArch
synced 2025-04-16 08:43:10 +00:00
Refactor audio stop/start
This commit is contained in:
parent
c3c0341f8c
commit
53ae4cd72c
@ -159,8 +159,7 @@ static int main_entry_iterate_menu_preinit(args_type() args)
|
|||||||
key_event = g_extern.system.key_event;
|
key_event = g_extern.system.key_event;
|
||||||
g_extern.system.key_event = menu_key_event;
|
g_extern.system.key_event = menu_key_event;
|
||||||
|
|
||||||
if (driver.audio_data)
|
rarch_main_command(RARCH_CMD_AUDIO_STOP);
|
||||||
audio_stop_func();
|
|
||||||
|
|
||||||
driver.menu->need_refresh = true;
|
driver.menu->need_refresh = true;
|
||||||
driver.menu->old_input_state |= 1ULL << RARCH_MENU_TOGGLE;
|
driver.menu->old_input_state |= 1ULL << RARCH_MENU_TOGGLE;
|
||||||
@ -183,11 +182,7 @@ static int main_entry_iterate_menu(args_type() args)
|
|||||||
g_extern.lifecycle_state &= ~(1ULL << MODE_MENU);
|
g_extern.lifecycle_state &= ~(1ULL << MODE_MENU);
|
||||||
driver_set_nonblock_state(driver.nonblock_state);
|
driver_set_nonblock_state(driver.nonblock_state);
|
||||||
|
|
||||||
if (driver.audio_data && !g_extern.audio_data.mute && !audio_start_func())
|
rarch_main_command(RARCH_CMD_AUDIO_START);
|
||||||
{
|
|
||||||
RARCH_ERR("Failed to resume audio driver. Will continue without audio.\n");
|
|
||||||
g_extern.audio_active = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_extern.lifecycle_state |= (1ULL << MODE_CLEAR_INPUT);
|
g_extern.lifecycle_state |= (1ULL << MODE_CLEAR_INPUT);
|
||||||
|
|
||||||
|
@ -102,6 +102,8 @@ enum basic_event
|
|||||||
RARCH_CMD_REINIT,
|
RARCH_CMD_REINIT,
|
||||||
RARCH_CMD_REWIND,
|
RARCH_CMD_REWIND,
|
||||||
RARCH_CMD_AUTOSAVE,
|
RARCH_CMD_AUTOSAVE,
|
||||||
|
RARCH_CMD_AUDIO_STOP,
|
||||||
|
RARCH_CMD_AUDIO_START,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum menu_enums
|
enum menu_enums
|
||||||
|
49
retroarch.c
49
retroarch.c
@ -2301,10 +2301,12 @@ static void check_movie(void)
|
|||||||
|
|
||||||
static void check_pause(void)
|
static void check_pause(void)
|
||||||
{
|
{
|
||||||
static bool old_state = false;
|
static bool old_state = false;
|
||||||
static bool old_focus = true;
|
static bool old_focus = true;
|
||||||
bool focus = true;
|
bool focus = true;
|
||||||
bool new_state = input_key_pressed_func(RARCH_PAUSE_TOGGLE);
|
bool has_set_audio_stop = false;
|
||||||
|
bool has_set_audio_start = false;
|
||||||
|
bool new_state = input_key_pressed_func(RARCH_PAUSE_TOGGLE);
|
||||||
|
|
||||||
// FRAMEADVANCE will set us into pause mode.
|
// FRAMEADVANCE will set us into pause mode.
|
||||||
new_state |= !g_extern.is_paused && input_key_pressed_func(RARCH_FRAMEADVANCE);
|
new_state |= !g_extern.is_paused && input_key_pressed_func(RARCH_FRAMEADVANCE);
|
||||||
@ -2319,40 +2321,32 @@ static void check_pause(void)
|
|||||||
if (g_extern.is_paused)
|
if (g_extern.is_paused)
|
||||||
{
|
{
|
||||||
RARCH_LOG("Paused.\n");
|
RARCH_LOG("Paused.\n");
|
||||||
if (driver.audio_data)
|
has_set_audio_stop = true;
|
||||||
audio_stop_func();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
RARCH_LOG("Unpaused.\n");
|
RARCH_LOG("Unpaused.\n");
|
||||||
if (driver.audio_data)
|
has_set_audio_start = true;
|
||||||
{
|
|
||||||
if (!g_extern.audio_data.mute && !audio_start_func())
|
|
||||||
{
|
|
||||||
RARCH_ERR("Failed to resume audio driver. Will continue without audio.\n");
|
|
||||||
g_extern.audio_active = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (focus && !old_focus)
|
else if (focus && !old_focus)
|
||||||
{
|
{
|
||||||
RARCH_LOG("Unpaused.\n");
|
RARCH_LOG("Unpaused.\n");
|
||||||
g_extern.is_paused = false;
|
g_extern.is_paused = false;
|
||||||
if (driver.audio_data && !g_extern.audio_data.mute && !audio_start_func())
|
has_set_audio_start = true;
|
||||||
{
|
|
||||||
RARCH_ERR("Failed to resume audio driver. Will continue without audio.\n");
|
|
||||||
g_extern.audio_active = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (!focus && old_focus)
|
else if (!focus && old_focus)
|
||||||
{
|
{
|
||||||
RARCH_LOG("Paused.\n");
|
RARCH_LOG("Paused.\n");
|
||||||
g_extern.is_paused = true;
|
g_extern.is_paused = true;
|
||||||
if (driver.audio_data)
|
has_set_audio_stop = true;
|
||||||
audio_stop_func();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (has_set_audio_stop)
|
||||||
|
rarch_main_command(RARCH_CMD_AUDIO_STOP);
|
||||||
|
if (has_set_audio_start)
|
||||||
|
rarch_main_command(RARCH_CMD_AUDIO_START);
|
||||||
|
|
||||||
old_focus = focus;
|
old_focus = focus;
|
||||||
old_state = new_state;
|
old_state = new_state;
|
||||||
}
|
}
|
||||||
@ -3206,6 +3200,17 @@ void rarch_main_command(unsigned action)
|
|||||||
init_autosave();
|
init_autosave();
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
case RARCH_CMD_AUDIO_STOP:
|
||||||
|
if (driver.audio_data)
|
||||||
|
audio_stop_func();
|
||||||
|
break;
|
||||||
|
case RARCH_CMD_AUDIO_START:
|
||||||
|
if (driver.audio_data && !g_extern.audio_data.mute && !audio_start_func())
|
||||||
|
{
|
||||||
|
RARCH_ERR("Failed to start audio driver. Will continue without audio.\n");
|
||||||
|
g_extern.audio_active = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user