diff --git a/audio/audio_driver.c b/audio/audio_driver.c index df63c57a13..a83f7aea22 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -31,10 +31,6 @@ #include "../verbosity.h" #include "../string_list_special.h" -#ifdef HAVE_NETPLAY -#include "../netplay/netplay.h" -#endif - #ifndef AUDIO_BUFFER_FREE_SAMPLES_COUNT #define AUDIO_BUFFER_FREE_SAMPLES_COUNT (8 * 1024) #endif @@ -854,12 +850,15 @@ bool audio_driver_ctl(enum rarch_audio_ctl_state state, void *data) { const struct retro_audio_callback *cb = (const struct retro_audio_callback*)data; +#ifdef HAVE_NETPLAY + global_t *global = global_get_ptr(); +#endif if (recording_driver_get_data_ptr()) /* A/V sync is a must. */ return false; #ifdef HAVE_NETPLAY - if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL)) + if (global->netplay.enable) return false; #endif if (cb) diff --git a/command_event.c b/command_event.c index 39b6d8b1d9..52d0decd8b 100644 --- a/command_event.c +++ b/command_event.c @@ -461,8 +461,7 @@ static void event_load_auto_state(void) global_t *global = global_get_ptr(); #ifdef HAVE_NETPLAY - if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL) - && !global->netplay.is_spectate) + if (global->netplay.enable && !global->netplay.is_spectate) return; #endif diff --git a/configuration.c b/configuration.c index 6580075763..59960b4ff2 100644 --- a/configuration.c +++ b/configuration.c @@ -36,10 +36,6 @@ #include "system.h" #include "verbosity.h" -#ifdef HAVE_NETPLAY -#include "netplay/netplay.h" -#endif - #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -2042,7 +2038,7 @@ bool config_load_override(void) } #ifdef HAVE_NETPLAY - if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL)) + if (global->netplay.enable) { RARCH_WARN("Overrides: can't use overrides in conjunction with netplay, disabling overrides\n"); return false; diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 6b6161e23f..5156146e02 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -55,9 +55,6 @@ #include "../tasks/tasks_internal.h" -#ifdef HAVE_NETPLAY -#include "../netplay/netplay.h" -#endif struct rarch_setting_info { @@ -157,9 +154,6 @@ struct rarch_setting bool enforce_maxrange; }; -/* static local variables */ -static bool setting_netplay_enable; - /* forward decls */ static void setting_get_string_representation_default(void *data, char *s, size_t len); @@ -2845,14 +2839,6 @@ void general_write_handler(void *data) switch (hash) { - case MENU_LABEL_NETPLAY_ENABLE: -#ifdef HAVE_NETPLAY - if (*setting->value.boolean) - netplay_driver_ctl(RARCH_NETPLAY_CTL_SET_ENABLE, NULL); - else - netplay_driver_ctl(RARCH_NETPLAY_CTL_UNSET_ENABLE, NULL); -#endif - break; case MENU_LABEL_VIDEO_THREADED: { if (*setting->value.boolean) @@ -6367,7 +6353,7 @@ static bool setting_append_list_netplay_options( CONFIG_BOOL( list, list_info, - &setting_netplay_enable, + &global->netplay.enable, menu_hash_to_str(MENU_LABEL_NETPLAY_ENABLE), menu_hash_to_str(MENU_LABEL_VALUE_NETPLAY_ENABLE), false, diff --git a/netplay/netplay.c b/netplay/netplay.c index be0c4aa07d..595b7a9696 100644 --- a/netplay/netplay.c +++ b/netplay/netplay.c @@ -1102,9 +1102,6 @@ void netplay_post_frame(netplay_t *netplay) void deinit_netplay(void) { netplay_t *netplay = (netplay_t*)netplay_data; - - netplay_driver_ctl(RARCH_NETPLAY_CTL_DEINIT, NULL); - if (netplay) netplay_free(netplay); netplay_data = NULL; @@ -1126,7 +1123,7 @@ bool init_netplay(void) settings_t *settings = config_get_ptr(); global_t *global = global_get_ptr(); - if (!netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL)) + if (!global->netplay.enable) return false; if (bsv_movie_ctl(BSV_MOVIE_CTL_START_PLAYBACK, NULL)) @@ -1166,23 +1163,11 @@ bool init_netplay(void) bool netplay_driver_ctl(enum rarch_netplay_ctl_state state, void *data) { - static bool netplay_is_enabled = false; if (!netplay_data) return false; switch (state) { - case RARCH_NETPLAY_CTL_DEINIT: - netplay_is_enabled = false; - break; - case RARCH_NETPLAY_CTL_IS_ENABLED: - return netplay_is_enabled; - case RARCH_NETPLAY_CTL_SET_ENABLE: - netplay_is_enabled = true; - break; - case RARCH_NETPLAY_CTL_UNSET_ENABLE: - netplay_is_enabled = false; - break; case RARCH_NETPLAY_CTL_IS_DATA_INITED: return true; case RARCH_NETPLAY_CTL_POST_FRAME: diff --git a/netplay/netplay.h b/netplay/netplay.h index 05ec44c3a4..8ca7536480 100644 --- a/netplay/netplay.h +++ b/netplay/netplay.h @@ -31,15 +31,11 @@ typedef struct netplay netplay_t; enum rarch_netplay_ctl_state { RARCH_NETPLAY_CTL_NONE = 0, - RARCH_NETPLAY_CTL_DEINIT, RARCH_NETPLAY_CTL_FLIP_PLAYERS, RARCH_NETPLAY_CTL_FULLSCREEN_TOGGLE, RARCH_NETPLAY_CTL_POST_FRAME, RARCH_NETPLAY_CTL_PRE_FRAME, - RARCH_NETPLAY_CTL_IS_DATA_INITED, - RARCH_NETPLAY_CTL_IS_ENABLED, - RARCH_NETPLAY_CTL_SET_ENABLE, - RARCH_NETPLAY_CTL_UNSET_ENABLE + RARCH_NETPLAY_CTL_IS_DATA_INITED }; enum netplay_cmd diff --git a/retroarch.c b/retroarch.c index a89d441279..4dec592c1c 100644 --- a/retroarch.c +++ b/retroarch.c @@ -68,10 +68,6 @@ #include "command.h" #endif -#ifdef HAVE_NETPLAY -#include "netplay/netplay.h" -#endif - #ifdef HAVE_MENU #include "menu/menu_driver.h" #include "menu/menu_content.h" @@ -856,13 +852,13 @@ static void parse_input(int argc, char *argv[]) #ifdef HAVE_NETPLAY case 'H': global->has_set.netplay_ip_address = true; - netplay_driver_ctl(RARCH_NETPLAY_CTL_SET_ENABLE, NULL); + global->netplay.enable = true; *global->netplay.server = '\0'; break; case 'C': global->has_set.netplay_ip_address = true; - netplay_driver_ctl(RARCH_NETPLAY_CTL_SET_ENABLE, NULL); + global->netplay.enable = true; strlcpy(global->netplay.server, optarg, sizeof(global->netplay.server)); break; diff --git a/runloop.c b/runloop.c index b45ffd4226..545c42bac7 100644 --- a/runloop.c +++ b/runloop.c @@ -572,9 +572,11 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) const struct retro_frame_time_callback *info = (const struct retro_frame_time_callback*)data; #ifdef HAVE_NETPLAY + global_t *global = global_get_ptr(); + /* retro_run() will be called in very strange and * mysterious ways, have to disable it. */ - if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL)) + if (global->netplay.enable) return false; #endif runloop_frame_time = *info; diff --git a/runloop.h b/runloop.h index c265289037..90b6afcc86 100644 --- a/runloop.h +++ b/runloop.h @@ -242,6 +242,7 @@ typedef struct global struct { char server[PATH_MAX_LENGTH]; + bool enable; bool is_client; bool is_spectate; unsigned sync_frames;