diff --git a/network/netplay/netplay_net.c b/network/netplay/netplay_net.c index 718b62dbbc..55e3932149 100644 --- a/network/netplay/netplay_net.c +++ b/network/netplay/netplay_net.c @@ -239,13 +239,9 @@ static void netplay_net_post_frame(netplay_t *netplay) if (netplay->replay_frame_count >= netplay->read_frame_count) netplay_simulate_input(netplay, netplay->replay_ptr); -#if defined(HAVE_THREADS) autosave_lock(); -#endif core_run(); -#if defined(HAVE_THREADS) autosave_unlock(); -#endif netplay->replay_ptr = NEXT_PTR(netplay->replay_ptr); netplay->replay_frame_count++; } diff --git a/network/netplay/netplay_spectate.c b/network/netplay/netplay_spectate.c index e6dbbd8aac..53ad18b85a 100644 --- a/network/netplay/netplay_spectate.c +++ b/network/netplay/netplay_spectate.c @@ -205,13 +205,9 @@ static void netplay_spectate_post_frame(netplay_t *netplay) while (netplay->replay_frame_count < netplay->self_frame_count) { -#if defined(HAVE_THREADS) autosave_lock(); -#endif core_run(); -#if defined(HAVE_THREADS) autosave_unlock(); -#endif netplay->replay_ptr = NEXT_PTR(netplay->replay_ptr); netplay->replay_frame_count++; } @@ -242,13 +238,9 @@ static void netplay_spectate_post_frame(netplay_t *netplay) while (netplay->replay_frame_count < netplay->read_frame_count - 1) { -#if defined(HAVE_THREADS) autosave_lock(); -#endif core_run(); -#if defined(HAVE_THREADS) autosave_unlock(); -#endif netplay->replay_ptr = NEXT_PTR(netplay->replay_ptr); netplay->replay_frame_count++; @@ -268,10 +260,7 @@ static bool netplay_spectate_info_cb(netplay_t* netplay, unsigned frames) { int i; for (i = 0; i < MAX_SPECTATORS; i++) - { netplay->spectate.fds[i] = -1; - } - } else { diff --git a/runloop.c b/runloop.c index deb029688d..3825901c0f 100644 --- a/runloop.c +++ b/runloop.c @@ -1328,9 +1328,7 @@ int runloop_iterate(unsigned *sleep_ms) return 1; } -#if defined(HAVE_THREADS) autosave_lock(); -#endif #ifdef HAVE_NETWORKING if (!netplay_driver_ctl(RARCH_NETPLAY_CTL_PRE_FRAME, NULL)) @@ -1385,9 +1383,7 @@ int runloop_iterate(unsigned *sleep_ms) netplay_driver_ctl(RARCH_NETPLAY_CTL_POST_FRAME, NULL); #endif -#if defined(HAVE_THREADS) autosave_unlock(); -#endif if (!settings->fastforward_ratio) return 0; diff --git a/tasks/task_save.c b/tasks/task_save.c index 9f3b25158b..24c9f28717 100644 --- a/tasks/task_save.c +++ b/tasks/task_save.c @@ -258,37 +258,6 @@ static void autosave_free(autosave_t *handle) free(handle); } -/** - * autosave_lock: - * - * Lock autosave. - **/ -void autosave_lock(void) -{ - unsigned i; - - for (i = 0; i < autosave_state.num; i++) - { - if (autosave_state.list[i]) - slock_lock(autosave_state.list[i]->lock); - } -} - -/** - * autosave_unlock: - * - * Unlocks autosave. - **/ -void autosave_unlock(void) -{ - unsigned i; - - for (i = 0; i < autosave_state.num; i++) - { - if (autosave_state.list[i]) - slock_unlock(autosave_state.list[i]->lock); - } -} void autosave_init(void) { @@ -345,6 +314,42 @@ void autosave_deinit(void) } #endif +/** + * autosave_lock: + * + * Lock autosave. + **/ +void autosave_lock(void) +{ +#ifdef HAVE_THREADS + unsigned i; + + for (i = 0; i < autosave_state.num; i++) + { + if (autosave_state.list[i]) + slock_lock(autosave_state.list[i]->lock); + } +#endif +} + +/** + * autosave_unlock: + * + * Unlocks autosave. + **/ +void autosave_unlock(void) +{ +#ifdef HAVE_THREADS + unsigned i; + + for (i = 0; i < autosave_state.num; i++) + { + if (autosave_state.list[i]) + slock_unlock(autosave_state.list[i]->lock); + } +#endif +} + /** * undo_load_state: * Revert to the state before a state was loaded.