diff --git a/camera/camera_driver.c b/camera/camera_driver.c index 9fbde34a9b..f0a86de452 100644 --- a/camera/camera_driver.c +++ b/camera/camera_driver.c @@ -160,7 +160,9 @@ void driver_camera_stop(void) **/ void driver_camera_poll(void) { - rarch_system_info_t *system = rarch_system_info_get_ptr(); + rarch_system_info_t *system = NULL; + + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (camera_driver && camera_driver->poll && camera_data) camera_driver->poll(camera_data, @@ -171,7 +173,9 @@ void driver_camera_poll(void) void init_camera(void) { settings_t *settings = config_get_ptr(); - rarch_system_info_t *system = rarch_system_info_get_ptr(); + rarch_system_info_t *system = NULL; + + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); /* Resource leaks will follow if camera is initialized twice. */ if (camera_data) @@ -199,7 +203,8 @@ void init_camera(void) static void uninit_camera(void) { - rarch_system_info_t *system = rarch_system_info_get_ptr(); + rarch_system_info_t *system = NULL; + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (camera_data && camera_driver) { diff --git a/command_event.c b/command_event.c index 90a63d95c5..9154bb1fb0 100644 --- a/command_event.c +++ b/command_event.c @@ -70,11 +70,15 @@ **/ static void event_disk_control_set_eject(bool new_state, bool print_log) { - char msg[128] = {0}; - bool error = false; - rarch_system_info_t *info = rarch_system_info_get_ptr(); - const struct retro_disk_control_callback *control = - info ? (const struct retro_disk_control_callback*)&info->disk_control : NULL; + char msg[128] = {0}; + bool error = false; + rarch_system_info_t *info = NULL; + const struct retro_disk_control_callback *control = NULL; + + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); + + if (info) + control = (const struct retro_disk_control_callback*)&info->disk_control; if (!control || !control->get_num_images) return; @@ -116,9 +120,13 @@ static void event_disk_control_set_index(unsigned idx) unsigned num_disks; bool error = false; char msg[128] = {0}; - rarch_system_info_t *info = rarch_system_info_get_ptr(); - const struct retro_disk_control_callback *control = - info ? (const struct retro_disk_control_callback*)&info->disk_control : NULL; + rarch_system_info_t *info = NULL; + const struct retro_disk_control_callback *control = NULL; + + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); + + if (info) + control = (const struct retro_disk_control_callback*)&info->disk_control; if (!control || !control->get_num_images) return; @@ -166,13 +174,16 @@ static void event_disk_control_set_index(unsigned idx) void event_disk_control_append_image(const char *path) { unsigned new_idx; - char msg[128] = {0}; - struct retro_game_info info = {0}; - global_t *global = global_get_ptr(); - rarch_system_info_t *sysinfo = rarch_system_info_get_ptr(); - const struct retro_disk_control_callback *control = - sysinfo ? (const struct retro_disk_control_callback*)&sysinfo->disk_control - : NULL; + char msg[128] = {0}; + struct retro_game_info info = {0}; + global_t *global = global_get_ptr(); + const struct retro_disk_control_callback *control = NULL; + rarch_system_info_t *sysinfo = NULL; + + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &sysinfo); + + if (sysinfo) + control = (const struct retro_disk_control_callback*)&sysinfo->disk_control; if (!control) return; @@ -309,7 +320,9 @@ static void event_init_controllers(void) { unsigned i; settings_t *settings = config_get_ptr(); - rarch_system_info_t *info = rarch_system_info_get_ptr(); + rarch_system_info_t *info = NULL; + + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); for (i = 0; i < MAX_USERS; i++) { @@ -869,11 +882,13 @@ static bool event_update_system_info(struct retro_system_info *_info, **/ bool event_command(enum event_command cmd) { - unsigned i = 0; - bool boolean = false; - global_t *global = global_get_ptr(); - settings_t *settings = config_get_ptr(); - rarch_system_info_t *info = rarch_system_info_get_ptr(); + unsigned i = 0; + bool boolean = false; + global_t *global = global_get_ptr(); + settings_t *settings = config_get_ptr(); + rarch_system_info_t *info = NULL; + + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); (void)i; diff --git a/configuration.c b/configuration.c index 254e1afe8d..3ff08a1acc 100644 --- a/configuration.c +++ b/configuration.c @@ -1923,7 +1923,9 @@ bool config_load_override(void) bool should_append = false; global_t *global = global_get_ptr(); settings_t *settings = config_get_ptr(); - rarch_system_info_t *system = rarch_system_info_get_ptr(); + rarch_system_info_t *system = NULL; + + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (!global || !settings || !system) { @@ -2111,7 +2113,9 @@ bool config_load_remap(void) char game_path[PATH_MAX_LENGTH] = {0}; /* final path for game-specific configuration (prefix+suffix) */ global_t *global = global_get_ptr(); settings_t *settings = config_get_ptr(); - rarch_system_info_t *system = rarch_system_info_get_ptr(); + rarch_system_info_t *system = NULL; + + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); /* Early return in case a library isn't loaded or remapping is disabled */ if (!system->info.library_name || !strcmp(system->info.library_name,"No Core")) diff --git a/content.c b/content.c index ffda550b29..8c1fd0b14b 100644 --- a/content.c +++ b/content.c @@ -394,7 +394,9 @@ static bool load_content_need_fullpath( char new_basedir[PATH_MAX_LENGTH] = {0}; bool ret = false; settings_t *settings = config_get_ptr(); - rarch_system_info_t *sys_info= rarch_system_info_get_ptr(); + rarch_system_info_t *sys_info= NULL; + + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &sys_info); if (sys_info && sys_info->info.block_extract) return true; @@ -552,11 +554,13 @@ bool init_content_file(void) bool ret = false; struct string_list *content = NULL; const struct retro_subsystem_info *special = NULL; + rarch_system_info_t *system = NULL; settings_t *settings = config_get_ptr(); - rarch_system_info_t *system = rarch_system_info_get_ptr(); global_t *global = global_get_ptr(); temporary_content = string_list_new(); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + if (!temporary_content) goto error; diff --git a/driver.c b/driver.c index ee1cd85091..9295adabd1 100644 --- a/driver.c +++ b/driver.c @@ -231,8 +231,9 @@ void init_drivers_pre(void) static void driver_adjust_system_rates(void) { - rarch_system_info_t *system = rarch_system_info_get_ptr(); - + rarch_system_info_t *system = NULL; + + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); audio_driver_ctl(RARCH_AUDIO_CTL_MONITOR_ADJUST_SYSTEM_RATES, NULL); video_driver_ctl(RARCH_DISPLAY_CTL_MONITOR_ADJUST_SYSTEM_RATES, NULL); @@ -271,9 +272,11 @@ void driver_set_refresh_rate(float hz) void driver_set_nonblock_state(void) { settings_t *settings = config_get_ptr(); - rarch_system_info_t *system = rarch_system_info_get_ptr(); bool enable = input_driver_ctl( RARCH_INPUT_CTL_IS_NONBLOCK_STATE, NULL); + rarch_system_info_t *system = NULL; + + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); /* Only apply non-block-state for video if we're using vsync. */ if (video_driver_ctl(RARCH_DISPLAY_CTL_IS_ACTIVE, NULL) diff --git a/dynamic.c b/dynamic.c index 9fb39e7066..a35fcabe76 100644 --- a/dynamic.c +++ b/dynamic.c @@ -606,7 +606,9 @@ bool rarch_environment_cb(unsigned cmd, void *data) unsigned p; settings_t *settings = config_get_ptr(); global_t *global = global_get_ptr(); - rarch_system_info_t *system = rarch_system_info_get_ptr(); + rarch_system_info_t *system = NULL; + + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (ignore_environment_cb) return false; diff --git a/frontend/frontend.c b/frontend/frontend.c index e7e6d95672..888a58fb15 100644 --- a/frontend/frontend.c +++ b/frontend/frontend.c @@ -152,7 +152,9 @@ static void history_playlist_push(content_playlist_t *playlist, { char tmp[PATH_MAX_LENGTH] = {0}; global_t *global = global_get_ptr(); - rarch_system_info_t *system = rarch_system_info_get_ptr(); + rarch_system_info_t *system = NULL; + + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (!playlist || (global->inited.core.type == CORE_TYPE_DUMMY) || !info) return; @@ -285,7 +287,9 @@ int rarch_main(int argc, char *argv[], void *data) { char *fullpath = NULL; global_t *global = global_get_ptr(); - rarch_system_info_t *system = rarch_system_info_get_ptr(); + rarch_system_info_t *system = NULL; + + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath); diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 90e45a038a..aa96ed11f6 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -597,16 +597,18 @@ error: static bool init_video(void) { unsigned max_dim, scale, width, height; - video_viewport_t *custom_vp = NULL; - const input_driver_t *tmp = NULL; + video_viewport_t *custom_vp = NULL; + const input_driver_t *tmp = NULL; const struct retro_game_geometry *geom = NULL; - video_info_t video = {0}; - static uint16_t dummy_pixels[32] = {0}; - settings_t *settings = config_get_ptr(); - rarch_system_info_t *system = rarch_system_info_get_ptr(); - struct retro_system_av_info *av_info = + rarch_system_info_t *system = NULL; + video_info_t video = {0}; + static uint16_t dummy_pixels[32] = {0}; + settings_t *settings = config_get_ptr(); + struct retro_system_av_info *av_info = video_viewport_get_system_av_info(); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + init_video_filter(video_driver_state.pix_fmt); event_command(EVENT_CMD_SHADER_DIR_INIT); @@ -1016,7 +1018,9 @@ bool video_monitor_get_fps(char *buf, size_t size, static retro_time_t curr_time; static retro_time_t fps_time; retro_time_t new_time = retro_get_time_usec(); - rarch_system_info_t *system = rarch_system_info_get_ptr(); + rarch_system_info_t *system = NULL; + + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); *buf = '\0'; @@ -1153,10 +1157,12 @@ static void video_monitor_adjust_system_rates(void) { float timing_skew; const struct retro_system_timing *info = NULL; - struct retro_system_av_info *av_info = + struct retro_system_av_info *av_info = video_viewport_get_system_av_info(); - settings_t *settings = config_get_ptr(); - rarch_system_info_t *system = rarch_system_info_get_ptr(); + settings_t *settings = config_get_ptr(); + rarch_system_info_t *system = NULL; + + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (!system) return; @@ -1197,6 +1203,7 @@ void video_driver_menu_settings(void **list_data, void *list_info_data, rarch_setting_group_info_t *group_info = (rarch_setting_group_info_t*)group_data; rarch_setting_group_info_t *subgroup_info = (rarch_setting_group_info_t*)subgroup_data; global_t *global = global_get_ptr(); + (void)list; (void)list_info; (void)group_info; diff --git a/input/input_keyboard.c b/input/input_keyboard.c index 0de8397fe0..bdf82fa2f7 100644 --- a/input/input_keyboard.c +++ b/input/input_keyboard.c @@ -237,7 +237,9 @@ void input_keyboard_event(bool down, unsigned code, uint32_t character, uint16_t mod, unsigned device) { static bool deferred_wait_keys; - rarch_system_info_t *system = rarch_system_info_get_ptr(); + rarch_system_info_t *system = NULL; + + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (deferred_wait_keys) { diff --git a/location/location_driver.c b/location/location_driver.c index 0ae87370c6..5d8b6b6e0f 100644 --- a/location/location_driver.c +++ b/location/location_driver.c @@ -191,7 +191,9 @@ bool driver_location_get_position(double *lat, double *lon, void init_location(void) { - rarch_system_info_t *system = rarch_system_info_get_ptr(); + rarch_system_info_t *system = NULL; + + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); /* Resource leaks will follow if location interface is initialized twice. */ if (location_data) @@ -213,7 +215,9 @@ void init_location(void) static void uninit_location(void) { - rarch_system_info_t *system = rarch_system_info_get_ptr(); + rarch_system_info_t *system = NULL; + + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (location_data && location_driver) { diff --git a/menu/cbs/menu_cbs_deferred_push.c b/menu/cbs/menu_cbs_deferred_push.c index 1c532f7cbb..e5469f90ad 100644 --- a/menu/cbs/menu_cbs_deferred_push.c +++ b/menu/cbs/menu_cbs_deferred_push.c @@ -510,10 +510,12 @@ enum static int general_push(menu_displaylist_info_t *info, unsigned id, unsigned type) { settings_t *settings = config_get_ptr(); - rarch_system_info_t *system = rarch_system_info_get_ptr(); + rarch_system_info_t *system = NULL; menu_handle_t *menu = menu_driver_get_ptr(); const char *exts = core_info_list_get_all_extensions(); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + switch (id) { case PUSH_DEFAULT: diff --git a/menu/cbs/menu_cbs_get_value.c b/menu/cbs/menu_cbs_get_value.c index 988cda45d6..29c8706c86 100644 --- a/menu/cbs/menu_cbs_get_value.c +++ b/menu/cbs/menu_cbs_get_value.c @@ -566,10 +566,11 @@ static void menu_action_setting_disp_set_label_menu_disk_index( const char *path, char *s2, size_t len2) { - unsigned images = 0, current = 0; - rarch_system_info_t *system = rarch_system_info_get_ptr(); + unsigned images = 0, current = 0; + rarch_system_info_t *system = NULL; struct retro_disk_control_callback *control = NULL; + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (!system) return; @@ -948,8 +949,10 @@ static void menu_action_setting_disp_set_label_core_option_create( const char *path, char *s2, size_t len2) { - rarch_system_info_t *system = rarch_system_info_get_ptr(); + rarch_system_info_t *system = NULL; global_t *global = global_get_ptr(); + + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (!system) return; @@ -972,8 +975,10 @@ static void menu_action_setting_disp_set_label(file_list_t* list, const char *path, char *s2, size_t len2) { - rarch_system_info_t *system = rarch_system_info_get_ptr(); - uint32_t hash_label = menu_hash_calculate(label); + rarch_system_info_t *system = NULL; + uint32_t hash_label = menu_hash_calculate(label); + + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); *s = '\0'; *w = 19; diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 7eba9e0563..2f38e26063 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -887,9 +887,14 @@ static int generic_action_ok_remap_file_save(const char *path, char file[PATH_MAX_LENGTH]; global_t *global = global_get_ptr(); settings_t *settings = config_get_ptr(); - rarch_system_info_t *info = rarch_system_info_get_ptr(); + rarch_system_info_t *info = NULL; const char *game_name = NULL; - const char *core_name = info ? info->info.library_name : NULL; + const char *core_name = NULL; + + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); + + if (info) + core_name = info->info.library_name; fill_pathname_join(directory, settings->input_remapping_directory, core_name, PATH_MAX_LENGTH); @@ -1266,16 +1271,17 @@ static int action_ok_disk_cycle_tray_status(const char *path, static int action_ok_option_create(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { - settings_t *settings = config_get_ptr(); - global_t *global = global_get_ptr(); - rarch_system_info_t *system = rarch_system_info_get_ptr(); - + settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); + rarch_system_info_t *system = NULL; const char *core_name = NULL; const char *game_name = NULL; char core_path[PATH_MAX_LENGTH] = {0}; char game_path[PATH_MAX_LENGTH] = {0}; char config_directory[PATH_MAX_LENGTH] = {0}; + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + /* Config directory: config_directory. * Try config directory setting first, * fallback to the location of the current configuration file. */ diff --git a/menu/cbs/menu_cbs_start.c b/menu/cbs/menu_cbs_start.c index d024417a11..524069d3f7 100644 --- a/menu/cbs/menu_cbs_start.c +++ b/menu/cbs/menu_cbs_start.c @@ -247,8 +247,10 @@ static int action_start_cheat_num_passes(unsigned type, const char *label) static int action_start_core_setting(unsigned type, const char *label) { - unsigned idx = type - MENU_SETTINGS_CORE_OPTION_START; - rarch_system_info_t *system = rarch_system_info_get_ptr(); + unsigned idx = type - MENU_SETTINGS_CORE_OPTION_START; + rarch_system_info_t *system = NULL; + + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (system) core_option_set_default(system->core_options, idx); diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index db6f84f5b1..b5a25f2c3f 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -1716,7 +1716,9 @@ static int menu_displaylist_parse_load_content_settings(menu_displaylist_info_t if (global->inited.main && (global->inited.core.type != CORE_TYPE_DUMMY)) { - rarch_system_info_t *system = rarch_system_info_get_ptr(); + rarch_system_info_t *system = NULL; + + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); menu_entries_push(info->list, menu_hash_to_str(MENU_LABEL_VALUE_RESUME_CONTENT), @@ -2019,9 +2021,11 @@ static int menu_displaylist_parse_options_remappings(menu_displaylist_info_t *in { unsigned p, retro_id; settings_t *settings = config_get_ptr(); - rarch_system_info_t *system = rarch_system_info_get_ptr(); + rarch_system_info_t *system = NULL; menu_handle_t *menu = menu_driver_get_ptr(); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + for (p = 0; p < settings->input.max_users; p++) { char key_type[PATH_MAX_LENGTH], key_analog[PATH_MAX_LENGTH]; @@ -2406,7 +2410,9 @@ int menu_displaylist_push_list(menu_displaylist_info_t *info, unsigned type) menu_handle_t *menu = menu_driver_get_ptr(); global_t *global = global_get_ptr(); settings_t *settings = config_get_ptr(); - rarch_system_info_t *system = rarch_system_info_get_ptr(); + rarch_system_info_t *system = NULL; + + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (menu_driver_list_push(info, type)) return 0; diff --git a/menu/menu_driver.c b/menu/menu_driver.c index 5122e3ab6a..bd6fafc124 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -286,7 +286,9 @@ static void menu_driver_toggle(bool latch) const menu_ctx_driver_t *menu_driver = menu_ctx_driver_get_ptr(); settings_t *settings = config_get_ptr(); global_t *global = global_get_ptr(); - rarch_system_info_t *system = rarch_system_info_get_ptr(); + rarch_system_info_t *system = NULL; + + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (menu_driver->toggle) menu_driver->toggle(menu_driver_data->userdata, latch); diff --git a/menu/menu_entries.c b/menu/menu_entries.c index 26b463538f..edf52f7bad 100644 --- a/menu/menu_entries.c +++ b/menu/menu_entries.c @@ -458,11 +458,13 @@ bool menu_entries_show_back(void) * (shown at the top of the UI). */ int menu_entries_get_core_title(char *s, size_t len) { + rarch_system_info_t *info = NULL; settings_t *settings = config_get_ptr(); - rarch_system_info_t *info = rarch_system_info_get_ptr(); const char *core_name = g_system_menu.library_name; const char *core_version = g_system_menu.library_version; + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); + if (!settings->menu.core_enable) return -1; diff --git a/menu/menu_setting.c b/menu/menu_setting.c index f2ec4e748c..81890b3f88 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -972,10 +972,12 @@ static void setting_get_string_representation_uint_libretro_device(void *data, { unsigned index_offset; const struct retro_controller_description *desc = NULL; - const char *name = NULL; - rarch_setting_t *setting = (rarch_setting_t*)data; - settings_t *settings = config_get_ptr(); - rarch_system_info_t *system = rarch_system_info_get_ptr(); + const char *name = NULL; + rarch_setting_t *setting = (rarch_setting_t*)data; + settings_t *settings = config_get_ptr(); + rarch_system_info_t *system = NULL; + + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (!setting) return; @@ -2183,7 +2185,9 @@ static int setting_action_start_libretro_device_type(void *data) const struct retro_controller_info *desc = NULL; rarch_setting_t *setting = (rarch_setting_t*)data; settings_t *settings = config_get_ptr(); - rarch_system_info_t *system = rarch_system_info_get_ptr(); + rarch_system_info_t *system = NULL; + + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (setting_generic_action_start_default(setting) != 0) return -1; @@ -2326,9 +2330,11 @@ static int setting_action_left_libretro_device_type( unsigned current_device, current_idx, i, devices[128], types = 0, port = 0; const struct retro_controller_info *desc = NULL; - rarch_setting_t *setting = (rarch_setting_t*)data; - settings_t *settings = config_get_ptr(); - rarch_system_info_t *system = rarch_system_info_get_ptr(); + rarch_setting_t *setting = (rarch_setting_t*)data; + settings_t *settings = config_get_ptr(); + rarch_system_info_t *system = NULL; + + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (!setting) return -1; @@ -2384,9 +2390,11 @@ static int setting_action_right_libretro_device_type( unsigned current_device, current_idx, i, devices[128], types = 0, port = 0; const struct retro_controller_info *desc = NULL; - rarch_setting_t *setting = (rarch_setting_t*)data; - settings_t *settings = config_get_ptr(); - rarch_system_info_t *system = rarch_system_info_get_ptr(); + rarch_setting_t *setting = (rarch_setting_t*)data; + settings_t *settings = config_get_ptr(); + rarch_system_info_t *system = NULL; + + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (!setting) return -1; @@ -2756,10 +2764,12 @@ void general_write_handler(void *data) settings_t *settings = config_get_ptr(); global_t *global = global_get_ptr(); file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0); - rarch_system_info_t *system = rarch_system_info_get_ptr(); + rarch_system_info_t *system = NULL; uint32_t hash = setting ? menu_hash_calculate(setting->name) : 0; uint64_t flags = menu_setting_get_flags(setting); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + if (!setting) return; @@ -3005,7 +3015,9 @@ static bool setting_append_list_input_player_options( global_t *global = global_get_ptr(); const struct retro_keybind* const defaults = (user == 0) ? retro_keybinds_1 : retro_keybinds_rest; - rarch_system_info_t *system = rarch_system_info_get_ptr(); + rarch_system_info_t *system = NULL; + + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); snprintf(buffer[user], sizeof(buffer[user]), "%s %u", menu_hash_to_str(MENU_VALUE_USER), user + 1); diff --git a/netplay.c b/netplay.c index 8cddc6dfb8..24c6e9d55d 100644 --- a/netplay.c +++ b/netplay.c @@ -888,10 +888,15 @@ static uint32_t implementation_magic_value(void) { size_t i, len; uint32_t res = 0; + rarch_system_info_t *info = NULL; + const char *lib = NULL; const char *ver = PACKAGE_VERSION; unsigned api = core.retro_api_version(); - rarch_system_info_t *info = rarch_system_info_get_ptr(); - const char *lib = info ? info->info.library_name : NULL; + + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); + + if (info) + lib = info->info.library_name; res |= api; diff --git a/retroarch.c b/retroarch.c index 94fc7196d0..73b30c3301 100644 --- a/retroarch.c +++ b/retroarch.c @@ -352,14 +352,17 @@ const char *rarch_get_current_savefile_dir(void) static void set_paths_redirect(const char *path) { + uint32_t global_library_name_hash = 0; bool check_global_library_name_hash = false; global_t *global = global_get_ptr(); settings_t *settings = config_get_ptr(); - rarch_system_info_t *info = rarch_system_info_get_ptr(); + rarch_system_info_t *info = NULL; + + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); - uint32_t global_library_name_hash = ((global && info->info.library_name && + if (global && info->info.library_name && (info->info.library_name[0] != '\0')) - ? msg_hash_calculate(info->info.library_name) : 0); + global_library_name_hash = msg_hash_calculate(info->info.library_name); /* Initialize current save directories with the values from the config */ strlcpy(current_savefile_dir, @@ -971,7 +974,9 @@ static void parse_input(int argc, char *argv[]) static void rarch_init_savefile_paths(void) { global_t *global = global_get_ptr(); - rarch_system_info_t *system = rarch_system_info_get_ptr(); + rarch_system_info_t *system = NULL; + + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); event_command(EVENT_CMD_SAVEFILES_DEINIT); diff --git a/runloop.c b/runloop.c index 8b448b71b4..12ee08b5c7 100644 --- a/runloop.c +++ b/runloop.c @@ -70,7 +70,6 @@ #define DEFAULT_EXT "" #endif -static rarch_system_info_t g_system; #ifdef HAVE_MENU struct retro_system_info g_system_menu; @@ -93,10 +92,6 @@ global_t *global_get_ptr(void) return &g_extern; } -rarch_system_info_t *rarch_system_info_get_ptr(void) -{ - return &g_system; -} const char *runloop_msg_queue_pull(void) { @@ -413,16 +408,17 @@ static void check_shader_dir(bool pressed_next, bool pressed_prev) **/ static bool rarch_game_specific_options(char **output) { - settings_t *settings = config_get_ptr(); - global_t *global = global_get_ptr(); - rarch_system_info_t *system = rarch_system_info_get_ptr(); - + settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); + rarch_system_info_t *system = NULL; const char *core_name = NULL; const char *game_name = NULL; config_file_t *option_file = NULL; char game_path[PATH_MAX_LENGTH] = {0}; char config_directory[PATH_MAX_LENGTH] = {0}; + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + core_name = system ? system->info.library_name : NULL; game_name = global ? path_basename(global->name.base) : NULL; @@ -472,6 +468,7 @@ static void runloop_data_clear_state(void) bool runloop_ctl(enum runloop_ctl_state state, void *data) { static char runloop_fullpath[PATH_MAX_LENGTH]; + static rarch_system_info_t runloop_system; static unsigned runloop_max_frames = false; static bool runloop_frame_time_last = false; static bool runloop_set_frame_limit = false; @@ -487,7 +484,6 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) static slock_t *runloop_msg_queue_lock = NULL; #endif settings_t *settings = config_get_ptr(); - rarch_system_info_t *system = rarch_system_info_get_ptr(); switch (state) { @@ -497,54 +493,62 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) case RUNLOOP_CTL_SHADER_DIR_INIT: return shader_dir_init(); case RUNLOOP_CTL_SYSTEM_INFO_INIT: - core.retro_get_system_info(&system->info); + core.retro_get_system_info(&runloop_system.info); - if (!system->info.library_name) - system->info.library_name = msg_hash_to_str(MSG_UNKNOWN); - if (!system->info.library_version) - system->info.library_version = "v0"; + if (!runloop_system.info.library_name) + runloop_system.info.library_name = msg_hash_to_str(MSG_UNKNOWN); + if (!runloop_system.info.library_version) + runloop_system.info.library_version = "v0"; #ifndef RARCH_CONSOLE - strlcpy(system->title_buf, - msg_hash_to_str(MSG_PROGRAM), sizeof(system->title_buf)); - strlcat(system->title_buf, " : ", sizeof(system->title_buf)); + strlcpy(runloop_system.title_buf, + msg_hash_to_str(MSG_PROGRAM), sizeof(runloop_system.title_buf)); + strlcat(runloop_system.title_buf, " : ", sizeof(runloop_system.title_buf)); #endif - strlcat(system->title_buf, system->info.library_name, sizeof(system->title_buf)); - strlcat(system->title_buf, " ", sizeof(system->title_buf)); - strlcat(system->title_buf, system->info.library_version, sizeof(system->title_buf)); - strlcpy(system->valid_extensions, system->info.valid_extensions ? - system->info.valid_extensions : DEFAULT_EXT, - sizeof(system->valid_extensions)); - system->block_extract = system->info.block_extract; + strlcat(runloop_system.title_buf, runloop_system.info.library_name, sizeof(runloop_system.title_buf)); + strlcat(runloop_system.title_buf, " ", sizeof(runloop_system.title_buf)); + strlcat(runloop_system.title_buf, runloop_system.info.library_version, sizeof(runloop_system.title_buf)); + strlcpy(runloop_system.valid_extensions, runloop_system.info.valid_extensions ? + runloop_system.info.valid_extensions : DEFAULT_EXT, + sizeof(runloop_system.valid_extensions)); + runloop_system.block_extract = runloop_system.info.block_extract; break; case RUNLOOP_CTL_GET_CORE_OPTION_SIZE: { unsigned *idx = (unsigned*)data; if (!idx) return false; - *idx = core_option_size(system->core_options); + *idx = core_option_size(runloop_system.core_options); } return true; case RUNLOOP_CTL_HAS_CORE_OPTIONS: - return system && system->core_options; - case RUNLOOP_CTL_SYSTEM_INFO_FREE: - if (system->core_options) + return runloop_system.core_options; + case RUNLOOP_CTL_SYSTEM_INFO_GET: { - core_option_flush(system->core_options); - core_option_free(system->core_options); + rarch_system_info_t **system = (rarch_system_info_t**)data; + if (!system) + return false; + *system = &runloop_system; + } + return true; + case RUNLOOP_CTL_SYSTEM_INFO_FREE: + if (runloop_system.core_options) + { + core_option_flush(runloop_system.core_options); + core_option_free(runloop_system.core_options); } - system->core_options = NULL; + runloop_system.core_options = NULL; /* No longer valid. */ - if (system->special) - free(system->special); - system->special = NULL; - if (system->ports) - free(system->ports); - system->ports = NULL; + if (runloop_system.special) + free(runloop_system.special); + runloop_system.special = NULL; + if (runloop_system.ports) + free(runloop_system.ports); + runloop_system.ports = NULL; - memset(&g_system, 0, sizeof(rarch_system_info_t)); + memset(&runloop_system, 0, sizeof(rarch_system_info_t)); break; case RUNLOOP_CTL_IS_FRAME_COUNT_END: { @@ -998,14 +1002,14 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) rarch_task_deinit(); break; case RUNLOOP_CTL_IS_CORE_OPTION_UPDATED: - return system->core_options ? - core_option_updated(system->core_options) : false; + return runloop_system.core_options ? + core_option_updated(runloop_system.core_options) : false; case RUNLOOP_CTL_CORE_OPTION_PREV: { unsigned *idx = (unsigned*)data; if (!idx) return false; - core_option_prev(system->core_options, *idx); + core_option_prev(runloop_system.core_options, *idx); if (ui_companion_is_on_foreground()) ui_companion_driver_notify_refresh(); } @@ -1015,7 +1019,7 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) unsigned *idx = (unsigned*)data; if (!idx) return false; - core_option_next(system->core_options, *idx); + core_option_next(runloop_system.core_options, *idx); if (ui_companion_is_on_foreground()) ui_companion_driver_notify_refresh(); } @@ -1024,11 +1028,11 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) { struct retro_variable *var = (struct retro_variable*)data; - if (!system || !system->core_options || !var) + if (!runloop_system.core_options || !var) return false; RARCH_LOG("Environ GET_VARIABLE %s:\n", var->key); - core_option_get(system->core_options, var); + core_option_get(runloop_system.core_options, var); RARCH_LOG("\t%s\n", var->value ? var->value : "N/A"); } return true; @@ -1054,22 +1058,22 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) if(ret) { - system->core_options = core_option_new(game_options_path, vars); + runloop_system.core_options = core_option_new(game_options_path, vars); free(game_options_path); } else - system->core_options = core_option_new(options_path, vars); + runloop_system.core_options = core_option_new(options_path, vars); } break; case RUNLOOP_CTL_CORE_OPTIONS_DEINIT: - if (!system->core_options) + if (!runloop_system.core_options) return false; - core_option_flush(system->core_options); - core_option_free(system->core_options); + core_option_flush(runloop_system.core_options); + core_option_free(runloop_system.core_options); - system->core_options = NULL; + runloop_system.core_options = NULL; return true; case RUNLOOP_CTL_NONE: default: @@ -1174,12 +1178,14 @@ int runloop_iterate(unsigned *sleep_ms) static retro_input_t last_input = 0; settings_t *settings = config_get_ptr(); global_t *global = global_get_ptr(); - rarch_system_info_t *system = rarch_system_info_get_ptr(); + rarch_system_info_t *system = NULL; cmd.state[1] = last_input; cmd.state[0] = input_keys_pressed(); last_input = cmd.state[0]; + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + if (runloop_ctl(RUNLOOP_CTL_IS_FRAME_TIME_LAST, NULL)) { frame_time_last = 0; diff --git a/runloop.h b/runloop.h index d671e2fb58..969626ef56 100644 --- a/runloop.h +++ b/runloop.h @@ -100,6 +100,7 @@ enum runloop_ctl_state RUNLOOP_CTL_CORE_OPTIONS_DEINIT, RUNLOOP_CTL_SHADER_DIR_DEINIT, RUNLOOP_CTL_SHADER_DIR_INIT, + RUNLOOP_CTL_SYSTEM_INFO_GET, RUNLOOP_CTL_SYSTEM_INFO_INIT, RUNLOOP_CTL_SYSTEM_INFO_FREE, RUNLOOP_CTL_PREPARE_DUMMY diff --git a/system.h b/system.h index 9e2dbc0206..bde4dda5e1 100644 --- a/system.h +++ b/system.h @@ -67,8 +67,6 @@ typedef struct rarch_system_info extern struct retro_system_info g_system_menu; #endif -rarch_system_info_t *rarch_system_info_get_ptr(void); - #ifdef __cplusplus } #endif