Revert "Create runloop_get_system_info/runloop_free_system_info/runloop_init_system_info"

This reverts commit 35bf38e05c.
This commit is contained in:
twinaphex 2016-05-12 09:37:21 +02:00
parent 6b33c19802
commit df3b090d7a
18 changed files with 97 additions and 110 deletions

View File

@ -733,7 +733,7 @@ static void command_event_disk_control_set_eject(bool new_state, bool print_log)
rarch_system_info_t *info = NULL;
const struct retro_disk_control_callback *control = NULL;
runloop_get_system_info((void**)&info);
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info);
if (info)
control = (const struct retro_disk_control_callback*)&info->disk_control_cb;
@ -781,7 +781,7 @@ static void command_event_disk_control_set_index(unsigned idx)
rarch_system_info_t *info = NULL;
const struct retro_disk_control_callback *control = NULL;
runloop_get_system_info((void**)&info);
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info);
if (info)
control = (const struct retro_disk_control_callback*)&info->disk_control_cb;
@ -838,7 +838,7 @@ static bool command_event_disk_control_append_image(const char *path)
const struct retro_disk_control_callback *control = NULL;
rarch_system_info_t *sysinfo = NULL;
runloop_get_system_info((void**)&info);
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &sysinfo);
if (sysinfo)
control = (const struct retro_disk_control_callback*)
@ -983,7 +983,7 @@ static void command_event_init_controllers(void)
settings_t *settings = config_get_ptr();
rarch_system_info_t *info = NULL;
runloop_get_system_info((void**)&info);
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info);
for (i = 0; i < MAX_USERS; i++)
{
@ -1236,7 +1236,7 @@ static bool command_event_init_core(enum rarch_core_type *data)
if (!core_init_symbols(data))
return false;
runloop_get_system_info((void**)&info);
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_INIT, NULL);
/* auto overrides: apply overrides */
if(settings->auto_overrides_enable)
@ -1591,7 +1591,7 @@ bool command_event(enum event_command cmd, void *data)
settings_t *settings = config_get_ptr();
rarch_system_info_t *info = NULL;
runloop_get_system_info((void**)&info);
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info);
(void)i;

View File

@ -1965,7 +1965,7 @@ bool config_load_override(void)
settings_t *settings = config_get_ptr();
rarch_system_info_t *system = NULL;
runloop_get_system_info((void**)&system);
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
if (system)
core_name = system->info.library_name;
@ -2143,7 +2143,7 @@ bool config_load_remap(void)
settings_t *settings = config_get_ptr();
rarch_system_info_t *system = NULL;
runloop_get_system_info((void**)&system);
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
if (system)
core_name = system->info.library_name;

View File

@ -1329,7 +1329,7 @@ static bool load_content_from_compressed_archive(
settings_t *settings = config_get_ptr();
rarch_system_info_t *sys_info= NULL;
runloop_get_system_info((void**)sys_info);
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &sys_info);
if (sys_info && sys_info->info.block_extract)
return true;
@ -1648,7 +1648,7 @@ static bool content_file_init(struct string_list *temporary_content)
rarch_system_info_t *system = NULL;
global_t *global = global_get_ptr();
runloop_get_system_info((void**)system);
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
if (*global->subsystem)
{

View File

@ -578,9 +578,7 @@ void uninit_libretro_sym(struct retro_core_t *current_core)
memset(current_core, 0, sizeof(struct retro_core_t));
runloop_ctl(RUNLOOP_CTL_CORE_OPTIONS_DEINIT, NULL);
runloop_free_system_info();
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_FREE, NULL);
runloop_ctl(RUNLOOP_CTL_FRAME_TIME_FREE, NULL);
camera_driver_ctl(RARCH_CAMERA_CTL_UNSET_ACTIVE, NULL);
location_driver_ctl(RARCH_LOCATION_CTL_UNSET_ACTIVE, NULL);
@ -742,7 +740,7 @@ bool rarch_environment_cb(unsigned cmd, void *data)
global_t *global = global_get_ptr();
rarch_system_info_t *system = NULL;
runloop_get_system_info((void**)&system);
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
if (ignore_environment_cb)
return false;

View File

@ -130,7 +130,7 @@ int rarch_main(int argc, char *argv[], void *data)
return 0;
}
runloop_get_system_info((void**)&system);
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath);
if (content_is_inited() || content_does_not_need_content())

View File

@ -598,7 +598,7 @@ static bool init_video(void)
struct retro_system_av_info *av_info =
video_viewport_get_system_av_info();
runloop_get_system_info((void**)&system);
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
init_video_filter(video_driver_state.pix_fmt);
command_event(CMD_EVENT_SHADER_DIR_INIT, NULL);

View File

@ -203,7 +203,7 @@ void init_location(void)
{
rarch_system_info_t *system = NULL;
runloop_get_system_info((void**)&system);
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
/* Resource leaks will follow if location interface is initialized twice. */
if (location_data)
@ -227,7 +227,7 @@ static void uninit_location(void)
{
rarch_system_info_t *system = NULL;
runloop_get_system_info((void**)&system);
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
if (location_data && location_driver)
{

View File

@ -345,8 +345,7 @@ static int general_push(menu_displaylist_info_t *info,
core_info_get_list(&list);
menu_driver_ctl(RARCH_MENU_CTL_SYSTEM_INFO_GET, &system_menu);
runloop_get_system_info((void**)&system);
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
switch (id)
{

View File

@ -778,8 +778,7 @@ static void menu_action_setting_disp_set_label_menu_disk_index(
rarch_system_info_t *system = NULL;
struct retro_disk_control_callback *control = NULL;
runloop_get_system_info((void**)&system);
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
if (!system)
return;
@ -1165,8 +1164,7 @@ static void menu_action_setting_disp_set_label_core_option_create(
rarch_system_info_t *system = NULL;
global_t *global = global_get_ptr();
runloop_get_system_info((void**)&system);
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
if (!system)
return;

View File

@ -1013,7 +1013,7 @@ static int generic_action_ok_remap_file_save(const char *path,
const char *game_name = NULL;
const char *core_name = NULL;
runloop_get_system_info((void**)&info);
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info);
if (info)
core_name = info->info.library_name;

View File

@ -685,7 +685,7 @@ static int mui_get_core_title(char *s, size_t len)
core_name = system->library_name;
core_version = system->library_version;
runloop_get_system_info((void**)&info);
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info);
if (!settings->menu.core_enable)
return -1;

View File

@ -2157,7 +2157,7 @@ static int menu_displaylist_parse_load_content_settings(
{
rarch_system_info_t *system = NULL;
runloop_get_system_info((void**)&system);
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
menu_entries_add(info->list,
menu_hash_to_str(MENU_LABEL_VALUE_RESUME_CONTENT),
@ -2518,7 +2518,7 @@ static int menu_displaylist_parse_options_remappings(
if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu))
return -1;
runloop_get_system_info((void**)&system);
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
for (p = 0; p < settings->input.max_users; p++)
{
@ -3326,7 +3326,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data)
case DISPLAYLIST_MAIN_MENU:
{
rarch_system_info_t *system = NULL;
runloop_get_system_info((void**)&system);
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
if (!rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL))
menu_displaylist_parse_settings(menu, info,

View File

@ -448,7 +448,7 @@ int menu_entries_get_core_title(char *s, size_t len)
core_name = system->library_name;
core_version = system->library_version;
runloop_get_system_info((void**)&info);
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info);
if (!settings->menu.core_enable)
return -1;

View File

@ -1068,7 +1068,7 @@ static void setting_get_string_representation_uint_libretro_device(void *data,
settings_t *settings = config_get_ptr();
rarch_system_info_t *system = NULL;
runloop_get_system_info((void**)&system);
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
if (!setting)
return;
@ -2290,7 +2290,7 @@ static int setting_action_start_libretro_device_type(void *data)
settings_t *settings = config_get_ptr();
rarch_system_info_t *system = NULL;
runloop_get_system_info((void**)&system);
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
if (setting_generic_action_start_default(setting) != 0)
return -1;
@ -2440,7 +2440,7 @@ static int setting_action_left_libretro_device_type(
settings_t *settings = config_get_ptr();
rarch_system_info_t *system = NULL;
runloop_get_system_info((void**)&system);
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
if (!setting)
return -1;
@ -2505,7 +2505,7 @@ static int setting_action_right_libretro_device_type(
settings_t *settings = config_get_ptr();
rarch_system_info_t *system = NULL;
runloop_get_system_info((void**)&system);
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
if (!setting)
return -1;
@ -2888,7 +2888,7 @@ void general_write_handler(void *data)
uint32_t hash = setting ? menu_hash_calculate(setting->name) : 0;
uint64_t flags = menu_setting_get_flags(setting);
runloop_get_system_info((void**)&system);
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
if (!setting)
return;
@ -3238,7 +3238,7 @@ static bool setting_append_list_input_player_options(
(user == 0) ? retro_keybinds_1 : retro_keybinds_rest;
rarch_system_info_t *system = NULL;
runloop_get_system_info((void**)&system);
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);

View File

@ -169,7 +169,7 @@ uint32_t np_impl_magic(void)
api = api_info.version;
runloop_get_system_info((void**)&info);
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info);
if (info)
lib = info->info.library_name;

View File

@ -412,8 +412,7 @@ static void retroarch_set_paths_redirect(const char *path)
settings_t *settings = config_get_ptr();
rarch_system_info_t *info = NULL;
runloop_get_system_info((void**)&info);
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info);
if (!global)
{
RARCH_WARN("retroarch_set_paths_redirect was sent a NULL \"global\" pointer.");
@ -1067,9 +1066,9 @@ static void retroarch_parse_input(int argc, char *argv[])
static void retroarch_init_savefile_paths(void)
{
global_t *global = global_get_ptr();
rarch_system_info_t *info = NULL;
rarch_system_info_t *system = NULL;
runloop_get_system_info((void**)&info);
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
command_event(CMD_EVENT_SAVEFILES_DEINIT, NULL);
@ -1081,15 +1080,14 @@ static void retroarch_init_savefile_paths(void)
/* For subsystems, we know exactly which RAM types are supported. */
unsigned i, j;
const struct retro_subsystem_info *subsystem_info =
const struct retro_subsystem_info *info =
libretro_find_subsystem_info(
info->subsystem.data,
info->subsystem.size,
system->subsystem.data,
system->subsystem.size,
global->subsystem);
/* We'll handle this error gracefully later. */
unsigned num_content = MIN(info
? subsystem_info->num_roms : 0,
unsigned num_content = MIN(info ? info->num_roms : 0,
global->subsystem_fullpaths ?
global->subsystem_fullpaths->size : 0);
@ -1097,14 +1095,14 @@ static void retroarch_init_savefile_paths(void)
for (i = 0; i < num_content; i++)
{
for (j = 0; j < subsystem_info->roms[i].num_memory; j++)
for (j = 0; j < info->roms[i].num_memory; j++)
{
union string_list_elem_attr attr;
char path[PATH_MAX_LENGTH] = {0};
char ext[32] = {0};
const struct retro_subsystem_memory_info *mem =
(const struct retro_subsystem_memory_info*)
&subsystem_info->roms[i].memory[j];
&info->roms[i].memory[j];
snprintf(ext, sizeof(ext), ".%s", mem->extension);
@ -1174,12 +1172,12 @@ bool retroarch_validate_game_options(char *s, size_t len, bool mkdir)
const char *game_name = NULL;
global_t *global = global_get_ptr();
settings_t *settings = config_get_ptr();
rarch_system_info_t *info = NULL;
rarch_system_info_t *system = NULL;
runloop_get_system_info((void**)&info);
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
if (info)
core_name = info->info.library_name;
if (system)
core_name = system->info.library_name;
if (global)
game_name = path_basename(global->name.base);

View File

@ -740,57 +740,6 @@ bool runloop_prepare_dummy(void)
return true;
}
bool runloop_get_system_info(void **data)
{
rarch_system_info_t **system = (rarch_system_info_t**)data;
if (!system)
return false;
*system = &runloop_system;
return true;
}
void runloop_init_system_info(void)
{
core_get_system_info(&runloop_system.info);
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";
video_driver_set_title_buf();
strlcpy(runloop_system.valid_extensions,
runloop_system.info.valid_extensions ?
runloop_system.info.valid_extensions : DEFAULT_EXT,
sizeof(runloop_system.valid_extensions));
}
void runloop_free_system_info(void)
{
/* No longer valid. */
if (runloop_system.subsystem.data)
free(runloop_system.subsystem.data);
runloop_system.subsystem.data = NULL;
runloop_system.subsystem.size = 0;
if (runloop_system.ports.data)
free(runloop_system.ports.data);
runloop_system.ports.data = NULL;
runloop_system.ports.size = 0;
if (runloop_system.mmaps.descriptors)
free((void *)runloop_system.mmaps.descriptors);
runloop_system.mmaps.descriptors = NULL;
runloop_system.mmaps.num_descriptors = 0;
runloop_key_event = NULL;
runloop_frontend_key_event = NULL;
audio_driver_unset_callback();
memset(&runloop_system, 0, sizeof(rarch_system_info_t));
}
bool runloop_ctl(enum runloop_ctl_state state, void *data)
{
settings_t *settings = config_get_ptr();
@ -802,6 +751,21 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data)
break;
case RUNLOOP_CTL_SHADER_DIR_INIT:
return shader_dir_init(&runloop_shader_dir);
case RUNLOOP_CTL_SYSTEM_INFO_INIT:
core_get_system_info(&runloop_system.info);
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";
video_driver_set_title_buf();
strlcpy(runloop_system.valid_extensions,
runloop_system.info.valid_extensions ?
runloop_system.info.valid_extensions : DEFAULT_EXT,
sizeof(runloop_system.valid_extensions));
break;
case RUNLOOP_CTL_GET_CORE_OPTION_SIZE:
{
unsigned *idx = (unsigned*)data;
@ -820,6 +784,38 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data)
*coreopts = runloop_core_options;
}
break;
case RUNLOOP_CTL_SYSTEM_INFO_GET:
{
rarch_system_info_t **system = (rarch_system_info_t**)data;
if (!system)
return false;
*system = &runloop_system;
}
break;
case RUNLOOP_CTL_SYSTEM_INFO_FREE:
/* No longer valid. */
if (runloop_system.subsystem.data)
free(runloop_system.subsystem.data);
runloop_system.subsystem.data = NULL;
runloop_system.subsystem.size = 0;
if (runloop_system.ports.data)
free(runloop_system.ports.data);
runloop_system.ports.data = NULL;
runloop_system.ports.size = 0;
if (runloop_system.mmaps.descriptors)
free((void *)runloop_system.mmaps.descriptors);
runloop_system.mmaps.descriptors = NULL;
runloop_system.mmaps.num_descriptors = 0;
runloop_key_event = NULL;
runloop_frontend_key_event = NULL;
audio_driver_unset_callback();
memset(&runloop_system, 0, sizeof(rarch_system_info_t));
break;
case RUNLOOP_CTL_SET_FRAME_TIME_LAST:
runloop_frame_time_last_enable = true;
break;

View File

@ -99,7 +99,10 @@ enum runloop_ctl_state
RUNLOOP_CTL_CORE_OPTIONS_DEINIT,
RUNLOOP_CTL_CORE_OPTIONS_FREE,
RUNLOOP_CTL_SHADER_DIR_DEINIT,
RUNLOOP_CTL_SHADER_DIR_INIT
RUNLOOP_CTL_SHADER_DIR_INIT,
RUNLOOP_CTL_SYSTEM_INFO_GET,
RUNLOOP_CTL_SYSTEM_INFO_INIT,
RUNLOOP_CTL_SYSTEM_INFO_FREE
};
typedef int (*transfer_cb_t)(void *data, size_t len);
@ -293,14 +296,9 @@ char* runloop_msg_queue_pull(void);
bool runloop_prepare_dummy(void);
void runloop_init_system_info(void);
void runloop_free_system_info(void);
bool runloop_get_system_info(void **data);
bool runloop_ctl(enum runloop_ctl_state state, void *data);
#ifdef __cplusplus
}
#endif