Get rid of RUNLOOP_STATE_SLEEP and reuse existing state

This commit is contained in:
twinaphex 2019-05-31 16:38:17 +02:00
parent 143c333343
commit 90fab37a86

View File

@ -198,7 +198,6 @@ enum runloop_state
{ {
RUNLOOP_STATE_ITERATE = 0, RUNLOOP_STATE_ITERATE = 0,
RUNLOOP_STATE_POLLED_AND_SLEEP, RUNLOOP_STATE_POLLED_AND_SLEEP,
RUNLOOP_STATE_SLEEP,
RUNLOOP_STATE_MENU_ITERATE, RUNLOOP_STATE_MENU_ITERATE,
RUNLOOP_STATE_END, RUNLOOP_STATE_END,
RUNLOOP_STATE_QUIT RUNLOOP_STATE_QUIT
@ -837,12 +836,11 @@ bool driver_ctl(enum driver_ctl_state state, void *data)
void rarch_core_runtime_tick(void) void rarch_core_runtime_tick(void)
{ {
retro_time_t frame_time;
struct retro_system_av_info *av_info = video_viewport_get_system_av_info(); struct retro_system_av_info *av_info = video_viewport_get_system_av_info();
if (av_info && av_info->timing.fps) if (av_info && av_info->timing.fps)
{ {
frame_time = (1.0 / av_info->timing.fps) * 1000000; retro_time_t frame_time = (1.0 / av_info->timing.fps) * 1000000;
/* Account for slow motion */ /* Account for slow motion */
if (runloop_slowmotion) if (runloop_slowmotion)
@ -3356,11 +3354,9 @@ static bool input_driver_toggle_button_combo(
return false; return false;
} }
/* user started holding down the start button, start the timer */
if (!rarch_timer_is_running(&timer)) if (!rarch_timer_is_running(&timer))
{
/* user started holding down the start button, start the timer */
rarch_timer_begin(&timer, HOLD_START_DELAY_SEC); rarch_timer_begin(&timer, HOLD_START_DELAY_SEC);
}
rarch_timer_tick(&timer); rarch_timer_tick(&timer);
@ -3743,7 +3739,10 @@ static enum runloop_state runloop_check_state(
seq = 0; seq = 0;
#endif #endif
if (runloop_idle) if (runloop_idle)
return RUNLOOP_STATE_SLEEP; {
retro_ctx.poll_cb();
return RUNLOOP_STATE_POLLED_AND_SLEEP;
}
} }
/* Check game focus toggle */ /* Check game focus toggle */
@ -4045,11 +4044,17 @@ static enum runloop_state runloop_check_state(
} }
if (!check_is_oneshot) if (!check_is_oneshot)
return RUNLOOP_STATE_SLEEP; {
retro_ctx.poll_cb();
return RUNLOOP_STATE_POLLED_AND_SLEEP;
}
} }
if (!focused) if (!focused)
return RUNLOOP_STATE_SLEEP; {
retro_ctx.poll_cb();
return RUNLOOP_STATE_POLLED_AND_SLEEP;
}
/* Check if we have pressed the fast forward button */ /* Check if we have pressed the fast forward button */
/* To avoid continous switching if we hold the button down, we require /* To avoid continous switching if we hold the button down, we require
@ -4491,18 +4496,11 @@ int runloop_iterate(unsigned *sleep_ms)
runloop_netplay_pause(); runloop_netplay_pause();
*sleep_ms = 10; *sleep_ms = 10;
return 1; return 1;
case RUNLOOP_STATE_SLEEP:
retro_ctx.poll_cb();
runloop_netplay_pause();
*sleep_ms = 10;
return 1;
case RUNLOOP_STATE_END: case RUNLOOP_STATE_END:
#ifdef HAVE_NETWORKING #ifdef HAVE_NETWORKING
if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL) if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL)
&& settings->bools.menu_pause_libretro) && settings->bools.menu_pause_libretro)
{
runloop_netplay_pause(); runloop_netplay_pause();
}
#endif #endif
goto end; goto end;
case RUNLOOP_STATE_MENU_ITERATE: case RUNLOOP_STATE_MENU_ITERATE: