Refactor core_system_info_* functions

This commit is contained in:
twinaphex 2016-09-06 07:08:25 +02:00
parent 18527d2fef
commit f637805c9e
21 changed files with 479 additions and 563 deletions

View File

@ -603,8 +603,7 @@ static unsigned cheevos_parse_operator(const char **memaddr)
void cheevos_parse_guest_addr(cheevos_var_t *var, unsigned value)
{
rarch_system_info_t *system;
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
rarch_system_info_t *system = core_system_info_get();
var->bank_id = -1;
var->value = value;
@ -1089,8 +1088,7 @@ uint8_t *cheevos_get_memory(const cheevos_var_t *var)
{
if (var->bank_id >= 0)
{
rarch_system_info_t *system;
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
rarch_system_info_t *system = core_system_info_get();
if (system->mmaps.num_descriptors != 0)
return (uint8_t *)system->mmaps.descriptors[var->bank_id].ptr + var->value;

View File

@ -834,10 +834,8 @@ static void command_event_disk_control_set_eject(bool new_state, bool print_log)
{
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);
rarch_system_info_t *info = core_system_info_get();
if (info)
control = (const struct retro_disk_control_callback*)&info->disk_control_cb;
@ -884,10 +882,8 @@ static void command_event_disk_control_set_index(unsigned idx)
unsigned num_disks;
bool error = false;
char msg[128] = {0};
rarch_system_info_t *info = NULL;
const struct retro_disk_control_callback *control = NULL;
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info);
rarch_system_info_t *info = core_system_info_get();
if (info)
control = (const struct retro_disk_control_callback*)&info->disk_control_cb;
@ -942,9 +938,7 @@ static bool command_event_disk_control_append_image(const char *path)
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);
rarch_system_info_t *sysinfo = core_system_info_get();
if (sysinfo)
control = (const struct retro_disk_control_callback*)
@ -1087,9 +1081,7 @@ static void command_event_init_controllers(void)
{
unsigned i;
settings_t *settings = config_get_ptr();
rarch_system_info_t *info = NULL;
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info);
rarch_system_info_t *info = core_system_info_get();
for (i = 0; i < MAX_USERS; i++)
{
@ -1814,9 +1806,7 @@ bool command_event(enum event_command cmd, void *data)
unsigned i = 0;
bool boolean = false;
settings_t *settings = config_get_ptr();
rarch_system_info_t *info = NULL;
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info);
rarch_system_info_t *info = core_system_info_get();
(void)i;

View File

@ -2132,10 +2132,8 @@ bool config_load_override(void)
const char *core_name = NULL;
const char *game_name = NULL;
bool should_append = false;
rarch_system_info_t *system = NULL;
global_t *global = global_get_ptr();
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
rarch_system_info_t *system = core_system_info_get();
if (system)
core_name = system->info.library_name;
@ -2292,9 +2290,7 @@ bool config_load_remap(void)
const char *game_name = NULL;
global_t *global = global_get_ptr();
settings_t *settings = config_get_ptr();
rarch_system_info_t *system = NULL;
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
rarch_system_info_t *system = core_system_info_get();
if (system)
core_name = system->info.library_name;
@ -2415,9 +2411,7 @@ bool config_load_shader_preset(void)
const char *game_name = NULL;
global_t *global = global_get_ptr();
settings_t *settings = config_get_ptr();
rarch_system_info_t *system = NULL;
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
rarch_system_info_t *system = core_system_info_get();
if (system)
core_name = system->info.library_name;
@ -3007,9 +3001,6 @@ bool config_save_overrides(int override_type)
const char *game_name = NULL;
config_file_t *conf = NULL;
settings_t *settings = NULL;
global_t *global = global_get_ptr();
settings_t *overrides = config_get_ptr();
rarch_system_info_t *system = NULL;
struct config_bool_setting *bool_settings = NULL;
struct config_bool_setting *bool_overrides = NULL;
struct config_int_setting *int_settings = NULL;
@ -3020,8 +3011,9 @@ bool config_save_overrides(int override_type)
struct config_array_setting *array_overrides= NULL;
struct config_path_setting *path_settings = NULL;
struct config_path_setting *path_overrides = NULL;
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
global_t *global = global_get_ptr();
settings_t *overrides = config_get_ptr();
rarch_system_info_t *system = core_system_info_get();
if (system)
core_name = system->info.library_name;

6
core.h
View File

@ -228,6 +228,12 @@ bool core_is_inited(void);
bool core_is_game_loaded(void);
rarch_system_info_t *core_system_info_get(void);
void core_system_info_init(void);
void core_system_info_free(void);
RETRO_END_DECLS
#endif

View File

@ -23,6 +23,7 @@
#include <retro_inline.h>
#include <boolean.h>
#include <compat/strl.h>
#include <lists/string_list.h>
#include <libretro.h>
@ -40,6 +41,12 @@
#include "network/netplay/netplay.h"
#endif
#ifdef HAVE_ZLIB
#define DEFAULT_EXT "zip"
#else
#define DEFAULT_EXT ""
#endif
static struct retro_core_t core;
static bool core_inited;
static bool core_symbols_inited;
@ -48,6 +55,7 @@ static unsigned core_poll_type;
static bool core_input_polled;
static bool core_has_set_input_descriptors = false;
static struct retro_callbacks retro_ctx;
static rarch_system_info_t core_system_info;
static void core_input_state_poll_maybe(void)
{
@ -448,3 +456,45 @@ bool core_is_game_loaded(void)
{
return core_game_loaded;
}
rarch_system_info_t *core_system_info_get(void)
{
return &core_system_info;
}
void core_system_info_init(void)
{
memset(&core_system_info, 0, sizeof(rarch_system_info_t));
core_get_system_info(&core_system_info.info);
if (!core_system_info.info.library_name)
core_system_info.info.library_name = msg_hash_to_str(MSG_UNKNOWN);
if (!core_system_info.info.library_version)
core_system_info.info.library_version = "v0";
strlcpy(core_system_info.valid_extensions,
core_system_info.info.valid_extensions ?
core_system_info.info.valid_extensions : DEFAULT_EXT,
sizeof(core_system_info.valid_extensions));
}
void core_system_info_free(void)
{
/* No longer valid. */
if (core_system_info.subsystem.data)
free(core_system_info.subsystem.data);
core_system_info.subsystem.data = NULL;
core_system_info.subsystem.size = 0;
if (core_system_info.ports.data)
free(core_system_info.ports.data);
core_system_info.ports.data = NULL;
core_system_info.ports.size = 0;
if (core_system_info.mmaps.descriptors)
free((void *)core_system_info.mmaps.descriptors);
core_system_info.mmaps.descriptors = NULL;
core_system_info.mmaps.num_descriptors = 0;
memset(&core_system_info, 0, sizeof(rarch_system_info_t));
}

View File

@ -932,9 +932,7 @@ 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 = NULL;
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
rarch_system_info_t *system = core_system_info_get();
if (ignore_environment_cb)
return false;

View File

@ -590,14 +590,12 @@ static bool init_video(void)
video_viewport_t *custom_vp = NULL;
const input_driver_t *tmp = NULL;
const struct retro_game_geometry *geom = NULL;
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);
rarch_system_info_t *system = core_system_info_get();
init_video_filter(video_driver_state.pix_fmt);
command_event(CMD_EVENT_SHADER_DIR_INIT, NULL);

View File

@ -102,9 +102,9 @@ HTTP ERRORS
static int httpserver_error(struct mg_connection* conn, unsigned code, const char* fmt, ...)
{
const char* reason;
char buffer[1024];
va_list args;
char buffer[1024];
const char* reason = NULL;
switch (code)
{
@ -146,9 +146,7 @@ static int httpserver_handle_basic_info(struct mg_connection* conn, void* cbdata
"L", "R", "L2", "R2", "L3", "R3",
};
const struct mg_request_info* req = mg_get_request_info(conn);
const settings_t* settings = config_get_ptr();
const rarch_system_info_t* system;
unsigned p, q, r;
char core_path[PATH_MAX_LENGTH];
retro_ctx_api_info_t api;
retro_ctx_region_info_t region;
@ -157,30 +155,26 @@ static int httpserver_handle_basic_info(struct mg_connection* conn, void* cbdata
retro_ctx_memory_info_t rtc;
retro_ctx_memory_info_t sysram;
retro_ctx_memory_info_t vram;
const struct retro_subsystem_info* subsys;
const struct retro_subsystem_rom_info* rom;
const struct retro_subsystem_memory_info* mem;
const struct retro_controller_description* ctrl;
const struct retro_system_av_info* av_info;
const core_option_manager_t* core_opts;
const struct core_option* opts;
unsigned p, q, r;
const char* comma;
const struct retro_subsystem_info* subsys = NULL;
const struct retro_subsystem_rom_info* rom = NULL;
const struct retro_subsystem_memory_info* mem = NULL;
const struct retro_controller_description* ctrl = NULL;
const struct retro_system_av_info* av_info = NULL;
const core_option_manager_t* core_opts = NULL;
const struct core_option* opts = NULL;
const char* comma = NULL;
const struct mg_request_info* req = mg_get_request_info(conn);
const settings_t* settings = config_get_ptr();
rarch_system_info_t *system = core_system_info_get();
if (!runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system))
{
if (!system)
return httpserver_error(conn, 500, "Could not get system information in %s", __FUNCTION__);
}
if (string_is_empty(system->info.library_name))
{
return httpserver_error(conn, 500, "Core not initialized in %s", __FUNCTION__);
}
if (!core_is_game_loaded())
{
return httpserver_error(conn, 500, "Game not loaded in %s", __FUNCTION__);
}
json_string_encode(core_path, sizeof(core_path), config_get_active_core_path());
@ -189,10 +183,18 @@ static int httpserver_handle_basic_info(struct mg_connection* conn, void* cbdata
switch (video_driver_get_pixel_format())
{
case RETRO_PIXEL_FORMAT_0RGB1555: pixel_format = "RETRO_PIXEL_FORMAT_0RGB1555"; break;
case RETRO_PIXEL_FORMAT_XRGB8888: pixel_format = "RETRO_PIXEL_FORMAT_XRGB8888"; break;
case RETRO_PIXEL_FORMAT_RGB565: pixel_format = "RETRO_PIXEL_FORMAT_RGB565"; break;
default: pixel_format = "?"; break;
case RETRO_PIXEL_FORMAT_0RGB1555:
pixel_format = "RETRO_PIXEL_FORMAT_0RGB1555";
break;
case RETRO_PIXEL_FORMAT_XRGB8888:
pixel_format = "RETRO_PIXEL_FORMAT_XRGB8888";
break;
case RETRO_PIXEL_FORMAT_RGB565:
pixel_format = "RETRO_PIXEL_FORMAT_RGB565";
break;
default:
pixel_format = "?";
break;
}
sram.id = RETRO_MEMORY_SAVE_RAM;
@ -392,22 +394,18 @@ MMAPS
static int httpserver_handle_get_mmaps(struct mg_connection* conn, void* cbdata)
{
const struct mg_request_info* req = mg_get_request_info(conn);
const char* comma = "";
rarch_system_info_t* system;
const struct retro_memory_map* mmaps;
const struct retro_memory_descriptor* mmap;
unsigned id;
const char* comma = "";
const struct retro_memory_map* mmaps = NULL;
const struct retro_memory_descriptor* mmap = NULL;
const struct mg_request_info* req = mg_get_request_info(conn);
rarch_system_info_t *system = core_system_info_get();
if (strcmp(req->request_method, "GET"))
{
return httpserver_error(conn, 405, "Unimplemented method in %s: %s", __FUNCTION__, req->request_method);
}
if (!runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system))
{
if (!system)
return httpserver_error(conn, 500, "Could not get system information in %s", __FUNCTION__);
}
mmaps = &system->mmaps;
mmap = mmaps->descriptors;
@ -450,41 +448,32 @@ static int httpserver_handle_get_mmaps(struct mg_connection* conn, void* cbdata)
static int httpserver_handle_get_mmap(struct mg_connection* conn, void* cbdata)
{
const struct mg_request_info* req = mg_get_request_info(conn);
const char* comma = "";
rarch_system_info_t* system;
const struct retro_memory_map* mmaps;
const struct retro_memory_descriptor* mmap;
size_t start, length;
const char* param;
unsigned id;
uLong buflen;
Bytef* buffer;
const char* comma = "";
const char* param = NULL;
Bytef* buffer = NULL;
const struct retro_memory_map* mmaps = NULL;
const struct retro_memory_descriptor* mmap = NULL;
const struct mg_request_info* req = mg_get_request_info(conn);
rarch_system_info_t *system = core_system_info_get();
if (strcmp(req->request_method, "GET"))
{
return httpserver_error(conn, 405, "Unimplemented method in %s: %s", __FUNCTION__, req->request_method);
}
if (sscanf(req->request_uri, "/" MEMORY_MAP "/%u", &id) != 1)
{
return httpserver_error(conn, 500, "Malformed request in %s: %s", __FUNCTION__, req->request_uri);
}
if (!runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system))
{
if (!system)
return httpserver_error(conn, 500, "Could not get system information in %s", __FUNCTION__);
}
mmaps = &system->mmaps;
if (id >= mmaps->num_descriptors)
{
return httpserver_error(conn, 404, "Invalid memory map id in %s: %u", __FUNCTION__, id);
}
mmap = mmaps->descriptors + id;
start = 0;
length = mmap->len;
@ -493,35 +482,25 @@ static int httpserver_handle_get_mmap(struct mg_connection* conn, void* cbdata)
param = strstr(req->query_string, "start=");
if (param != NULL)
{
start = atoll(param + 6);
}
param = strstr(req->query_string, "length=");
if (param != NULL)
{
length = atoll(param + 7);
}
}
if (start >= mmap->len)
{
start = mmap->len - 1;
}
if (length > mmap->len - start)
{
length = mmap->len - start;
}
buflen = compressBound(length);
buffer = (Bytef*)malloc(((buflen + 3) / 4) * 5);
if (buffer == NULL)
{
return httpserver_error(conn, 500, "Out of memory in %s", __FUNCTION__);
}
if (compress2(buffer, &buflen, (Bytef*)mmap->ptr + start, length, Z_BEST_COMPRESSION) != Z_OK)
{
@ -556,17 +535,13 @@ static int httpserver_handle_get_mmap(struct mg_connection* conn, void* cbdata)
static int httpserver_handle_mmaps(struct mg_connection* conn, void* cbdata)
{
const struct mg_request_info* req = mg_get_request_info(conn);
unsigned id;
const struct mg_request_info* req = mg_get_request_info(conn);
if (sscanf(req->request_uri, "/" MEMORY_MAP "/%u", &id) == 1)
{
return httpserver_handle_get_mmap(conn, cbdata);
}
else
{
return httpserver_handle_get_mmaps(conn, cbdata);
}
}
/*============================================================
@ -576,6 +551,7 @@ HTTP SERVER
int httpserver_init(unsigned port)
{
char str[16];
snprintf(str, sizeof(str), "%u", port);
str[sizeof(str) - 1] = 0;
@ -589,9 +565,7 @@ int httpserver_init(unsigned port)
s_httpserver_ctx = mg_start(&s_httpserver_callbacks, NULL, options);
if (s_httpserver_ctx == NULL)
{
return -1;
}
mg_set_request_handler(s_httpserver_ctx, "/" BASIC_INFO, httpserver_handle_basic_info, NULL);
@ -601,7 +575,7 @@ int httpserver_init(unsigned port)
return 0;
}
void httpserver_destroy()
void httpserver_destroy(void)
{
mg_stop(s_httpserver_ctx);
}

View File

@ -206,9 +206,7 @@ bool driver_location_get_position(double *lat, double *lon,
void init_location(void)
{
rarch_system_info_t *system = NULL;
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
rarch_system_info_t *system = core_system_info_get();
/* Resource leaks will follow if location interface is initialized twice. */
if (location_data)
@ -230,9 +228,7 @@ void init_location(void)
static void uninit_location(void)
{
rarch_system_info_t *system = NULL;
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
rarch_system_info_t *system = core_system_info_get();
if (location_data && location_driver)
{

View File

@ -443,10 +443,10 @@ static int general_push(menu_displaylist_info_t *info,
unsigned id, enum menu_displaylist_ctl_state state)
{
struct retro_system_info *system_menu = NULL;
settings_t *settings = config_get_ptr();
rarch_system_info_t *system = NULL;
core_info_list_t *list = NULL;
menu_handle_t *menu = NULL;
settings_t *settings = config_get_ptr();
rarch_system_info_t *system = core_system_info_get();
if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu))
return menu_cbs_exit();
@ -454,7 +454,6 @@ 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_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
switch (id)
{

View File

@ -933,10 +933,9 @@ static void menu_action_setting_disp_set_label_menu_disk_index(
char *s2, size_t len2)
{
unsigned images = 0, current = 0;
rarch_system_info_t *system = NULL;
struct retro_disk_control_callback *control = NULL;
rarch_system_info_t *system = core_system_info_get();
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
if (!system)
return;
@ -1319,10 +1318,9 @@ static void menu_action_setting_disp_set_label_core_option_create(
const char *path,
char *s2, size_t len2)
{
rarch_system_info_t *system = NULL;
global_t *global = global_get_ptr();
rarch_system_info_t *system = core_system_info_get();
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
if (!system)
return;

View File

@ -1540,11 +1540,9 @@ static int generic_action_ok_shader_preset_save(const char *path,
char directory[PATH_MAX_LENGTH] = {0};
char file[PATH_MAX_LENGTH] = {0};
char tmp[PATH_MAX_LENGTH] = {0};
settings_t *settings = config_get_ptr();
rarch_system_info_t *info = NULL;
const char *core_name = NULL;
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info);
settings_t *settings = config_get_ptr();
rarch_system_info_t *info = core_system_info_get();
if (info)
core_name = info->info.library_name;
@ -1660,11 +1658,9 @@ static int generic_action_ok_remap_file_save(const char *path,
{
char directory[PATH_MAX_LENGTH] = {0};
char file[PATH_MAX_LENGTH] = {0};
settings_t *settings = config_get_ptr();
rarch_system_info_t *info = NULL;
const char *core_name = NULL;
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info);
settings_t *settings = config_get_ptr();
rarch_system_info_t *info = core_system_info_get();
if (info)
core_name = info->info.library_name;

View File

@ -704,23 +704,15 @@ static size_t mui_list_get_size(void *data, enum menu_list_type type)
static int mui_get_core_title(char *s, size_t len)
{
struct retro_system_info *system = NULL;
rarch_system_info_t *info = NULL;
struct retro_system_info*system= NULL;
settings_t *settings = config_get_ptr();
const char *core_name = NULL;
const char *core_version = NULL;
menu_driver_ctl(RARCH_MENU_CTL_SYSTEM_INFO_GET,
&system);
core_name = system->library_name;
core_version = system->library_version;
rarch_system_info_t *info = core_system_info_get();
const char *core_name = system->library_name;
const char *core_version = system->library_version;
if (!settings->menu.core_enable)
return -1;
if (runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info))
{
if (info)
{
if (string_is_empty(core_name))
@ -728,7 +720,6 @@ static int mui_get_core_title(char *s, size_t len)
if (!core_version)
core_version = info->info.library_version;
}
}
if (string_is_empty(core_name))
core_name = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_CORE);

View File

@ -2531,9 +2531,7 @@ static int menu_displaylist_parse_load_content_settings(
if (!rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL))
{
rarch_system_info_t *system = NULL;
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
rarch_system_info_t *system = core_system_info_get();
menu_entries_append_enum(info->list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RESUME_CONTENT),
@ -2949,9 +2947,9 @@ static int menu_displaylist_parse_options_remappings(
menu_displaylist_info_t *info)
{
unsigned p, retro_id;
rarch_system_info_t *system = NULL;
menu_handle_t *menu = NULL;
settings_t *settings = config_get_ptr();
rarch_system_info_t *system = core_system_info_get();
if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu))
return -1;
@ -2988,10 +2986,9 @@ static int menu_displaylist_parse_options_remappings(
MENU_ENUM_LABEL_REMAP_FILE_SAVE_GAME,
MENU_SETTING_ACTION, 0, 0);
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
if (!system)
return 0;
if (system)
{
for (p = 0; p < settings->input.max_users; p++)
{
for (retro_id = 0; retro_id < RARCH_FIRST_CUSTOM_BIND + 4; retro_id++)
@ -3019,7 +3016,6 @@ static int menu_displaylist_parse_options_remappings(
(p * (RARCH_FIRST_CUSTOM_BIND + 4)) + retro_id, 0, 0);
}
}
}
return 0;
}
@ -4195,8 +4191,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data)
return true;
case DISPLAYLIST_MAIN_MENU:
{
rarch_system_info_t *system = NULL;
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
rarch_system_info_t *system = core_system_info_get();
if (!rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL))
menu_displaylist_parse_settings_enum(menu, info,

View File

@ -440,19 +440,18 @@ int menu_entries_get_title(char *s, size_t len)
* (shown at the top of the UI). */
int menu_entries_get_core_title(char *s, size_t len)
{
struct retro_system_info *system = NULL;
rarch_system_info_t *info = NULL;
settings_t *settings = config_get_ptr();
struct retro_system_info*system= NULL;
const char *core_name = NULL;
const char *core_version = NULL;
settings_t *settings = config_get_ptr();
rarch_system_info_t *info = core_system_info_get();
menu_driver_ctl(RARCH_MENU_CTL_SYSTEM_INFO_GET,
&system);
if (menu_driver_ctl(RARCH_MENU_CTL_SYSTEM_INFO_GET, &system)
&& system)
{
core_name = system->library_name;
core_version = system->library_version;
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info);
}
if (!settings->menu.core_enable)
return -1;

View File

@ -340,17 +340,16 @@ 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_system_info_t *system = NULL;
rarch_setting_t *setting = (rarch_setting_t*)data;
settings_t *settings = config_get_ptr();
rarch_system_info_t *system = core_system_info_get();
if (!setting)
return;
index_offset = setting_get_index_offset(setting);
if (runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system)
&& system)
if (system)
{
if (index_offset < system->ports.size)
desc = libretro_find_controller_description(
@ -958,9 +957,9 @@ static int setting_action_start_libretro_device_type(void *data)
unsigned index_offset, current_device;
unsigned devices[128], types = 0, port = 0;
const struct retro_controller_info *desc = NULL;
rarch_system_info_t *system = NULL;
settings_t *settings = config_get_ptr();
rarch_setting_t *setting = (rarch_setting_t*)data;
rarch_system_info_t *system = core_system_info_get();
if (setting_generic_action_start_default(setting) != 0)
return -1;
@ -971,8 +970,7 @@ static int setting_action_start_libretro_device_type(void *data)
devices[types++] = RETRO_DEVICE_NONE;
devices[types++] = RETRO_DEVICE_JOYPAD;
if (runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system)
&& system)
if (system)
{
/* Only push RETRO_DEVICE_ANALOG as default if we use an
* older core which doesn't use SET_CONTROLLER_INFO. */
@ -1064,7 +1062,7 @@ static int setting_action_left_libretro_device_type(
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 = NULL;
rarch_system_info_t *system = core_system_info_get();
if (!setting)
return -1;
@ -1074,8 +1072,6 @@ static int setting_action_left_libretro_device_type(
devices[types++] = RETRO_DEVICE_NONE;
devices[types++] = RETRO_DEVICE_JOYPAD;
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
if (system)
{
/* Only push RETRO_DEVICE_ANALOG as default if we use an
@ -1132,7 +1128,7 @@ static int setting_action_right_libretro_device_type(
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 = NULL;
rarch_system_info_t *system = core_system_info_get();
if (!setting)
return -1;
@ -1142,8 +1138,7 @@ static int setting_action_right_libretro_device_type(
devices[types++] = RETRO_DEVICE_NONE;
devices[types++] = RETRO_DEVICE_JOYPAD;
if (runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system)
&& system)
if (system)
{
/* Only push RETRO_DEVICE_ANALOG as default if we use an
* older core which doesn't use SET_CONTROLLER_INFO. */
@ -1666,8 +1661,8 @@ void general_write_handler(void *data)
break;
case MENU_ENUM_LABEL_VIDEO_ROTATION:
{
rarch_system_info_t *system = NULL;
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
rarch_system_info_t *system = core_system_info_get();
if (system)
video_driver_set_rotation(
(*setting->value.target.unsigned_integer +
@ -1920,14 +1915,11 @@ static bool setting_append_list_input_player_options(
rarch_setting_group_info_t group_info = {0};
rarch_setting_group_info_t subgroup_info = {0};
settings_t *settings = config_get_ptr();
const char *temp_value = NULL;
const struct retro_keybind* const defaults =
(user == 0) ? retro_keybinds_1 : retro_keybinds_rest;
rarch_system_info_t *system = NULL;
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
temp_value =msg_hash_to_str((enum msg_hash_enums)(MENU_ENUM_LABEL_INPUT_USER_1_BINDS + user));
rarch_system_info_t *system = core_system_info_get();
const char *temp_value = msg_hash_to_str((enum msg_hash_enums)
(MENU_ENUM_LABEL_INPUT_USER_1_BINDS + user));
snprintf(buffer[user], sizeof(buffer[user]),
"%s %u", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_USER), user + 1);

View File

@ -170,16 +170,14 @@ uint32_t netplay_impl_magic(void)
retro_ctx_api_info_t api_info;
unsigned api;
uint32_t res = 0;
rarch_system_info_t *info = NULL;
const char *lib = NULL;
const char *ver = PACKAGE_VERSION;
rarch_system_info_t *info = core_system_info_get();
core_api_version(&api_info);
api = api_info.version;
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info);
if (info)
lib = info->info.library_name;

View File

@ -413,9 +413,7 @@ static void retroarch_set_paths_redirect(void)
bool check_global_library_name_hash = 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);
rarch_system_info_t *info = core_system_info_get();
if (!global)
return;
@ -1088,9 +1086,7 @@ 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 *system = NULL;
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
rarch_system_info_t *system = core_system_info_get();
command_event(CMD_EVENT_SAVEFILES_DEINIT, NULL);
@ -1199,10 +1195,8 @@ bool retroarch_validate_game_options(char *s, size_t len, bool mkdir)
char config_directory[PATH_MAX_LENGTH] = {0};
const char *core_name = NULL;
const char *game_name = NULL;
rarch_system_info_t *system = NULL;
global_t *global = global_get_ptr();
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
rarch_system_info_t *system = core_system_info_get();
if (system)
core_name = system->info.library_name;

View File

@ -75,12 +75,6 @@
#include "verbosity.h"
#ifdef HAVE_ZLIB
#define DEFAULT_EXT "zip"
#else
#define DEFAULT_EXT ""
#endif
#define runloop_cmd_triggered(cmd, id) BIT64_GET(cmd->state[2].state, id)
#define runloop_cmd_press(cmd, id) BIT64_GET(cmd->state[0].state, id)
@ -106,7 +100,6 @@ typedef struct event_cmd_state
static struct rarch_dir_list runloop_shader_dir;
static char runloop_fullpath[PATH_MAX_LENGTH];
static char runloop_default_shader_preset[PATH_MAX_LENGTH];
static rarch_system_info_t runloop_system;
static unsigned runloop_pending_windowed_scale;
static struct retro_frame_time_callback runloop_frame_time;
static retro_keyboard_event_t runloop_key_event = NULL;
@ -756,6 +749,7 @@ static bool runloop_is_frame_count_end(void)
return runloop_max_frames && (*frame_count >= runloop_max_frames);
}
bool runloop_ctl(enum runloop_ctl_state state, void *data)
{
@ -767,19 +761,8 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data)
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";
core_system_info_init();
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:
{
@ -799,37 +782,12 @@ 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;
core_system_info_free();
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;

View File

@ -127,7 +127,6 @@ enum runloop_ctl_state
RUNLOOP_CTL_SHADER_DIR_INIT,
/* System info */
RUNLOOP_CTL_SYSTEM_INFO_GET,
RUNLOOP_CTL_SYSTEM_INFO_INIT,
RUNLOOP_CTL_SYSTEM_INFO_FREE,

View File

@ -1134,10 +1134,8 @@ static bool load_content_from_compressed_archive(
char new_basedir[PATH_MAX_LENGTH] = {0};
ssize_t new_path_len = 0;
bool ret = false;
rarch_system_info_t *sys_info= NULL;
settings_t *settings = config_get_ptr();
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &sys_info);
rarch_system_info_t *sys_info = core_system_info_get();
if (sys_info && sys_info->info.block_extract)
return true;
@ -1457,10 +1455,8 @@ static bool content_file_init(struct string_list *temporary_content)
struct string_list* additional_path_allocs = NULL;
struct string_list *content = NULL;
const struct retro_subsystem_info *special = NULL;
rarch_system_info_t *system = NULL;
global_t *global = global_get_ptr();
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
rarch_system_info_t *system = core_system_info_get();
if (!string_is_empty(global->subsystem))
{
@ -1668,9 +1664,8 @@ static bool task_load_content(content_ctx_info_t *content_info,
{
char tmp[PATH_MAX_LENGTH] = {0};
struct retro_system_info *info = NULL;
rarch_system_info_t *system = NULL;
rarch_system_info_t *system = core_system_info_get();
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
if (system)
info = &system->info;