Refactor rarch_init_autosave/rarch_deinit_autosave

This commit is contained in:
twinaphex 2014-08-02 04:11:06 +02:00
parent 33d18b3722
commit 15f3f79732
3 changed files with 20 additions and 18 deletions

View File

@ -101,6 +101,7 @@ enum basic_event
RARCH_CMD_QUIT,
RARCH_CMD_REINIT,
RARCH_CMD_REWIND,
RARCH_CMD_AUTOSAVE,
};
enum menu_enums
@ -786,8 +787,6 @@ void rarch_disk_control_set_eject(bool state, bool log);
void rarch_disk_control_set_index(unsigned index);
void rarch_disk_control_append_image(const char *path);
bool rarch_set_rumble_state(unsigned port, enum retro_rumble_effect effect, bool enable);
void rarch_init_autosave(void);
void rarch_deinit_autosave(void);
#ifdef HAVE_RECORD
void rarch_init_recording(void);

View File

@ -1699,7 +1699,7 @@ static void init_libretro_cbs(void)
}
#if defined(HAVE_THREADS)
void rarch_init_autosave(void)
static void init_autosave(void)
{
unsigned i;
@ -1729,7 +1729,7 @@ void rarch_init_autosave(void)
}
}
void rarch_deinit_autosave(void)
static void deinit_autosave(void)
{
unsigned i;
for (i = 0; i < g_extern.num_autosave; i++)
@ -2483,7 +2483,7 @@ void rarch_disk_control_append_image(const char *path)
msg_queue_push(g_extern.msg_queue, msg, 0, 180);
#if defined(HAVE_THREADS)
rarch_deinit_autosave();
deinit_autosave();
#endif
// TODO: Need to figure out what to do with subsystems case.
@ -2498,7 +2498,7 @@ void rarch_disk_control_append_image(const char *path)
}
#if defined(HAVE_THREADS)
rarch_init_autosave();
init_autosave();
#endif
rarch_disk_control_set_eject(false, false);
@ -2922,7 +2922,7 @@ static void init_sram(void)
#if defined(HAVE_THREADS)
if (g_extern.use_sram)
rarch_init_autosave();
init_autosave();
#endif
}
@ -3151,6 +3151,13 @@ void rarch_main_command(unsigned action)
else
deinit_rewind();
break;
case RARCH_CMD_AUTOSAVE:
#ifdef HAVE_THREADS
deinit_autosave();
if (g_settings.autosave_interval)
init_autosave();
#endif
break;
}
}
@ -3284,7 +3291,7 @@ void rarch_main_deinit(void)
#if defined(HAVE_THREADS)
if (g_extern.use_sram)
rarch_deinit_autosave();
deinit_autosave();
#endif
#ifdef HAVE_RECORD

View File

@ -977,8 +977,9 @@ static void general_read_handler(const void *data)
static void general_write_handler(const void *data)
{
bool has_set_reinit = false;
bool has_set_rewind = false;
bool has_set_reinit = false;
bool has_set_rewind = false;
bool has_set_autosave = false;
const rarch_setting_t *setting = (const rarch_setting_t*)data;
if (!setting)
@ -1127,14 +1128,8 @@ static void general_write_handler(const void *data)
g_settings.fastforward_ratio = *setting->value.fraction;
else if (!strcmp(setting->name, "autosave_interval"))
{
#ifdef HAVE_THREADS
rarch_deinit_autosave();
#endif
g_settings.autosave_interval = *setting->value.unsigned_integer;
#ifdef HAVE_THREADS
if (g_settings.autosave_interval)
rarch_init_autosave();
#endif
has_set_autosave = true;
}
else if (!strcmp(setting->name, "video_font_enable"))
g_settings.video.font_enable = *setting->value.boolean;
@ -1339,9 +1334,10 @@ static void general_write_handler(const void *data)
if (has_set_reinit)
rarch_main_command(RARCH_CMD_REINIT);
if (has_set_rewind)
rarch_main_command(RARCH_CMD_REWIND);
if (has_set_autosave)
rarch_main_command(RARCH_CMD_AUTOSAVE);
}
#define NEXT (list[index++])