runloop.c - Rewrite check_pause

This commit is contained in:
twinaphex 2014-10-05 02:36:05 +02:00
parent cfdbb8cf63
commit 2ef17806fd
1 changed files with 11 additions and 28 deletions

View File

@ -144,8 +144,6 @@ static void check_pause(bool pressed, bool frameadvance_pressed)
{ {
static bool old_focus = true; static bool old_focus = true;
bool focus = true; bool focus = true;
bool has_set_audio_stop = false;
bool has_set_audio_start = false;
/* FRAMEADVANCE will set us into pause mode. */ /* FRAMEADVANCE will set us into pause mode. */
pressed |= !g_extern.is_paused && frameadvance_pressed; pressed |= !g_extern.is_paused && frameadvance_pressed;
@ -154,40 +152,25 @@ static void check_pause(bool pressed, bool frameadvance_pressed)
focus = driver.video->focus(driver.video_data); focus = driver.video->focus(driver.video_data);
if (focus && pressed) if (focus && pressed)
{
g_extern.is_paused = !g_extern.is_paused; g_extern.is_paused = !g_extern.is_paused;
else if (focus && !old_focus)
g_extern.is_paused = false;
else if (!focus && old_focus)
g_extern.is_paused = true;
if (g_extern.is_paused) if (g_extern.is_paused)
{ {
RARCH_LOG("Paused.\n"); RARCH_LOG("Paused.\n");
has_set_audio_stop = true; rarch_main_command(RARCH_CMD_AUDIO_STOP);
if (g_settings.video.black_frame_insertion)
rarch_render_cached_frame();
} }
else else
{ {
RARCH_LOG("Unpaused.\n"); RARCH_LOG("Unpaused.\n");
has_set_audio_start = true;
}
}
else if (focus && !old_focus)
{
RARCH_LOG("Unpaused.\n");
g_extern.is_paused = false;
has_set_audio_start = true;
}
else if (!focus && old_focus)
{
RARCH_LOG("Paused.\n");
g_extern.is_paused = true;
has_set_audio_stop = true;
}
if (has_set_audio_stop)
rarch_main_command(RARCH_CMD_AUDIO_STOP);
if (has_set_audio_start)
rarch_main_command(RARCH_CMD_AUDIO_START); rarch_main_command(RARCH_CMD_AUDIO_START);
}
if (g_extern.is_paused && g_settings.video.black_frame_insertion)
rarch_render_cached_frame();
old_focus = focus; old_focus = focus;
} }