mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 21:32:45 +00:00
Create runloop_{set|unset} - only do autosave lock/unlock if
autosaves are actually active
This commit is contained in:
parent
924296c680
commit
ce8083fd2e
@ -2063,7 +2063,10 @@ bool command_event(enum event_command cmd, void *data)
|
||||
case CMD_EVENT_AUTOSAVE_INIT:
|
||||
command_event(CMD_EVENT_AUTOSAVE_DEINIT, NULL);
|
||||
#ifdef HAVE_THREADS
|
||||
return autosave_init();
|
||||
if (autosave_init())
|
||||
runloop_set(RUNLOOP_ACTION_AUTOSAVE);
|
||||
else
|
||||
runloop_unset(RUNLOOP_ACTION_AUTOSAVE);
|
||||
#else
|
||||
break;
|
||||
#endif
|
||||
|
32
runloop.c
32
runloop.c
@ -132,6 +132,7 @@ static bool runloop_perfcnt_enable = false;
|
||||
static bool runloop_overrides_active = false;
|
||||
static bool runloop_game_options_active = false;
|
||||
static bool runloop_missing_bios = false;
|
||||
static bool runloop_autosave = false;
|
||||
static retro_time_t frame_limit_minimum_time = 0.0;
|
||||
static retro_time_t frame_limit_last_time = 0.0;
|
||||
|
||||
@ -392,6 +393,7 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data)
|
||||
runloop_paused = false;
|
||||
runloop_slowmotion = false;
|
||||
runloop_overrides_active = false;
|
||||
runloop_autosave = false;
|
||||
runloop_ctl(RUNLOOP_CTL_FRAME_TIME_FREE, NULL);
|
||||
break;
|
||||
case RUNLOOP_CTL_GLOBAL_FREE:
|
||||
@ -1040,6 +1042,30 @@ static enum runloop_state runloop_check_state(
|
||||
#define runloop_netplay_pause() ((void)0)
|
||||
#endif
|
||||
|
||||
void runloop_set(enum runloop_action action)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
case RUNLOOP_ACTION_AUTOSAVE:
|
||||
runloop_autosave = true;
|
||||
break;
|
||||
case RUNLOOP_ACTION_NONE:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void runloop_unset(enum runloop_action action)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
case RUNLOOP_ACTION_AUTOSAVE:
|
||||
runloop_autosave = false;
|
||||
break;
|
||||
case RUNLOOP_ACTION_NONE:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* runloop_iterate:
|
||||
*
|
||||
@ -1133,7 +1159,8 @@ int runloop_iterate(unsigned *sleep_ms)
|
||||
break;
|
||||
}
|
||||
|
||||
autosave_lock();
|
||||
if (runloop_autosave)
|
||||
autosave_lock();
|
||||
|
||||
bsv_movie_set_frame_start();
|
||||
|
||||
@ -1178,7 +1205,8 @@ int runloop_iterate(unsigned *sleep_ms)
|
||||
|
||||
bsv_movie_set_frame_end();
|
||||
|
||||
autosave_unlock();
|
||||
if (runloop_autosave)
|
||||
autosave_unlock();
|
||||
|
||||
if (!settings->floats.fastforward_ratio)
|
||||
return 0;
|
||||
|
10
runloop.h
10
runloop.h
@ -28,6 +28,12 @@
|
||||
|
||||
RETRO_BEGIN_DECLS
|
||||
|
||||
enum runloop_action
|
||||
{
|
||||
RUNLOOP_ACTION_NONE = 0,
|
||||
RUNLOOP_ACTION_AUTOSAVE
|
||||
};
|
||||
|
||||
enum runloop_ctl_state
|
||||
{
|
||||
RUNLOOP_CTL_NONE = 0,
|
||||
@ -209,6 +215,10 @@ void runloop_get_status(bool *is_paused, bool *is_idle, bool *is_slowmotion,
|
||||
|
||||
bool runloop_ctl(enum runloop_ctl_state state, void *data);
|
||||
|
||||
void runloop_set(enum runloop_action action);
|
||||
|
||||
void runloop_unset(enum runloop_action action);
|
||||
|
||||
rarch_system_info_t *runloop_get_system_info(void);
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
Loading…
x
Reference in New Issue
Block a user