diff --git a/cheevos/cheevos.c b/cheevos/cheevos.c index d8f9817b90..b594598ab6 100644 --- a/cheevos/cheevos.c +++ b/cheevos/cheevos.c @@ -188,8 +188,8 @@ static int rcheevos_init_memory(rcheevos_locals_t* locals) unsigned i; int result; struct retro_memory_map mmap; - rarch_system_info_t* system = &runloop_state_get_ptr()->system; - rarch_memory_map_t* mmaps = &system->mmaps; + rarch_system_info_t *sys_info = &runloop_state_get_ptr()->system; + rarch_memory_map_t *mmaps = &sys_info->mmaps; struct retro_memory_descriptor *descriptors = (struct retro_memory_descriptor*)malloc(mmaps->num_descriptors * sizeof(*descriptors)); if (!descriptors) return 0; @@ -2045,11 +2045,10 @@ static void rcheevos_identify_game_callback(void* userdata) static int rcheevos_get_image_path(unsigned index, char* buffer, size_t buffer_size) { - rarch_system_info_t* system = &runloop_state_get_ptr()->system; - if (!system->disk_control.cb.get_image_path) + rarch_system_info_t *sys_info = &runloop_state_get_ptr()->system; + if (!sys_info->disk_control.cb.get_image_path) return 0; - - return system->disk_control.cb.get_image_path(index, buffer, buffer_size); + return sys_info->disk_control.cb.get_image_path(index, buffer, buffer_size); } static bool rcheevos_identify_game(const struct retro_game_info* info) diff --git a/location_driver.c b/location_driver.c index e4c38948ab..92c5c1f94e 100644 --- a/location_driver.c +++ b/location_driver.c @@ -154,40 +154,38 @@ bool init_location( bool verbosity_enabled) { location_driver_state_t - *location_st = &location_driver_st; - rarch_system_info_t *system = (rarch_system_info_t*)data; + *location_st = &location_driver_st; + /* Resource leaks will follow if location interface is initialized twice. */ - if (location_st->data) - return true; - - location_driver_find_driver(settings, - "location driver", verbosity_enabled); - - location_st->data = location_st->driver->init(); - if (!location_st->data) { - RARCH_ERR("Failed to initialize location driver. Will continue without location.\n"); - return false; - } + rarch_system_info_t *sys_info = (rarch_system_info_t*)data; + location_driver_find_driver(settings, + "location driver", verbosity_enabled); - if (system->location_cb.initialized) - system->location_cb.initialized(); + if (!(location_st->data = location_st->driver->init())) + { + RARCH_ERR("Failed to initialize location driver. Will continue without location.\n"); + return false; + } + + if (sys_info->location_cb.initialized) + sys_info->location_cb.initialized(); + } return true; } void uninit_location(void *data) { - location_driver_state_t - *location_st = &location_driver_st; - rarch_system_info_t *system = (rarch_system_info_t*)data; + location_driver_state_t *location_st = &location_driver_st; if (location_st->data && location_st->driver) { - if (system->location_cb.deinitialized) - system->location_cb.deinitialized(); + rarch_system_info_t *sys_info = (rarch_system_info_t*)data; + if (sys_info->location_cb.deinitialized) + sys_info->location_cb.deinitialized(); if (location_st->driver->free) location_st->driver->free(location_st->data); diff --git a/menu/cbs/menu_cbs_start.c b/menu/cbs/menu_cbs_start.c index b0fcec5f31..828ea697d0 100644 --- a/menu/cbs/menu_cbs_start.c +++ b/menu/cbs/menu_cbs_start.c @@ -71,13 +71,9 @@ static int action_start_audio_mixer_stream_volume( const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { - unsigned offset = (type - MENU_SETTINGS_AUDIO_MIXER_STREAM_ACTIONS_VOLUME_BEGIN); - - if (offset >= AUDIO_MIXER_MAX_STREAMS) - return 0; - - audio_driver_mixer_set_stream_volume(offset, 1.0f); - + unsigned offset = (type - MENU_SETTINGS_AUDIO_MIXER_STREAM_ACTIONS_VOLUME_BEGIN); + if (offset < AUDIO_MIXER_MAX_STREAMS) + audio_driver_mixer_set_stream_volume(offset, 1.0f); return 0; } #endif @@ -90,11 +86,11 @@ static int action_start_remap_file_info( settings_t *settings = config_get_ptr(); const char *directory_input_remapping = settings ? settings->paths.directory_input_remapping : NULL; - rarch_system_info_t *system = &runloop_state_get_ptr()->system; + rarch_system_info_t *sys_info = &runloop_state_get_ptr()->system; input_remapping_deinit(false); input_remapping_set_defaults(false); - config_load_remap(directory_input_remapping, system); + config_load_remap(directory_input_remapping, sys_info); /* Refresh menu */ menu_st->flags |= MENU_ST_FLAG_ENTRIES_NEED_REFRESH @@ -108,8 +104,8 @@ static int action_start_override_file_info( unsigned type, size_t idx, size_t entry_idx) { struct menu_state *menu_st = menu_state_get_ptr(); - rarch_system_info_t *system = &runloop_state_get_ptr()->system; - config_load_override(system); + rarch_system_info_t *sys_info = &runloop_state_get_ptr()->system; + config_load_override(sys_info); /* Refresh menu */ menu_st->flags |= MENU_ST_FLAG_ENTRIES_NEED_REFRESH | MENU_ST_FLAG_PREVENT_POPULATE; @@ -244,32 +240,29 @@ static int action_start_input_desc( const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { - unsigned user_idx; - unsigned btn_idx; - unsigned mapped_port; - settings_t *settings = config_get_ptr(); - rarch_system_info_t *system = &runloop_state_get_ptr()->system; + settings_t *settings = config_get_ptr(); + rarch_system_info_t *sys_info = &runloop_state_get_ptr()->system; - if (!settings || !system) - return 0; - - user_idx = (type - MENU_SETTINGS_INPUT_DESC_BEGIN) / (RARCH_FIRST_CUSTOM_BIND + 8); - btn_idx = (type - MENU_SETTINGS_INPUT_DESC_BEGIN) - (RARCH_FIRST_CUSTOM_BIND + 8) * user_idx; - mapped_port = settings->uints.input_remap_ports[user_idx]; - - if ((user_idx >= MAX_USERS) || - (mapped_port >= MAX_USERS) || - (btn_idx >= RARCH_CUSTOM_BIND_LIST_END)) - return 0; - - /* Check whether core has defined this input */ - if (!string_is_empty(system->input_desc_btn[mapped_port][btn_idx])) + if (settings && sys_info) { - const struct retro_keybind *keyptr = &input_config_binds[user_idx][btn_idx]; - settings->uints.input_remap_ids[user_idx][btn_idx] = keyptr->id; + unsigned user_idx = (type - MENU_SETTINGS_INPUT_DESC_BEGIN) / (RARCH_FIRST_CUSTOM_BIND + 8); + unsigned btn_idx = (type - MENU_SETTINGS_INPUT_DESC_BEGIN) - (RARCH_FIRST_CUSTOM_BIND + 8) * user_idx; + unsigned mapped_port = settings->uints.input_remap_ports[user_idx]; + + if ( (user_idx >= MAX_USERS) + || (mapped_port >= MAX_USERS) + || (btn_idx >= RARCH_CUSTOM_BIND_LIST_END)) + return 0; + + /* Check whether core has defined this input */ + if (!string_is_empty(sys_info->input_desc_btn[mapped_port][btn_idx])) + { + const struct retro_keybind *keyptr = &input_config_binds[user_idx][btn_idx]; + settings->uints.input_remap_ids[user_idx][btn_idx] = keyptr->id; + } + else + settings->uints.input_remap_ids[user_idx][btn_idx] = RARCH_UNMAPPED; } - else - settings->uints.input_remap_ids[user_idx][btn_idx] = RARCH_UNMAPPED; return 0; } @@ -279,22 +272,18 @@ static int action_start_input_desc_kbd( unsigned type, size_t idx, size_t entry_idx) { settings_t *settings = config_get_ptr(); - unsigned user_idx; - unsigned btn_idx; - (void)label; + if (settings) + { + unsigned user_idx = (type - MENU_SETTINGS_INPUT_DESC_KBD_BEGIN) / RARCH_ANALOG_BIND_LIST_END; + unsigned btn_idx = (type - MENU_SETTINGS_INPUT_DESC_KBD_BEGIN) - RARCH_ANALOG_BIND_LIST_END * user_idx; - if (!settings) - return 0; + if ((user_idx >= MAX_USERS) || (btn_idx >= RARCH_CUSTOM_BIND_LIST_END)) + return 0; - user_idx = (type - MENU_SETTINGS_INPUT_DESC_KBD_BEGIN) / RARCH_ANALOG_BIND_LIST_END; - btn_idx = (type - MENU_SETTINGS_INPUT_DESC_KBD_BEGIN) - RARCH_ANALOG_BIND_LIST_END * user_idx; - - if ((user_idx >= MAX_USERS) || (btn_idx >= RARCH_CUSTOM_BIND_LIST_END)) - return 0; - - /* By default, inputs are unmapped */ - settings->uints.input_keymapper_ids[user_idx][btn_idx] = RETROK_FIRST; + /* By default, inputs are unmapped */ + settings->uints.input_keymapper_ids[user_idx][btn_idx] = RETROK_FIRST; + } return 0; } @@ -674,10 +663,10 @@ static int action_start_core_updater_entry( /* If specified core is installed, go to core * information menu */ - if (core_list && - core_updater_list_get_filename(core_list, path, &entry) && - !string_is_empty(entry->local_core_path) && - path_is_valid(entry->local_core_path)) + if ( core_list + && core_updater_list_get_filename(core_list, path, &entry) + && !string_is_empty(entry->local_core_path) + && path_is_valid(entry->local_core_path)) return action_ok_push_core_information_list( entry->local_core_path, label, type, idx, entry_idx); @@ -752,54 +741,53 @@ static int action_start_core_set_standalone_exempt( unsigned type, size_t idx, size_t entry_idx) { const char *core_path = path; - int ret = 0; if (string_is_empty(core_path)) return -1; /* Core should not be exempt by default * > If it is currently 'not exempt', do nothing */ - if (!core_info_get_core_standalone_exempt(core_path)) - return ret; - - /* ...Otherwise, attempt to unset the exempt flag */ - if (!core_info_set_core_standalone_exempt(core_path, false)) + if (core_info_get_core_standalone_exempt(core_path)) { - size_t _len; - const char *core_name = NULL; - core_info_t *core_info = NULL; - char msg[128]; + /* ...Otherwise, attempt to unset the exempt flag */ + if (!core_info_set_core_standalone_exempt(core_path, false)) + { + size_t _len; + const char *core_name = NULL; + core_info_t *core_info = NULL; + char msg[128]; - /* Need to fetch core name for error message */ + /* Need to fetch core name for error message */ - /* If core is found, use display name */ - if (core_info_find(core_path, &core_info) && - core_info->display_name) - core_name = core_info->display_name; - /* If not, use core file name */ - else - core_name = path_basename_nocompression(core_path); + /* If core is found, use display name */ + if (core_info_find(core_path, &core_info) && + core_info->display_name) + core_name = core_info->display_name; + /* If not, use core file name */ + else + core_name = path_basename_nocompression(core_path); - /* Build error message */ - _len = strlcpy(msg, - msg_hash_to_str(MSG_CORE_UNSET_STANDALONE_EXEMPT_FAILED), - sizeof(msg)); + /* Build error message */ + _len = strlcpy(msg, + msg_hash_to_str(MSG_CORE_UNSET_STANDALONE_EXEMPT_FAILED), + sizeof(msg)); - if (!string_is_empty(core_name)) - strlcpy(msg + _len, core_name, sizeof(msg) - _len); + if (!string_is_empty(core_name)) + strlcpy(msg + _len, core_name, sizeof(msg) - _len); - /* Generate log + notification */ - RARCH_ERR("%s\n", msg); + /* Generate log + notification */ + RARCH_ERR("%s\n", msg); - runloop_msg_queue_push( - msg, - 1, 100, true, - NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); + runloop_msg_queue_push( + msg, + 1, 100, true, + NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); - ret = -1; + return -1; + } } - return ret; + return 0; } static int action_start_lookup_setting( @@ -927,7 +915,7 @@ static int menu_cbs_init_bind_start_compare_type(menu_file_list_cbs_t *cbs, unsigned type) { #if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL) - if (type >= MENU_SETTINGS_SHADER_PARAMETER_0 + if ( type >= MENU_SETTINGS_SHADER_PARAMETER_0 && type <= MENU_SETTINGS_SHADER_PARAMETER_LAST) { BIND_ACTION_START(cbs, action_start_shader_action_parameter); @@ -939,8 +927,8 @@ static int menu_cbs_init_bind_start_compare_type(menu_file_list_cbs_t *cbs, } else #endif - if (type >= MENU_SETTINGS_LIBRETRO_PERF_COUNTERS_BEGIN && - type <= MENU_SETTINGS_LIBRETRO_PERF_COUNTERS_END) + if ( type >= MENU_SETTINGS_LIBRETRO_PERF_COUNTERS_BEGIN + && type <= MENU_SETTINGS_LIBRETRO_PERF_COUNTERS_END) { BIND_ACTION_START(cbs, action_start_performance_counters_core); } @@ -954,13 +942,13 @@ static int menu_cbs_init_bind_start_compare_type(menu_file_list_cbs_t *cbs, { BIND_ACTION_START(cbs, action_start_input_desc_kbd); } - else if (type >= MENU_SETTINGS_PERF_COUNTERS_BEGIN && - type <= MENU_SETTINGS_PERF_COUNTERS_END) + else if (type >= MENU_SETTINGS_PERF_COUNTERS_BEGIN + && type <= MENU_SETTINGS_PERF_COUNTERS_END) { BIND_ACTION_START(cbs, action_start_performance_counters_frontend); } - else if ((type >= MENU_SETTINGS_CORE_OPTION_START) && - (type < MENU_SETTINGS_CHEEVOS_START)) + else if ( (type >= MENU_SETTINGS_CORE_OPTION_START) + && (type < MENU_SETTINGS_CHEEVOS_START)) { BIND_ACTION_START(cbs, action_start_core_setting); } diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index 53d6b74782..98a15677ae 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -1401,11 +1401,11 @@ static int action_bind_sublabel_subsystem_add( { const struct retro_subsystem_info *subsystem = NULL; runloop_state_t *runloop_st = runloop_state_get_ptr(); - rarch_system_info_t *system = &runloop_st->system; + rarch_system_info_t *sys_info = &runloop_st->system; /* Core fully loaded, use the subsystem data */ - if (system->subsystem.data) - subsystem = system->subsystem.data + (type - MENU_SETTINGS_SUBSYSTEM_ADD); + if (sys_info->subsystem.data) + subsystem = sys_info->subsystem.data + (type - MENU_SETTINGS_SUBSYSTEM_ADD); /* Core not loaded completely, use the data we peeked on load core */ else subsystem = runloop_st->subsystem_data + (type - MENU_SETTINGS_SUBSYSTEM_ADD); @@ -1542,29 +1542,27 @@ static int action_bind_sublabel_remap_sublabel( const char *label, const char *path, char *s, size_t len) { - size_t _len; settings_t *settings = config_get_ptr(); unsigned port = (type - MENU_SETTINGS_INPUT_DESC_BEGIN) / (RARCH_FIRST_CUSTOM_BIND + 8); - if (!settings || (port >= MAX_USERS)) - return 0; - - /* Device name is set per-port - * If the user changes the device index for - * a port, then we are effectively changing - * the port to which the corresponding - * controller is connected... */ - port = settings->uints.input_joypad_index[port]; - _len = strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PORT), len); - - snprintf(s + _len, len - _len, " %u: %s", - port + 1, - input_config_get_device_display_name(port) - ? input_config_get_device_display_name(port) - : (input_config_get_device_name(port) - ? input_config_get_device_name(port) - : msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE))); + if (settings && (port < MAX_USERS)) + { + /* Device name is set per-port + * If the user changes the device index for + * a port, then we are effectively changing + * the port to which the corresponding + * controller is connected... */ + size_t _len = strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PORT), len); + port = settings->uints.input_joypad_index[port]; + snprintf(s + _len, len - _len, " %u: %s", + port + 1, + input_config_get_device_display_name(port) + ? input_config_get_device_display_name(port) + : (input_config_get_device_name(port) + ? input_config_get_device_name(port) + : msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE))); + } return 0; } @@ -1587,11 +1585,11 @@ static int action_bind_sublabel_input_remap_port( * This is difficult to obtain here - the only * way to get it is to parse the entry label * (input_remap_port_p) */ - if (string_is_empty(entry.label) || - (sscanf(entry.label, + if ( string_is_empty(entry.label) + || (sscanf(entry.label, msg_hash_to_str(MENU_ENUM_LABEL_INPUT_REMAP_PORT), - &display_port) != 1) || - (display_port >= MAX_USERS + 1)) + &display_port) != 1) + || (display_port >= MAX_USERS + 1)) return 0; snprintf(s, len, @@ -1871,7 +1869,7 @@ static int action_bind_sublabel_playlist_entry( * *and* this is a valid playlist type */ if ( ((playlist_sublabel_runtime_type == PLAYLIST_RUNTIME_PER_CORE) && !content_runtime_log) - || ((playlist_sublabel_runtime_type == PLAYLIST_RUNTIME_AGGREGATE) + || ((playlist_sublabel_runtime_type == PLAYLIST_RUNTIME_AGGREGATE) && !content_runtime_log_aggregate)) return 0; @@ -1980,15 +1978,15 @@ static int action_bind_sublabel_core_updater_entry( const char *label, const char *path, char *s, size_t len) { - size_t _len; core_updater_list_t *core_list = core_updater_list_get_cached(); const core_updater_list_entry_t *entry = NULL; /* Search for specified core */ - if (core_list && - core_updater_list_get_filename(core_list, path, &entry) && - entry->licenses_list) + if ( core_list + && core_updater_list_get_filename(core_list, path, &entry) + && entry->licenses_list) { + size_t _len; char tmp[MENU_SUBLABEL_MAX_LENGTH]; tmp[0] = '\0'; /* Add license text */ @@ -2004,11 +2002,11 @@ static int action_bind_sublabel_core_updater_entry( else { /* No license found - set to N/A */ - _len = strlcpy(s, + size_t _len = strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_LICENSES), len); - s[ _len] = ':'; - s[++_len] = ' '; - s[++_len] = '\0'; + s[ _len] = ':'; + s[++_len] = ' '; + s[++_len] = '\0'; strlcpy(s + _len, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE), len - _len); } return 1; @@ -2028,7 +2026,7 @@ static int action_bind_sublabel_core_backup_entry( /* Set sublabel prefix */ size_t _len = strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_BACKUP_CRC), len); - /* Add crc string */ + /* Add CRC string */ if (string_is_empty(crc)) { s[ _len] = '0'; diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 20f352b879..9911f52389 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -7916,7 +7916,6 @@ static int xmb_list_push(void *data, void *userdata, break; case DISPLAYLIST_MAIN_MENU: { - rarch_system_info_t *system = &runloop_state_get_ptr()->system; uint32_t flags = runloop_get_flags(); menu_entries_clear(info->list); @@ -7934,7 +7933,8 @@ static int xmb_list_push(void *data, void *userdata, } else { - if (system && system->load_no_content) + rarch_system_info_t *sys_info = &runloop_state_get_ptr()->system; + if (sys_info && sys_info->load_no_content) { MENU_DISPLAYLIST_PARSE_SETTINGS_ENUM( info->list, diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index c34741ec26..3fb67c085d 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -6467,14 +6467,14 @@ unsigned menu_displaylist_build_list( { case DISPLAYLIST_OPTIONS_OVERRIDES: { - runloop_state_t *runloop_st = runloop_state_get_ptr(); - rarch_system_info_t *system = &runloop_st->system; - - const char *rarch_path_basename = path_get(RARCH_PATH_BASENAME); - const char *core_name = system ? system->info.library_name : NULL; char config_directory[PATH_MAX_LENGTH]; char content_dir_name[PATH_MAX_LENGTH]; char override_path[PATH_MAX_LENGTH]; + runloop_state_t *runloop_st = runloop_state_get_ptr(); + rarch_system_info_t *sys_info = &runloop_st->system; + + const char *rarch_path_basename = path_get(RARCH_PATH_BASENAME); + const char *core_name = sys_info ? sys_info->info.library_name : NULL; bool has_content = !string_is_empty(path_get(RARCH_PATH_CONTENT)); bool core_override_remove = false; bool content_dir_override_remove = false; diff --git a/runahead.c b/runahead.c index 527d50d6fe..1595b9a6cd 100644 --- a/runahead.c +++ b/runahead.c @@ -421,10 +421,10 @@ static bool secondary_core_create(runloop_state_t *runloop_st, settings_t *settings) { const enum rarch_core_type - last_core_type = runloop_st->last_core_type; - rarch_system_info_t *info = &runloop_st->system; - unsigned num_active_users = settings->uints.input_max_users; - uint8_t flags = content_get_flags(); + last_core_type = runloop_st->last_core_type; + rarch_system_info_t *sys_info = &runloop_st->system; + unsigned num_active_users = settings->uints.input_max_users; + uint8_t flags = content_get_flags(); if ( (last_core_type != CORE_TYPE_PLAIN) || (!runloop_st->load_content_info) @@ -504,12 +504,12 @@ static bool secondary_core_create(runloop_state_t *runloop_st, runloop_st->secondary_core.retro_set_input_poll( runloop_st->secondary_callbacks.poll_cb); - if (info) + if (sys_info) { - int port; + ssize_t port; for (port = 0; port < MAX_USERS; port++) { - if (port < (int)info->ports.size) + if (port < sys_info->ports.size) { unsigned device = (port < (int)num_active_users) ? runloop_st->port_map[port] : RETRO_DEVICE_NONE; diff --git a/runloop.c b/runloop.c index 1c4f34ddf7..8bdbd57d10 100644 --- a/runloop.c +++ b/runloop.c @@ -1418,7 +1418,7 @@ bool runloop_environment_cb(unsigned cmd, void *data) runloop_state_t *runloop_st = &runloop_state; recording_state_t *recording_st = recording_state_get_ptr(); settings_t *settings = config_get_ptr(); - rarch_system_info_t *system = &runloop_st->system; + rarch_system_info_t *sys_info = &runloop_st->system; bool ignore_environment_cb = runloop_st->flags & RUNLOOP_FLAG_IGNORE_ENVIRONMENT_CB; @@ -1914,14 +1914,14 @@ bool runloop_environment_cb(unsigned cmd, void *data) bool video_allow_rotate = settings->bools.video_allow_rotate; RARCH_LOG("[Environ]: SET_ROTATION: %u\n", rotation); - if (system) - system->core_requested_rotation = rotation; + if (sys_info) + sys_info->core_requested_rotation = rotation; if (!video_allow_rotate) return false; - if (system) - system->rotation = rotation; + if (sys_info) + sys_info->rotation = rotation; if (!video_driver_set_rotation(rotation)) return false; @@ -1961,11 +1961,11 @@ bool runloop_environment_cb(unsigned cmd, void *data) } case RETRO_ENVIRONMENT_SET_PERFORMANCE_LEVEL: - if (system) + if (sys_info) { - system->performance_level = *(const unsigned*)data; + sys_info->performance_level = *(const unsigned*)data; RARCH_LOG("[Environ]: PERFORMANCE_LEVEL: %u.\n", - system->performance_level); + sys_info->performance_level); } break; @@ -2062,12 +2062,12 @@ bool runloop_environment_cb(unsigned cmd, void *data) "L", "R", "L2", "R2", "L3", "R3", }; - if (system) + if (sys_info) { unsigned retro_id; const struct retro_input_descriptor *desc = NULL; - memset((void*)&system->input_desc_btn, 0, - sizeof(system->input_desc_btn)); + memset((void*)&sys_info->input_desc_btn, 0, + sizeof(sys_info->input_desc_btn)); desc = (const struct retro_input_descriptor*)data; @@ -2086,7 +2086,7 @@ bool runloop_environment_cb(unsigned cmd, void *data) switch (desc->device) { case RETRO_DEVICE_JOYPAD: - system->input_desc_btn[retro_port] + sys_info->input_desc_btn[retro_port] [retro_id] = desc->description; break; case RETRO_DEVICE_ANALOG: @@ -2096,15 +2096,15 @@ bool runloop_environment_cb(unsigned cmd, void *data) switch (desc->index) { case RETRO_DEVICE_INDEX_ANALOG_LEFT: - system->input_desc_btn[retro_port] + sys_info->input_desc_btn[retro_port] [RARCH_ANALOG_LEFT_X_PLUS] = desc->description; - system->input_desc_btn[retro_port] + sys_info->input_desc_btn[retro_port] [RARCH_ANALOG_LEFT_X_MINUS] = desc->description; break; case RETRO_DEVICE_INDEX_ANALOG_RIGHT: - system->input_desc_btn[retro_port] + sys_info->input_desc_btn[retro_port] [RARCH_ANALOG_RIGHT_X_PLUS] = desc->description; - system->input_desc_btn[retro_port] + sys_info->input_desc_btn[retro_port] [RARCH_ANALOG_RIGHT_X_MINUS] = desc->description; break; } @@ -2113,15 +2113,15 @@ bool runloop_environment_cb(unsigned cmd, void *data) switch (desc->index) { case RETRO_DEVICE_INDEX_ANALOG_LEFT: - system->input_desc_btn[retro_port] + sys_info->input_desc_btn[retro_port] [RARCH_ANALOG_LEFT_Y_PLUS] = desc->description; - system->input_desc_btn[retro_port] + sys_info->input_desc_btn[retro_port] [RARCH_ANALOG_LEFT_Y_MINUS] = desc->description; break; case RETRO_DEVICE_INDEX_ANALOG_RIGHT: - system->input_desc_btn[retro_port] + sys_info->input_desc_btn[retro_port] [RARCH_ANALOG_RIGHT_Y_PLUS] = desc->description; - system->input_desc_btn[retro_port] + sys_info->input_desc_btn[retro_port] [RARCH_ANALOG_RIGHT_Y_MINUS] = desc->description; break; } @@ -2130,7 +2130,7 @@ bool runloop_environment_cb(unsigned cmd, void *data) switch (desc->index) { case RETRO_DEVICE_INDEX_ANALOG_BUTTON: - system->input_desc_btn[retro_port] + sys_info->input_desc_btn[retro_port] [retro_id] = desc->description; break; } @@ -2139,7 +2139,7 @@ bool runloop_environment_cb(unsigned cmd, void *data) switch (desc->index) { case RETRO_DEVICE_INDEX_ANALOG_BUTTON: - system->input_desc_btn[retro_port] + sys_info->input_desc_btn[retro_port] [retro_id] = desc->description; break; } @@ -2164,7 +2164,7 @@ bool runloop_environment_cb(unsigned cmd, void *data) for (retro_id = 0; retro_id < RARCH_FIRST_CUSTOM_BIND; retro_id++) { - const char *description = system->input_desc_btn[mapped_port][retro_id]; + const char *description = sys_info->input_desc_btn[mapped_port][retro_id]; if (!description) continue; @@ -2217,10 +2217,10 @@ bool runloop_environment_cb(unsigned cmd, void *data) const struct retro_disk_control_callback *control_cb = (const struct retro_disk_control_callback*)data; - if (system) + if (sys_info) { RARCH_LOG("[Environ]: SET_DISK_CONTROL_INTERFACE.\n"); - disk_control_set_callback(&system->disk_control, control_cb); + disk_control_set_callback(&sys_info->disk_control, control_cb); } } break; @@ -2230,10 +2230,10 @@ bool runloop_environment_cb(unsigned cmd, void *data) const struct retro_disk_control_ext_callback *control_cb = (const struct retro_disk_control_ext_callback*)data; - if (system) + if (sys_info) { RARCH_LOG("[Environ]: SET_DISK_CONTROL_EXT_INTERFACE.\n"); - disk_control_set_ext_callback(&system->disk_control, control_cb); + disk_control_set_ext_callback(&sys_info->disk_control, control_cb); } } break; @@ -2578,8 +2578,8 @@ bool runloop_environment_cb(unsigned cmd, void *data) cb->get_position = driver_location_get_position; cb->set_interval = driver_location_set_interval; - if (system) - system->location_cb = *cb; + if (sys_info) + sys_info->location_cb = *cb; location_st->active = false; break; @@ -2753,12 +2753,12 @@ bool runloop_environment_cb(unsigned cmd, void *data) } } - if (system) + if (sys_info) { struct retro_subsystem_info *info_ptr = NULL; - free(system->subsystem.data); - system->subsystem.data = NULL; - system->subsystem.size = 0; + free(sys_info->subsystem.data); + sys_info->subsystem.data = NULL; + sys_info->subsystem.size = 0; info_ptr = (struct retro_subsystem_info*) malloc(i * sizeof(*info_ptr)); @@ -2766,11 +2766,11 @@ bool runloop_environment_cb(unsigned cmd, void *data) if (!info_ptr) return false; - system->subsystem.data = info_ptr; + sys_info->subsystem.data = info_ptr; - memcpy(system->subsystem.data, info, - i * sizeof(*system->subsystem.data)); - system->subsystem.size = i; + memcpy(sys_info->subsystem.data, info, + i * sizeof(*sys_info->subsystem.data)); + sys_info->subsystem.size = i; runloop_st->current_core.flags |= RETRO_CORE_FLAG_HAS_SET_SUBSYSTEMS; } @@ -2798,29 +2798,29 @@ bool runloop_environment_cb(unsigned cmd, void *data) info[i].types[j].id); } - if (system) + if (sys_info) { struct retro_controller_info *info_ptr = NULL; - free(system->ports.data); - system->ports.data = NULL; - system->ports.size = 0; + free(sys_info->ports.data); + sys_info->ports.data = NULL; + sys_info->ports.size = 0; - info_ptr = (struct retro_controller_info*)calloc(i, sizeof(*info_ptr)); - if (!info_ptr) + if (!(info_ptr = (struct retro_controller_info*) + calloc(i, sizeof(*info_ptr)))) return false; - system->ports.data = info_ptr; - memcpy(system->ports.data, info, - i * sizeof(*system->ports.data)); - system->ports.size = i; + sys_info->ports.data = info_ptr; + memcpy(sys_info->ports.data, info, + i * sizeof(*sys_info->ports.data)); + sys_info->ports.size = i; } break; } case RETRO_ENVIRONMENT_SET_MEMORY_MAPS: { - if (system) + if (sys_info) { unsigned i; const struct retro_memory_map *mmaps = @@ -2830,20 +2830,19 @@ bool runloop_environment_cb(unsigned cmd, void *data) RARCH_LOG("[Environ]: SET_MEMORY_MAPS.\n"); - free((void*)system->mmaps.descriptors); - system->mmaps.descriptors = 0; - system->mmaps.num_descriptors = 0; - descriptors = (rarch_memory_descriptor_t*)calloc(mmaps->num_descriptors, - sizeof(*descriptors)); + free((void*)sys_info->mmaps.descriptors); + sys_info->mmaps.descriptors = 0; + sys_info->mmaps.num_descriptors = 0; - if (!descriptors) + if (!(descriptors = (rarch_memory_descriptor_t*)calloc(mmaps->num_descriptors, + sizeof(*descriptors)))) return false; - system->mmaps.descriptors = descriptors; - system->mmaps.num_descriptors = mmaps->num_descriptors; + sys_info->mmaps.descriptors = descriptors; + sys_info->mmaps.num_descriptors = mmaps->num_descriptors; for (i = 0; i < mmaps->num_descriptors; i++) - system->mmaps.descriptors[i].core = mmaps->descriptors[i]; + sys_info->mmaps.descriptors[i].core = mmaps->descriptors[i]; mmap_preprocess_descriptors(descriptors, mmaps->num_descriptors); @@ -2866,14 +2865,14 @@ bool runloop_environment_cb(unsigned cmd, void *data) else RARCH_DBG(" ndx flags ptr offset start select disconn len addrspace\n"); - for (i = 0; i < system->mmaps.num_descriptors; i++) + for (i = 0; i < sys_info->mmaps.num_descriptors; i++) { - const rarch_memory_descriptor_t *desc = - &system->mmaps.descriptors[i]; char flags[7]; + const rarch_memory_descriptor_t *desc = + &sys_info->mmaps.descriptors[i]; - flags[0] = 'M'; - if ((desc->core.flags & RETRO_MEMDESC_MINSIZE_8) == RETRO_MEMDESC_MINSIZE_8) + flags[0] = 'M'; + if ( (desc->core.flags & RETRO_MEMDESC_MINSIZE_8) == RETRO_MEMDESC_MINSIZE_8) flags[1] = '8'; else if ((desc->core.flags & RETRO_MEMDESC_MINSIZE_4) == RETRO_MEMDESC_MINSIZE_4) flags[1] = '4'; @@ -2883,7 +2882,7 @@ bool runloop_environment_cb(unsigned cmd, void *data) flags[1] = '1'; flags[2] = 'A'; - if ((desc->core.flags & RETRO_MEMDESC_ALIGN_8) == RETRO_MEMDESC_ALIGN_8) + if ( (desc->core.flags & RETRO_MEMDESC_ALIGN_8) == RETRO_MEMDESC_ALIGN_8) flags[3] = '8'; else if ((desc->core.flags & RETRO_MEMDESC_ALIGN_4) == RETRO_MEMDESC_ALIGN_4) flags[3] = '4'; @@ -2893,7 +2892,7 @@ bool runloop_environment_cb(unsigned cmd, void *data) flags[3] = '1'; flags[4] = (desc->core.flags & RETRO_MEMDESC_BIGENDIAN) ? 'B' : 'b'; - flags[5] = (desc->core.flags & RETRO_MEMDESC_CONST) ? 'C' : 'c'; + flags[5] = (desc->core.flags & RETRO_MEMDESC_CONST) ? 'C' : 'c'; flags[6] = 0; RARCH_DBG(" %03u %s %p %08X %08X %08X %08X %08X %s\n", @@ -3060,7 +3059,7 @@ bool runloop_environment_cb(unsigned cmd, void *data) vfs_iface_info->required_interface_version = supported_vfs_version; vfs_iface_info->iface = &vfs_iface; - system->supports_vfs = true; + sys_info->supports_vfs = true; } else { @@ -4054,23 +4053,24 @@ static bool runloop_path_init_subsystem(runloop_state_t *runloop_st) { unsigned i, j; const struct retro_subsystem_info *info = NULL; - rarch_system_info_t *system = &runloop_st->system; + rarch_system_info_t *sys_info = &runloop_st->system; bool subsystem_path_empty = path_is_empty(RARCH_PATH_SUBSYSTEM); const char *savefile_dir = runloop_st->savefile_dir; - if (!system || subsystem_path_empty) + if (!sys_info || subsystem_path_empty) return false; /* For subsystems, we know exactly which RAM types are supported. */ /* We'll handle this error gracefully later. */ if ((info = libretro_find_subsystem_info( - system->subsystem.data, - system->subsystem.size, + sys_info->subsystem.data, + sys_info->subsystem.size, path_get(RARCH_PATH_SUBSYSTEM)))) { unsigned num_content = MIN(info->num_roms, - subsystem_path_empty ? - 0 : (unsigned)runloop_st->subsystem_fullpaths->size); + subsystem_path_empty + ? 0 + : (unsigned)runloop_st->subsystem_fullpaths->size); for (i = 0; i < num_content; i++) { diff --git a/tasks/task_content.c b/tasks/task_content.c index 9e299c0d9b..af1b44c787 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -2768,11 +2768,11 @@ void content_set_subsystem(unsigned idx) const struct retro_subsystem_info *subsystem = NULL; runloop_state_t *runloop_st = runloop_state_get_ptr(); content_state_t *p_content = content_state_get_ptr(); - rarch_system_info_t *system = &runloop_st->system; + rarch_system_info_t *sys_info = &runloop_st->system; /* Core fully loaded, use the subsystem data */ - if (system->subsystem.data) - subsystem = system->subsystem.data + idx; + if (sys_info->subsystem.data) + subsystem = sys_info->subsystem.data + idx; /* Core not loaded completely, use the data we peeked on load core */ else subsystem = runloop_st->subsystem_data + idx; @@ -2798,15 +2798,15 @@ void content_set_subsystem(unsigned idx) bool content_set_subsystem_by_name(const char* subsystem_name) { runloop_state_t *runloop_st = runloop_state_get_ptr(); - rarch_system_info_t *system = &runloop_st->system; + rarch_system_info_t *sys_info = &runloop_st->system; unsigned i = 0; /* Core not loaded completely, use the data we peeked on load core */ const struct retro_subsystem_info *subsystem = runloop_st->subsystem_data; /* Core fully loaded, use the subsystem data */ - if (system->subsystem.data) - subsystem = system->subsystem.data; + if (sys_info->subsystem.data) + subsystem = sys_info->subsystem.data; for (i = 0; i < runloop_st->subsystem_current_count; i++, subsystem++) { @@ -2824,13 +2824,13 @@ void content_get_subsystem_friendly_name(const char* subsystem_name, char* subsy { unsigned i = 0; runloop_state_t *runloop_st = runloop_state_get_ptr(); - rarch_system_info_t *system = &runloop_st->system; + rarch_system_info_t *sys_info = &runloop_st->system; /* Core not loaded completely, use the data we peeked on load core */ const struct retro_subsystem_info *subsystem = runloop_st->subsystem_data; /* Core fully loaded, use the subsystem data */ - if (system->subsystem.data) - subsystem = system->subsystem.data; + if (sys_info->subsystem.data) + subsystem = sys_info->subsystem.data; for (i = 0; i < runloop_st->subsystem_current_count; i++, subsystem++) { diff --git a/tasks/task_translation.c b/tasks/task_translation.c index c0637931ab..7f66f98088 100644 --- a/tasks/task_translation.c +++ b/tasks/task_translation.c @@ -134,8 +134,6 @@ static void handle_translation_cb( retro_task_t *task, void *task_data, void *user_data, const char *error) { - unsigned width, height; - unsigned image_width, image_height; uint8_t* raw_output_data = NULL; char* raw_image_file_data = NULL; struct scaler_ctx* scaler = NULL; @@ -144,23 +142,20 @@ static void handle_translation_cb( #ifdef HAVE_AUDIOMIXER int new_sound_size = 0; #endif - const void* dummy_data = NULL; void* raw_image_data = NULL; void* raw_image_data_alpha = NULL; void* raw_sound_data = NULL; - int retval = 0; - rjson_t* json = NULL; + rjson_t *json = NULL; int json_current_key = 0; - char* err_string = NULL; - char* text_string = NULL; - char* auto_string = NULL; - char* key_string = NULL; + char* err_str = NULL; + char* txt_str = NULL; + char* auto_str = NULL; + char* key_str = NULL; settings_t* settings = config_get_ptr(); uint32_t runloop_flags = runloop_get_flags(); #ifdef HAVE_ACCESSIBILITY input_driver_state_t *input_st = input_state_get_ptr(); #endif - bool was_paused = runloop_flags & RUNLOOP_FLAG_PAUSED; video_driver_state_t *video_st = video_state_get_ptr(); const enum retro_pixel_format @@ -191,8 +186,7 @@ static void handle_translation_cb( if (!data || error || !data->data) goto finish; - json = rjson_open_buffer(data->data, data->len); - if (!json) + if (!(json = rjson_open_buffer(data->data, data->len))) goto finish; /* Parse JSON body for the image and sound data */ @@ -241,36 +235,35 @@ static void handle_translation_cb( break; #endif case 2: /* text */ - text_string = strdup(str); + txt_str = strdup(str); break; case 3: /* error */ - err_string = strdup(str); + err_str = strdup(str); break; case 4: /* auto */ - auto_string = strdup(str); + auto_str = strdup(str); break; case 5: /* press */ - key_string = strdup(str); + key_str = strdup(str); break; } json_current_key = -1; } } - if (string_is_equal(err_string, "No text found.")) + if (string_is_equal(err_str, "No text found.")) { #ifdef DEBUG RARCH_LOG("No text found...\n"); #endif - if (text_string) + if (txt_str) { - free(text_string); - text_string = NULL; + free(txt_str); + txt_str = NULL; } - text_string = (char*)malloc(15); - - strlcpy(text_string, err_string, 15); + txt_str = (char*)malloc(15); + strlcpy(txt_str, err_str, 15); #ifdef HAVE_GFX_WIDGETS if (gfx_widgets_paused) { @@ -283,9 +276,9 @@ static void handle_translation_cb( if ( !raw_image_file_data && !raw_sound_data - && !text_string - && (access_st->ai_service_auto != 2) - && !key_string) + && !txt_str + && !key_str + && (access_st->ai_service_auto != 2)) { error = "Invalid JSON body."; goto finish; @@ -293,10 +286,11 @@ static void handle_translation_cb( if (raw_image_file_data) { + unsigned image_width, image_height; /* Get the video frame dimensions reference */ - dummy_data = video_st->frame_cache_data; - width = video_st->frame_cache_width; - height = video_st->frame_cache_height; + const void *dummy_data = video_st->frame_cache_data; + unsigned width = video_st->frame_cache_width; + unsigned height = video_st->frame_cache_height; /* try two different modes for text display * * In the first mode, we use display widget overlays, but they require @@ -309,7 +303,6 @@ static void handle_translation_cb( && video_st->poke->load_texture && video_st->poke->unload_texture) { - bool ai_res; enum image_type_enum image_type; /* Write to overlay */ if ( raw_image_file_data[0] == 'B' @@ -325,11 +318,9 @@ static void handle_translation_cb( goto finish; } - ai_res = gfx_widgets_ai_service_overlay_load( + if (!gfx_widgets_ai_service_overlay_load( raw_image_file_data, (unsigned)new_image_size, - image_type); - - if (!ai_res) + image_type)) { RARCH_LOG("Video driver not supported for AI Service."); runloop_msg_queue_push( @@ -352,9 +343,11 @@ static void handle_translation_cb( { size_t pitch; /* Write to video buffer directly (software cores only) */ - if (raw_image_file_data[0] == 'B' && raw_image_file_data[1] == 'M') + + /* This is a BMP file coming back. */ + if ( raw_image_file_data[0] == 'B' + && raw_image_file_data[1] == 'M') { - /* This is a BMP file coming back. */ /* Get image data (24 bit), and convert to the emulated pixel format */ image_width = ((uint32_t) ((uint8_t)raw_image_file_data[21]) << 24) + @@ -367,16 +360,18 @@ static void handle_translation_cb( ((uint32_t) ((uint8_t)raw_image_file_data[24]) << 16) + ((uint32_t) ((uint8_t)raw_image_file_data[23]) << 8) + ((uint32_t) ((uint8_t)raw_image_file_data[22]) << 0); - raw_image_data = (void*)malloc(image_width*image_height*3*sizeof(uint8_t)); + raw_image_data = (void*)malloc(image_width * image_height * 3 * sizeof(uint8_t)); memcpy(raw_image_data, - raw_image_file_data+54*sizeof(uint8_t), - image_width*image_height*3*sizeof(uint8_t)); + raw_image_file_data + 54 * sizeof(uint8_t), + image_width * image_height * 3 * sizeof(uint8_t)); } - else if (raw_image_file_data[1] == 'P' && raw_image_file_data[2] == 'N' && - raw_image_file_data[3] == 'G') + /* PNG coming back from the url */ + else if (raw_image_file_data[1] == 'P' + && raw_image_file_data[2] == 'N' + && raw_image_file_data[3] == 'G') { + int retval = 0; rpng_t *rpng = NULL; - /* PNG coming back from the url */ image_width = ((uint32_t) ((uint8_t)raw_image_file_data[16]) << 24)+ ((uint32_t) ((uint8_t)raw_image_file_data[17]) << 16)+ @@ -387,9 +382,8 @@ static void handle_translation_cb( ((uint32_t) ((uint8_t)raw_image_file_data[21]) << 16)+ ((uint32_t) ((uint8_t)raw_image_file_data[22]) << 8)+ ((uint32_t) ((uint8_t)raw_image_file_data[23]) << 0); - rpng = rpng_alloc(); - if (!rpng) + if (!(rpng = rpng_alloc())) { error = "Can't allocate memory."; goto finish; @@ -410,18 +404,18 @@ static void handle_translation_cb( * probably be replaced with a scaler call.*/ { unsigned ui; - int d,tw,th,tc; - d=0; + int tw, th, tc; + int d = 0; raw_image_data = (void*)malloc(image_width*image_height*3*sizeof(uint8_t)); for (ui = 0; ui < image_width * image_height * 4; ui++) { if (ui % 4 != 3) { - tc = d%3; - th = image_height-d / (3*image_width)-1; - tw = (d%(image_width*3)) / 3; - ((uint8_t*) raw_image_data)[tw*3+th*3*image_width+tc] = ((uint8_t *)raw_image_data_alpha)[ui]; - d+=1; + tc = d % 3; + th = image_height-d / (image_width * 3) - 1; + tw = (d % (image_width * 3)) / 3; + ((uint8_t*) raw_image_data)[tw * 3 + th * 3 * image_width + tc] = ((uint8_t *)raw_image_data_alpha)[ui]; + d += 1; } } } @@ -512,20 +506,19 @@ static void handle_translation_cb( } #endif - if (key_string) + if (key_str) { + size_t i; char key[8]; - int length = (int)strlen(key_string); - int i = 0; + size_t length = strlen(key_str); int start = 0; - char t = ' '; for (i = 1; i < length; i++) { - t = key_string[i]; - if (i == length-1 || t == ' ' || t == ',') + char t = key_str[i]; + if (i == length - 1 || t == ' ' || t == ',') { - if (i == length-1 && t != ' ' && t!= ',') + if (i == length - 1 && t != ' ' && t!= ',') i++; if (i-start > 7) @@ -534,32 +527,32 @@ static void handle_translation_cb( continue; } - strncpy(key, key_string+start, i-start); + strncpy(key, key_str + start, i-start); key[i-start] = '\0'; #ifdef HAVE_ACCESSIBILITY if (string_is_equal(key, "b")) - input_st->ai_gamepad_state[0] = 2; + input_st->ai_gamepad_state[0] = 2; if (string_is_equal(key, "y")) - input_st->ai_gamepad_state[1] = 2; + input_st->ai_gamepad_state[1] = 2; if (string_is_equal(key, "select")) - input_st->ai_gamepad_state[2] = 2; + input_st->ai_gamepad_state[2] = 2; if (string_is_equal(key, "start")) - input_st->ai_gamepad_state[3] = 2; + input_st->ai_gamepad_state[3] = 2; if (string_is_equal(key, "up")) - input_st->ai_gamepad_state[4] = 2; + input_st->ai_gamepad_state[4] = 2; if (string_is_equal(key, "down")) - input_st->ai_gamepad_state[5] = 2; + input_st->ai_gamepad_state[5] = 2; if (string_is_equal(key, "left")) - input_st->ai_gamepad_state[6] = 2; + input_st->ai_gamepad_state[6] = 2; if (string_is_equal(key, "right")) - input_st->ai_gamepad_state[7] = 2; + input_st->ai_gamepad_state[7] = 2; if (string_is_equal(key, "a")) - input_st->ai_gamepad_state[8] = 2; + input_st->ai_gamepad_state[8] = 2; if (string_is_equal(key, "x")) - input_st->ai_gamepad_state[9] = 2; + input_st->ai_gamepad_state[9] = 2; if (string_is_equal(key, "l")) input_st->ai_gamepad_state[10] = 2; if (string_is_equal(key, "r")) @@ -586,14 +579,14 @@ static void handle_translation_cb( } #ifdef HAVE_ACCESSIBILITY - if ( text_string + if ( txt_str && is_accessibility_enabled( accessibility_enable, access_st->enabled)) accessibility_speak_priority( accessibility_enable, accessibility_narrator_speech_speed, - text_string, 10); + txt_str, 10); #endif finish: @@ -613,23 +606,26 @@ finish: free(raw_image_data); if (scaler) free(scaler); - if (err_string) - free(err_string); - if (text_string) - free(text_string); + if (err_str) + free(err_str); + if (txt_str) + free(txt_str); if (raw_output_data) free(raw_output_data); - if (string_is_equal(auto_string, "auto")) + if (auto_str) { - if ( (access_st->ai_service_auto != 0) - && !settings->bools.ai_service_pause) - call_auto_translate_task(settings, &was_paused); + if (string_is_equal(auto_str, "auto")) + { + bool was_paused = runloop_flags & RUNLOOP_FLAG_PAUSED; + if ( (access_st->ai_service_auto != 0) + && !settings->bools.ai_service_pause) + call_auto_translate_task(settings, &was_paused); + } + free(auto_str); } - if (auto_string) - free(auto_string); - if (key_string) - free(key_string); + if (key_str) + free(key_str); } static const char *ai_service_get_str(enum translation_lang id) @@ -788,23 +784,17 @@ bool run_translation_service(settings_t *settings, bool paused) uint8_t *bmp_buffer = NULL; uint64_t buffer_bytes = 0; char *bmp64_buffer = NULL; - rjsonwriter_t* jsonwriter = NULL; + rjsonwriter_t *jsonwriter = NULL; const char *json_buffer = NULL; - int bmp64_length = 0; bool TRANSLATE_USE_BMP = false; - - const char *label = NULL; - char* system_label = NULL; + char *sys_lbl = NULL; core_info_t *core_info = NULL; video_driver_state_t *video_st = video_state_get_ptr(); - const enum retro_pixel_format - video_driver_pix_fmt = video_st->pix_fmt; access_state_t *access_st = access_state_get_ptr(); #ifdef HAVE_ACCESSIBILITY input_driver_state_t *input_st = input_state_get_ptr(); #endif - #ifdef HAVE_GFX_WIDGETS dispgfx_widget_t *p_dispwidget = dispwidget_get_ptr(); /* For the case when ai service pause is disabled. */ @@ -822,10 +812,11 @@ bool run_translation_service(settings_t *settings, bool paused) if (core_info) { - size_t label_len; - const char *system_id = core_info->system_id + size_t lbl_len; + const char *lbl = NULL; + const char *sys_id = core_info->system_id ? core_info->system_id : "core"; - size_t system_id_len = strlen(system_id); + size_t sys_id_len = strlen(sys_id); const struct playlist_entry *entry = NULL; playlist_t *current_playlist = playlist_get_cached(); @@ -835,17 +826,17 @@ bool run_translation_service(settings_t *settings, bool paused) current_playlist, path_get(RARCH_PATH_CONTENT), &entry); if (entry && !string_is_empty(entry->label)) - label = entry->label; + lbl = entry->label; } - if (!label) - label = path_basename(path_get(RARCH_PATH_BASENAME)); - label_len = strlen(label); - system_label = (char*)malloc(label_len + system_id_len + 3); - memcpy(system_label, system_id, system_id_len); - memcpy(system_label + system_id_len, "__", 2); - memcpy(system_label + 2 + system_id_len, label, label_len); - system_label[system_id_len + 2 + label_len] = '\0'; + if (!lbl) + lbl = path_basename(path_get(RARCH_PATH_BASENAME)); + lbl_len = strlen(lbl); + sys_lbl = (char*)malloc(lbl_len + sys_id_len + 3); + memcpy(sys_lbl, sys_id, sys_id_len); + memcpy(sys_lbl + sys_id_len, "__", 2); + memcpy(sys_lbl + 2 + sys_id_len, lbl, lbl_len); + sys_lbl[sys_id_len + 2 + lbl_len] = '\0'; } if (!scaler) @@ -910,6 +901,8 @@ bool run_translation_service(settings_t *settings, bool paused) } else { + const enum retro_pixel_format + video_driver_pix_fmt = video_st->pix_fmt; /* This is a software core, so just change the pixel format to 24-bit. */ if (!(bit24_image = (uint8_t*)malloc(width * height * 3))) goto finish; @@ -975,14 +968,14 @@ bool run_translation_service(settings_t *settings, bool paused) rjsonwriter_add_string_len(jsonwriter, bmp64_buffer, bmp64_length); /* Form request... */ - if (system_label) + if (sys_lbl) { rjsonwriter_raw(jsonwriter, ",", 1); rjsonwriter_raw(jsonwriter, " ", 1); rjsonwriter_add_string(jsonwriter, "label"); rjsonwriter_raw(jsonwriter, ":", 1); rjsonwriter_raw(jsonwriter, " ", 1); - rjsonwriter_add_string(jsonwriter, system_label); + rjsonwriter_add_string(jsonwriter, sys_lbl); } rjsonwriter_raw(jsonwriter, ",", 1); @@ -1147,8 +1140,8 @@ finish: if (bmp64_buffer) free(bmp64_buffer); - if (system_label) - free(system_label); + if (sys_lbl) + free(sys_lbl); if (jsonwriter) rjsonwriter_free(jsonwriter); return !error; diff --git a/ui/drivers/qt/qt_dialogs.cpp b/ui/drivers/qt/qt_dialogs.cpp index 81b9d75116..e2f5638b61 100644 --- a/ui/drivers/qt/qt_dialogs.cpp +++ b/ui/drivers/qt/qt_dialogs.cpp @@ -1103,10 +1103,10 @@ void CoreOptionsDialog::buildLayout() { QString contentLabel; QString label; - rarch_system_info_t *system = &runloop_st->system; + rarch_system_info_t *sys_info = &runloop_st->system; - /* TODO/FIXME - why have this check here? system is not used */ - if (system) + /* TODO/FIXME - why have this check here? sys_info is not used */ + if (sys_info) contentLabel = QFileInfo(path_get(RARCH_PATH_BASENAME)).completeBaseName(); if (!contentLabel.isEmpty()) diff --git a/ui/drivers/ui_cocoa.m b/ui/drivers/ui_cocoa.m index 3b58210dcc..6a38b60784 100644 --- a/ui/drivers/ui_cocoa.m +++ b/ui/drivers/ui_cocoa.m @@ -878,7 +878,7 @@ static ui_application_t ui_application_cocoa = { static void open_core_handler(ui_browser_window_state_t *state, bool result) { - rarch_system_info_t *info = &runloop_state_get_ptr()->system; + rarch_system_info_t *sys_info = &runloop_state_get_ptr()->system; settings_t *settings = config_get_ptr(); bool set_supports_no_game_enable = settings->bools.set_supports_no_game_enable; @@ -890,8 +890,8 @@ static void open_core_handler(ui_browser_window_state_t *state, bool result) path_set(RARCH_PATH_CORE, state->result); ui_companion_event_command(CMD_EVENT_LOAD_CORE); - if ( info - && info->load_no_content + if ( sys_info + && sys_info->load_no_content && set_supports_no_game_enable) { content_ctx_info_t content_info = {0}; diff --git a/ui/drivers/ui_qt.cpp b/ui/drivers/ui_qt.cpp index 8b4ba5fe30..cd6d5337ac 100644 --- a/ui/drivers/ui_qt.cpp +++ b/ui/drivers/ui_qt.cpp @@ -2913,11 +2913,11 @@ void MainWindow::setCoreActions() ViewType viewType = getCurrentViewType(); QHash hash = getCurrentContentHash(); QString currentPlaylistFileName = QString(); - rarch_system_info_t *system = &runloop_state_get_ptr()->system; + rarch_system_info_t *sys_info = &runloop_state_get_ptr()->system; m_launchWithComboBox->clear(); - if (system->load_no_content) /* Is contentless core? */ + if (sys_info->load_no_content) /* Is contentless core? */ m_startCorePushButton->show(); else m_startCorePushButton->hide();