Remove p_rarch passing around where it's no longer needed

This commit is contained in:
twinaphex 2021-05-22 02:14:32 +02:00
parent fede9eee4b
commit 706ab17b2c

View File

@ -9650,7 +9650,6 @@ static void dir_free_shader(struct rarch_state *p_rarch,
#if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL) #if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL)
static bool dir_init_shader_internal( static bool dir_init_shader_internal(
struct rarch_state *p_rarch,
bool shader_remember_last_dir, bool shader_remember_last_dir,
struct rarch_dir_shader_list *dir_list, struct rarch_dir_shader_list *dir_list,
const char *shader_dir, const char *shader_dir,
@ -9741,7 +9740,6 @@ static void dir_init_shader(
(last_shader_preset_type != RARCH_SHADER_NONE) && (last_shader_preset_type != RARCH_SHADER_NONE) &&
!string_is_empty(last_shader_preset_dir) && !string_is_empty(last_shader_preset_dir) &&
dir_init_shader_internal( dir_init_shader_internal(
p_rarch,
video_shader_remember_last_dir, video_shader_remember_last_dir,
dir_list, dir_list,
last_shader_preset_dir, last_shader_preset_dir,
@ -9752,7 +9750,6 @@ static void dir_init_shader(
/* Try video shaders directory */ /* Try video shaders directory */
if (!string_is_empty(directory_video_shader) && if (!string_is_empty(directory_video_shader) &&
dir_init_shader_internal( dir_init_shader_internal(
p_rarch,
video_shader_remember_last_dir, video_shader_remember_last_dir,
dir_list, dir_list,
directory_video_shader, NULL, show_hidden_files)) directory_video_shader, NULL, show_hidden_files))
@ -9761,7 +9758,6 @@ static void dir_init_shader(
/* Try config directory */ /* Try config directory */
if (!string_is_empty(directory_menu_config) && if (!string_is_empty(directory_menu_config) &&
dir_init_shader_internal( dir_init_shader_internal(
p_rarch,
video_shader_remember_last_dir, video_shader_remember_last_dir,
dir_list, dir_list,
directory_menu_config, NULL, show_hidden_files)) directory_menu_config, NULL, show_hidden_files))
@ -9776,7 +9772,6 @@ static void dir_init_shader(
if (!string_is_empty(rarch_config_directory)) if (!string_is_empty(rarch_config_directory))
dir_init_shader_internal( dir_init_shader_internal(
p_rarch,
video_shader_remember_last_dir, video_shader_remember_last_dir,
dir_list, dir_list,
rarch_config_directory, NULL, show_hidden_files); rarch_config_directory, NULL, show_hidden_files);
@ -10443,7 +10438,7 @@ static void retroarch_msg_queue_init(void)
} }
#ifdef HAVE_THREADS #ifdef HAVE_THREADS
static void retroarch_autosave_deinit(struct rarch_state *p_rarch) static void retroarch_autosave_deinit(void)
{ {
const bool rarch_use_sram = runloop_state.rarch_use_sram; const bool rarch_use_sram = runloop_state.rarch_use_sram;
if (rarch_use_sram) if (rarch_use_sram)
@ -10868,7 +10863,7 @@ bool command_set_shader(command_t *cmd, const char *arg)
/* TRANSLATION */ /* TRANSLATION */
#ifdef HAVE_TRANSLATE #ifdef HAVE_TRANSLATE
static bool task_auto_translate_callback(struct rarch_state *p_rarch) static bool task_auto_translate_callback(void)
{ {
bool was_paused = runloop_state.paused; bool was_paused = runloop_state.paused;
command_event(CMD_EVENT_AI_SERVICE_CALL, &was_paused); command_event(CMD_EVENT_AI_SERVICE_CALL, &was_paused);
@ -10925,7 +10920,7 @@ task_finished:
task_set_finished(task, true); task_set_finished(task, true);
if (*mode_ptr == 1 || *mode_ptr == 2) if (*mode_ptr == 1 || *mode_ptr == 2)
task_auto_translate_callback(p_rarch); task_auto_translate_callback();
if (task->user_data) if (task->user_data)
free(task->user_data); free(task->user_data);
} }
@ -12035,7 +12030,7 @@ static bool command_event_disk_control_append_image(
return false; return false;
#ifdef HAVE_THREADS #ifdef HAVE_THREADS
retroarch_autosave_deinit(p_rarch); retroarch_autosave_deinit();
#endif #endif
/* TODO/FIXME: Need to figure out what to do with subsystems case. */ /* TODO/FIXME: Need to figure out what to do with subsystems case. */
@ -12282,9 +12277,7 @@ static void command_event_init_cheats(
} }
#endif #endif
static void command_event_load_auto_state( static void command_event_load_auto_state(global_t *global)
global_t *global,
struct rarch_state *p_rarch)
{ {
char savestate_name_auto[PATH_MAX_LENGTH]; char savestate_name_auto[PATH_MAX_LENGTH];
bool ret = false; bool ret = false;
@ -12316,9 +12309,7 @@ static void command_event_load_auto_state(
} }
static void command_event_set_savestate_auto_index( static void command_event_set_savestate_auto_index(
settings_t *settings, settings_t *settings, const global_t *global)
const global_t *global,
struct rarch_state *p_rarch)
{ {
size_t i; size_t i;
char state_dir[PATH_MAX_LENGTH]; char state_dir[PATH_MAX_LENGTH];
@ -12384,7 +12375,6 @@ static void command_event_set_savestate_auto_index(
static void command_event_set_savestate_garbage_collect( static void command_event_set_savestate_garbage_collect(
const global_t *global, const global_t *global,
struct rarch_state *p_rarch,
unsigned max_to_keep, unsigned max_to_keep,
bool show_hidden_files bool show_hidden_files
) )
@ -12509,7 +12499,7 @@ static bool event_init_content(
return false; return false;
} }
command_event_set_savestate_auto_index(settings, global, p_rarch); command_event_set_savestate_auto_index(settings, global);
if (event_load_save_files(runloop_state.rarch_is_sram_load_disabled)) if (event_load_save_files(runloop_state.rarch_is_sram_load_disabled))
RARCH_LOG("[SRAM]: %s.\n", RARCH_LOG("[SRAM]: %s.\n",
@ -12526,7 +12516,7 @@ static bool event_init_content(
if (!cheevos_enable || !cheevos_hardcore_mode_enable) if (!cheevos_enable || !cheevos_hardcore_mode_enable)
#endif #endif
if (global && settings->bools.savestate_auto_load) if (global && settings->bools.savestate_auto_load)
command_event_load_auto_state(global, p_rarch); command_event_load_auto_state(global);
#ifdef HAVE_BSV_MOVIE #ifdef HAVE_BSV_MOVIE
bsv_movie_deinit(p_rarch); bsv_movie_deinit(p_rarch);
@ -12865,7 +12855,6 @@ static bool command_event_save_config(
* Returns: true (1) on success, otherwise false (0). * Returns: true (1) on success, otherwise false (0).
**/ **/
static bool command_event_save_core_config( static bool command_event_save_core_config(
struct rarch_state *p_rarch,
const char *dir_menu_config, const char *dir_menu_config,
const char *rarch_path_config) const char *rarch_path_config)
{ {
@ -12968,9 +12957,7 @@ static bool command_event_save_core_config(
* Saves current configuration file to disk, and (optionally) * Saves current configuration file to disk, and (optionally)
* autosave state. * autosave state.
**/ **/
static void command_event_save_current_config( static void command_event_save_current_config(enum override_type type)
struct rarch_state *p_rarch,
enum override_type type)
{ {
char msg[128]; char msg[128];
@ -13105,7 +13092,6 @@ static bool command_event_main_state(
/* Clean up excess savestates if necessary */ /* Clean up excess savestates if necessary */
if (savestate_auto_index && (savestate_max_keep > 0)) if (savestate_auto_index && (savestate_max_keep > 0))
command_event_set_savestate_garbage_collect(global, command_event_set_savestate_garbage_collect(global,
p_rarch,
settings->uints.savestate_max_keep, settings->uints.savestate_max_keep,
settings->bools.show_hidden_files settings->bools.show_hidden_files
); );
@ -13164,10 +13150,9 @@ static bool command_event_main_state(
return ret; return ret;
} }
static bool command_event_resize_windowed_scale(struct rarch_state *p_rarch) static bool command_event_resize_windowed_scale(settings_t *settings)
{ {
unsigned idx = 0; unsigned idx = 0;
settings_t *settings = p_rarch->configuration_settings;
unsigned window_scale = runloop_state.pending_windowed_scale; unsigned window_scale = runloop_state.pending_windowed_scale;
bool video_fullscreen = settings->bools.video_fullscreen; bool video_fullscreen = settings->bools.video_fullscreen;
@ -13679,7 +13664,7 @@ bool command_event(enum event_command cmd, void *data)
return false; return false;
break; break;
case CMD_EVENT_RESIZE_WINDOWED_SCALE: case CMD_EVENT_RESIZE_WINDOWED_SCALE:
if (!command_event_resize_windowed_scale(p_rarch)) if (!command_event_resize_windowed_scale(settings))
return false; return false;
break; break;
case CMD_EVENT_MENU_TOGGLE: case CMD_EVENT_MENU_TOGGLE:
@ -13913,7 +13898,7 @@ bool command_event(enum event_command cmd, void *data)
break; break;
case CMD_EVENT_AUTOSAVE_INIT: case CMD_EVENT_AUTOSAVE_INIT:
#ifdef HAVE_THREADS #ifdef HAVE_THREADS
retroarch_autosave_deinit(p_rarch); retroarch_autosave_deinit();
{ {
#ifdef HAVE_NETWORKING #ifdef HAVE_NETWORKING
unsigned autosave_interval = unsigned autosave_interval =
@ -14371,27 +14356,27 @@ bool command_event(enum event_command cmd, void *data)
config_save_file_salamander(); config_save_file_salamander();
#endif #endif
#ifdef HAVE_CONFIGFILE #ifdef HAVE_CONFIGFILE
command_event_save_current_config(p_rarch, OVERRIDE_NONE); command_event_save_current_config(OVERRIDE_NONE);
#endif #endif
break; break;
case CMD_EVENT_MENU_SAVE_CURRENT_CONFIG_OVERRIDE_CORE: case CMD_EVENT_MENU_SAVE_CURRENT_CONFIG_OVERRIDE_CORE:
#ifdef HAVE_CONFIGFILE #ifdef HAVE_CONFIGFILE
command_event_save_current_config(p_rarch, OVERRIDE_CORE); command_event_save_current_config(OVERRIDE_CORE);
#endif #endif
break; break;
case CMD_EVENT_MENU_SAVE_CURRENT_CONFIG_OVERRIDE_CONTENT_DIR: case CMD_EVENT_MENU_SAVE_CURRENT_CONFIG_OVERRIDE_CONTENT_DIR:
#ifdef HAVE_CONFIGFILE #ifdef HAVE_CONFIGFILE
command_event_save_current_config(p_rarch, OVERRIDE_CONTENT_DIR); command_event_save_current_config(OVERRIDE_CONTENT_DIR);
#endif #endif
break; break;
case CMD_EVENT_MENU_SAVE_CURRENT_CONFIG_OVERRIDE_GAME: case CMD_EVENT_MENU_SAVE_CURRENT_CONFIG_OVERRIDE_GAME:
#ifdef HAVE_CONFIGFILE #ifdef HAVE_CONFIGFILE
command_event_save_current_config(p_rarch, OVERRIDE_GAME); command_event_save_current_config(OVERRIDE_GAME);
#endif #endif
break; break;
case CMD_EVENT_MENU_SAVE_CONFIG: case CMD_EVENT_MENU_SAVE_CONFIG:
#ifdef HAVE_CONFIGFILE #ifdef HAVE_CONFIGFILE
if (!command_event_save_core_config(p_rarch, if (!command_event_save_core_config(
settings->paths.directory_menu_config, settings->paths.directory_menu_config,
path_get(RARCH_PATH_CONFIG))) path_get(RARCH_PATH_CONFIG)))
return false; return false;
@ -15117,7 +15102,6 @@ bool command_event(enum event_command cmd, void *data)
void retroarch_override_setting_set( void retroarch_override_setting_set(
enum rarch_override_setting enum_idx, void *data) enum rarch_override_setting enum_idx, void *data)
{ {
struct rarch_state *p_rarch = &rarch_st;
switch (enum_idx) switch (enum_idx)
{ {
@ -15126,7 +15110,8 @@ void retroarch_override_setting_set(
unsigned *val = (unsigned*)data; unsigned *val = (unsigned*)data;
if (val) if (val)
{ {
unsigned bit = *val; unsigned bit = *val;
struct rarch_state *p_rarch = &rarch_st;
BIT256_SET(p_rarch->has_set_libretro_device, bit); BIT256_SET(p_rarch->has_set_libretro_device, bit);
} }
} }
@ -15190,8 +15175,6 @@ void retroarch_override_setting_set(
void retroarch_override_setting_unset( void retroarch_override_setting_unset(
enum rarch_override_setting enum_idx, void *data) enum rarch_override_setting enum_idx, void *data)
{ {
struct rarch_state *p_rarch = &rarch_st;
switch (enum_idx) switch (enum_idx)
{ {
case RARCH_OVERRIDE_SETTING_LIBRETRO_DEVICE: case RARCH_OVERRIDE_SETTING_LIBRETRO_DEVICE:
@ -15199,7 +15182,8 @@ void retroarch_override_setting_unset(
unsigned *val = (unsigned*)data; unsigned *val = (unsigned*)data;
if (val) if (val)
{ {
unsigned bit = *val; struct rarch_state *p_rarch = &rarch_st;
unsigned bit = *val;
BIT256_CLEAR(p_rarch->has_set_libretro_device, bit); BIT256_CLEAR(p_rarch->has_set_libretro_device, bit);
} }
} }
@ -19220,8 +19204,7 @@ static bool write_file_with_random_name(char **temp_dll_path,
return okay; return okay;
} }
static char *copy_core_to_temp_file(struct rarch_state *p_rarch, static char *copy_core_to_temp_file(const char *dir_libretro)
const char *dir_libretro)
{ {
char retroarch_tmp_path[PATH_MAX_LENGTH]; char retroarch_tmp_path[PATH_MAX_LENGTH];
bool failed = false; bool failed = false;
@ -19327,7 +19310,7 @@ static bool secondary_core_create(struct rarch_state *p_rarch,
if (p_rarch->secondary_library_path) if (p_rarch->secondary_library_path)
free(p_rarch->secondary_library_path); free(p_rarch->secondary_library_path);
p_rarch->secondary_library_path = NULL; p_rarch->secondary_library_path = NULL;
p_rarch->secondary_library_path = copy_core_to_temp_file(p_rarch, p_rarch->secondary_library_path = copy_core_to_temp_file(
settings->paths.directory_libretro); settings->paths.directory_libretro);
if (!p_rarch->secondary_library_path) if (!p_rarch->secondary_library_path)
@ -20462,7 +20445,7 @@ void recording_driver_update_streaming_url(void)
settings_t *settings = p_rarch->configuration_settings; settings_t *settings = p_rarch->configuration_settings;
const char *youtube_url = "rtmp://a.rtmp.youtube.com/live2/"; const char *youtube_url = "rtmp://a.rtmp.youtube.com/live2/";
const char *twitch_url = "rtmp://live.twitch.tv/app/"; const char *twitch_url = "rtmp://live.twitch.tv/app/";
const char *facebook_url = "rtmps://live-api-s.facebook.com:443/rtmp/"; const char *facebook_url= "rtmps://live-api-s.facebook.com:443/rtmp/";
if (!settings) if (!settings)
return; return;
@ -32199,7 +32182,6 @@ void video_driver_get_window_title(char *buf, unsigned len)
* otherwise NULL. * otherwise NULL.
**/ **/
static const gfx_ctx_driver_t *video_context_driver_init( static const gfx_ctx_driver_t *video_context_driver_init(
struct rarch_state *p_rarch,
settings_t *settings, settings_t *settings,
void *data, void *data,
const gfx_ctx_driver_t *ctx, const gfx_ctx_driver_t *ctx,
@ -32254,7 +32236,7 @@ static const gfx_ctx_driver_t *vk_context_driver_init_first(
if (i >= 0) if (i >= 0)
{ {
const gfx_ctx_driver_t *ctx = video_context_driver_init(p_rarch, const gfx_ctx_driver_t *ctx = video_context_driver_init(
settings, settings,
data, data,
gfx_ctx_vk_drivers[i], ident, gfx_ctx_vk_drivers[i], ident,
@ -32270,7 +32252,6 @@ static const gfx_ctx_driver_t *vk_context_driver_init_first(
{ {
const gfx_ctx_driver_t *ctx = const gfx_ctx_driver_t *ctx =
video_context_driver_init( video_context_driver_init(
p_rarch,
settings, settings,
data, data,
gfx_ctx_vk_drivers[i], ident, gfx_ctx_vk_drivers[i], ident,
@ -32309,7 +32290,6 @@ static const gfx_ctx_driver_t *gl_context_driver_init_first(
if (i >= 0) if (i >= 0)
{ {
const gfx_ctx_driver_t *ctx = video_context_driver_init( const gfx_ctx_driver_t *ctx = video_context_driver_init(
p_rarch,
settings, settings,
data, data,
gfx_ctx_gl_drivers[i], ident, gfx_ctx_gl_drivers[i], ident,
@ -32325,7 +32305,6 @@ static const gfx_ctx_driver_t *gl_context_driver_init_first(
{ {
const gfx_ctx_driver_t *ctx = const gfx_ctx_driver_t *ctx =
video_context_driver_init( video_context_driver_init(
p_rarch,
settings, settings,
data, data,
gfx_ctx_gl_drivers[i], ident, gfx_ctx_gl_drivers[i], ident,
@ -33438,7 +33417,6 @@ static void retroarch_deinit_drivers(
bool driver_ctl(enum driver_ctl_state state, void *data) bool driver_ctl(enum driver_ctl_state state, void *data)
{ {
struct rarch_state *p_rarch = &rarch_st;
driver_ctx_info_t *drv = (driver_ctx_info_t*)data; driver_ctx_info_t *drv = (driver_ctx_info_t*)data;
switch (state) switch (state)
@ -33446,6 +33424,7 @@ bool driver_ctl(enum driver_ctl_state state, void *data)
case RARCH_DRIVER_CTL_SET_REFRESH_RATE: case RARCH_DRIVER_CTL_SET_REFRESH_RATE:
{ {
float *hz = (float*)data; float *hz = (float*)data;
struct rarch_state *p_rarch = &rarch_st;
settings_t *settings = p_rarch->configuration_settings; settings_t *settings = p_rarch->configuration_settings;
unsigned audio_output_sample_rate = settings->uints.audio_output_sample_rate; unsigned audio_output_sample_rate = settings->uints.audio_output_sample_rate;
bool vrr_runloop_enable = settings->bools.vrr_runloop_enable; bool vrr_runloop_enable = settings->bools.vrr_runloop_enable;
@ -36236,7 +36215,7 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data)
input_mapper_reset(&p_rarch->input_driver_mapper); input_mapper_reset(&p_rarch->input_driver_mapper);
#ifdef HAVE_THREADS #ifdef HAVE_THREADS
retroarch_autosave_deinit(p_rarch); retroarch_autosave_deinit();
#endif #endif
command_event(CMD_EVENT_RECORD_DEINIT, NULL); command_event(CMD_EVENT_RECORD_DEINIT, NULL);
@ -36706,8 +36685,6 @@ const char *retroarch_get_shader_preset(void)
bool retroarch_override_setting_is_set( bool retroarch_override_setting_is_set(
enum rarch_override_setting enum_idx, void *data) enum rarch_override_setting enum_idx, void *data)
{ {
struct rarch_state *p_rarch = &rarch_st;
switch (enum_idx) switch (enum_idx)
{ {
case RARCH_OVERRIDE_SETTING_LIBRETRO_DEVICE: case RARCH_OVERRIDE_SETTING_LIBRETRO_DEVICE:
@ -36715,7 +36692,8 @@ bool retroarch_override_setting_is_set(
unsigned *val = (unsigned*)data; unsigned *val = (unsigned*)data;
if (val) if (val)
{ {
unsigned bit = *val; unsigned bit = *val;
struct rarch_state *p_rarch = &rarch_st;
return BIT256_GET(p_rarch->has_set_libretro_device, bit); return BIT256_GET(p_rarch->has_set_libretro_device, bit);
} }
} }
@ -39253,10 +39231,8 @@ bool core_run(void)
return true; return true;
} }
static bool core_verify_api_version(struct rarch_state *p_rarch) static bool core_verify_api_version(unsigned api_version)
{ {
unsigned api_version = p_rarch->current_core.retro_api_version();
RARCH_LOG("%s: %u\n%s %s: %u\n", RARCH_LOG("%s: %u\n%s %s: %u\n",
msg_hash_to_str(MSG_VERSION_OF_LIBRETRO_API), msg_hash_to_str(MSG_VERSION_OF_LIBRETRO_API),
api_version, api_version,
@ -39279,7 +39255,8 @@ static bool core_load(
{ {
p_rarch->current_core.poll_type = poll_type_behavior; p_rarch->current_core.poll_type = poll_type_behavior;
if (!core_verify_api_version(p_rarch)) if (!core_verify_api_version(
p_rarch->current_core.retro_api_version()))
return false; return false;
if (!core_init_libretro_cbs(p_rarch, if (!core_init_libretro_cbs(p_rarch,
&p_rarch->retro_ctx)) &p_rarch->retro_ctx))