From 7c8c53fb2de7deec99ab9f6520cf9e0278f2b0a1 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 21 Sep 2021 07:14:27 +0200 Subject: [PATCH] Get rid of menu_driver_get_ptr - we are going to be using only one getter for each component state instead of several getters --- .../gfx_widget_load_content_animation.c | 2 +- menu/cbs/menu_cbs_deferred_push.c | 2 +- menu/cbs/menu_cbs_ok.c | 56 +++++++++---------- menu/cbs/menu_cbs_start.c | 2 +- menu/drivers/xmb.c | 2 +- menu/menu_displaylist.c | 2 +- menu/menu_driver.c | 26 +++------ menu/menu_driver.h | 2 - menu/menu_explore.c | 2 +- retroarch.c | 6 +- tasks/task_content.c | 2 +- tasks/task_pl_thumbnail_download.c | 2 +- 12 files changed, 48 insertions(+), 58 deletions(-) diff --git a/gfx/widgets/gfx_widget_load_content_animation.c b/gfx/widgets/gfx_widget_load_content_animation.c index 269d15c75a..8ee0824cbb 100644 --- a/gfx/widgets/gfx_widget_load_content_animation.c +++ b/gfx/widgets/gfx_widget_load_content_animation.c @@ -326,7 +326,7 @@ bool gfx_widget_start_load_content_animation(void) { const struct playlist_entry *entry = NULL; #ifdef HAVE_MENU - menu_handle_t *menu = menu_driver_get_ptr(); + menu_handle_t *menu = menu_state_get_ptr()->driver_data; /* If we have an active menu, playlist entry * index can be obtained directly */ diff --git a/menu/cbs/menu_cbs_deferred_push.c b/menu/cbs/menu_cbs_deferred_push.c index 95a8f0bd6a..fd1fa68a48 100644 --- a/menu/cbs/menu_cbs_deferred_push.c +++ b/menu/cbs/menu_cbs_deferred_push.c @@ -391,7 +391,7 @@ static int general_push(menu_displaylist_info_t *info, char newstring2[PATH_MAX_LENGTH]; core_info_list_t *list = NULL; settings_t *settings = config_get_ptr(); - menu_handle_t *menu = menu_driver_get_ptr(); + menu_handle_t *menu = menu_state_get_ptr()->driver_data; bool multimedia_builtin_mediaplayer_enable = settings->bools.multimedia_builtin_mediaplayer_enable; bool multimedia_builtin_imageviewer_enable = settings->bools.multimedia_builtin_imageviewer_enable; diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 0788050618..abad1442da 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -544,7 +544,7 @@ int generic_action_ok_displaylist_push(const char *path, const char *content_path = NULL; const char *info_label = NULL; const char *info_path = NULL; - menu_handle_t *menu = menu_driver_get_ptr(); + menu_handle_t *menu = menu_state_get_ptr()->driver_data; settings_t *settings = config_get_ptr(); const char *menu_ident = menu_driver_ident(); file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0); @@ -1679,7 +1679,7 @@ static int file_load_with_detect_core_wrapper( unsigned type, bool is_carchive) { int ret = 0; - menu_handle_t *menu = menu_driver_get_ptr(); + menu_handle_t *menu = menu_state_get_ptr()->driver_data; if (!menu) return menu_cbs_exit(); @@ -1770,7 +1770,7 @@ static int action_ok_file_load_with_detect_core_carchive( const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { - menu_handle_t *menu = menu_driver_get_ptr(); + menu_handle_t *menu = menu_state_get_ptr()->driver_data; if (!menu) return menu_cbs_exit(); @@ -1852,7 +1852,7 @@ static int generic_action_ok(const char *path, const char *menu_path = NULL; const char *menu_label = NULL; const char *flush_char = NULL; - menu_handle_t *menu = menu_driver_get_ptr(); + menu_handle_t *menu = menu_state_get_ptr()->driver_data; #ifdef HAVE_AUDIOMIXER settings_t *settings = config_get_ptr(); bool audio_enable_menu = settings->bools.audio_enable_menu; @@ -2202,7 +2202,7 @@ static int action_ok_file_load(const char *path, /* TODO/FIXME - this path is triggered when we try to load a * file from an archive while inside the load subsystem * action */ - menu_handle_t *menu = menu_driver_get_ptr(); + menu_handle_t *menu = menu_state_get_ptr()->driver_data; if (!menu) return menu_cbs_exit(); @@ -2246,7 +2246,7 @@ static int action_ok_file_load(const char *path, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_ARCHIVE_OPEN)) ) { - menu_handle_t *menu = menu_driver_get_ptr(); + menu_handle_t *menu = menu_state_get_ptr()->driver_data; if (!menu) return menu_cbs_exit(); @@ -2334,7 +2334,7 @@ static int action_ok_playlist_entry_collection(const char *path, const struct playlist_entry *entry = NULL; core_info_t* core_info = NULL; bool core_is_builtin = false; - menu_handle_t *menu = menu_driver_get_ptr(); + menu_handle_t *menu = menu_state_get_ptr()->driver_data; settings_t *settings = config_get_ptr(); bool playlist_sort_alphabetical = settings->bools.playlist_sort_alphabetical; const char *path_content_history = settings->paths.path_content_history; @@ -2788,7 +2788,7 @@ static int action_ok_audio_add_to_mixer_and_collection(const char *path, { char combined_path[PATH_MAX_LENGTH]; struct playlist_entry entry = {0}; - menu_handle_t *menu = menu_driver_get_ptr(); + menu_handle_t *menu = menu_state_get_ptr()->driver_data; combined_path[0] = '\0'; @@ -2819,7 +2819,7 @@ static int action_ok_audio_add_to_mixer_and_collection_and_play(const char *path { char combined_path[PATH_MAX_LENGTH]; struct playlist_entry entry = {0}; - menu_handle_t *menu = menu_driver_get_ptr(); + menu_handle_t *menu = menu_state_get_ptr()->driver_data; combined_path[0] = '\0'; @@ -2991,7 +2991,7 @@ static void menu_input_st_string_cb_enable_settings(void *userdata, static int action_ok_shader_pass(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { - menu_handle_t *menu = menu_driver_get_ptr(); + menu_handle_t *menu = menu_state_get_ptr()->driver_data; if (!menu) return menu_cbs_exit(); @@ -3578,7 +3578,7 @@ static int action_ok_core_deferred_set(const char *new_core_path, { size_t selection = menu_navigation_get_selection(); struct playlist_entry entry = {0}; - menu_handle_t *menu = menu_driver_get_ptr(); + menu_handle_t *menu = menu_state_get_ptr()->driver_data; core_info_t *core_info = NULL; const char *core_display_name = NULL; char resolved_core_path[PATH_MAX_LENGTH]; @@ -3699,7 +3699,7 @@ static int action_ok_load_core_deferred(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { content_ctx_info_t content_info; - menu_handle_t *menu = menu_driver_get_ptr(); + menu_handle_t *menu = menu_state_get_ptr()->driver_data; content_info.argc = 0; content_info.argv = NULL; @@ -3756,7 +3756,7 @@ static int action_ok_audio_run(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { char combined_path[PATH_MAX_LENGTH]; - menu_handle_t *menu = menu_driver_get_ptr(); + menu_handle_t *menu = menu_state_get_ptr()->driver_data; combined_path[0] = '\0'; @@ -4194,7 +4194,7 @@ static int action_ok_file_load_imageviewer(const char *path, static int action_ok_file_load_current_core(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { - menu_handle_t *menu = menu_driver_get_ptr(); + menu_handle_t *menu = menu_state_get_ptr()->driver_data; if (!menu) return menu_cbs_exit(); @@ -4207,7 +4207,7 @@ static int action_ok_file_load_detect_core(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { content_ctx_info_t content_info; - menu_handle_t *menu = menu_driver_get_ptr(); + menu_handle_t *menu = menu_state_get_ptr()->driver_data; if (!menu) return menu_cbs_exit(); @@ -4437,7 +4437,7 @@ static void cb_net_generic(retro_task_t *task, bool refresh = false; http_transfer_data_t *data = (http_transfer_data_t*)task_data; file_transfer_t *state = (file_transfer_t*)user_data; - menu_handle_t *menu = menu_driver_get_ptr(); + menu_handle_t *menu = menu_state_get_ptr()->driver_data; if (!menu) goto finish; @@ -4969,7 +4969,7 @@ static int action_ok_sideload_core(const char *path, const char *menu_path = NULL; const char *core_file = path; bool core_loaded = false; - menu_handle_t *menu = menu_driver_get_ptr(); + menu_handle_t *menu = menu_state_get_ptr()->driver_data; settings_t *settings = config_get_ptr(); const char *dir_libretro = settings->paths.directory_libretro; @@ -5140,7 +5140,7 @@ DEFAULT_ACTION_OK_CMD_FUNC(action_ok_show_wimp, CMD_EVENT_UI_COMP static int action_ok_set_core_association(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { - menu_handle_t *menu = menu_driver_get_ptr(); + menu_handle_t *menu = menu_state_get_ptr()->driver_data; if (!menu) return menu_cbs_exit(); @@ -5155,8 +5155,8 @@ static int action_ok_set_core_association(const char *path, static int action_ok_reset_core_association(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { - menu_handle_t *menu = menu_driver_get_ptr(); size_t playlist_index; + menu_handle_t *menu = menu_state_get_ptr()->driver_data; if (!menu) return menu_cbs_exit(); @@ -5246,7 +5246,7 @@ static int action_ok_add_to_favorites(const char *path, /* > crc32 + db_name */ { - menu_handle_t *menu = menu_driver_get_ptr(); + menu_handle_t *menu = menu_state_get_ptr()->driver_data; if (menu) { playlist_t *playlist_curr = playlist_get_cached(); @@ -5298,7 +5298,7 @@ static int action_ok_add_to_favorites_playlist(const char *path, { playlist_t *playlist_curr = playlist_get_cached(); const struct playlist_entry *entry = NULL; - menu_handle_t *menu = menu_driver_get_ptr(); + menu_handle_t *menu = menu_state_get_ptr()->driver_data; int ret = 0; if (!playlist_curr) @@ -5407,7 +5407,7 @@ static int action_ok_delete_entry(const char *path, #endif char *def_conf_fav_path = NULL; playlist_t *playlist = playlist_get_cached(); - menu_handle_t *menu = menu_driver_get_ptr(); + menu_handle_t *menu = menu_state_get_ptr()->driver_data; if (!menu) return menu_cbs_exit(); @@ -6012,7 +6012,7 @@ static int action_ok_push_downloads_dir(const char *path, int action_ok_push_filebrowser_list_dir_select(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { - menu_handle_t *menu = menu_driver_get_ptr(); + menu_handle_t *menu = menu_state_get_ptr()->driver_data; if (!menu) return menu_cbs_exit(); @@ -6026,7 +6026,7 @@ int action_ok_push_filebrowser_list_dir_select(const char *path, int action_ok_push_filebrowser_list_file_select(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { - menu_handle_t *menu = menu_driver_get_ptr(); + menu_handle_t *menu = menu_state_get_ptr()->driver_data; if (!menu) return menu_cbs_exit(); @@ -6646,7 +6646,7 @@ static int action_ok_load_archive(const char *path, { const char *menu_path = NULL; const char *content_path = NULL; - menu_handle_t *menu = menu_driver_get_ptr(); + menu_handle_t *menu = menu_state_get_ptr()->driver_data; if (!menu) return menu_cbs_exit(); @@ -6674,7 +6674,7 @@ static int action_ok_load_archive_detect_core(const char *path, core_info_list_t *list = NULL; const char *menu_path = NULL; const char *content_path = NULL; - menu_handle_t *menu = menu_driver_get_ptr(); + menu_handle_t *menu = menu_state_get_ptr()->driver_data; if (!menu) return menu_cbs_exit(); @@ -6960,7 +6960,7 @@ static int action_ok_disk_image_append(const char *path, { char image_path[PATH_MAX_LENGTH]; rarch_system_info_t *sys_info = runloop_get_system_info(); - menu_handle_t *menu = menu_driver_get_ptr(); + menu_handle_t *menu = menu_state_get_ptr()->driver_data; const char *menu_path = NULL; settings_t *settings = config_get_ptr(); #ifdef HAVE_AUDIOMIXER @@ -7404,7 +7404,7 @@ static int action_ok_pl_entry_content_thumbnails(const char *path, { char system[PATH_MAX_LENGTH]; playlist_t *playlist = playlist_get_cached(); - menu_handle_t *menu = menu_driver_get_ptr(); + menu_handle_t *menu = menu_state_get_ptr()->driver_data; system[0] = '\0'; diff --git a/menu/cbs/menu_cbs_start.c b/menu/cbs/menu_cbs_start.c index eee4f0450c..ba22ca4f8c 100644 --- a/menu/cbs/menu_cbs_start.c +++ b/menu/cbs/menu_cbs_start.c @@ -283,7 +283,7 @@ static int action_start_shader_pass( const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { - menu_handle_t *menu = menu_driver_get_ptr(); + menu_handle_t *menu = menu_state_get_ptr()->driver_data; if (!menu) return menu_cbs_exit(); diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index f08cf86b4a..6aaf9434c9 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -5703,7 +5703,7 @@ static void xmb_menu_animation_update_time( float *ticker_pixel_increment, unsigned video_width, unsigned video_height) { - menu_handle_t *menu = menu_driver_get_ptr(); + menu_handle_t *menu = menu_state_get_ptr()->driver_data; xmb_handle_t *xmb = NULL; if (!menu) diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 0095b6889e..149183ad42 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -9827,7 +9827,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, static bool core_selected = false; unsigned count = 0; int ret = 0; - menu_handle_t *menu = menu_driver_get_ptr(); + menu_handle_t *menu = menu_state_get_ptr()->driver_data; disp_list.info = info; disp_list.type = type; diff --git a/menu/menu_driver.c b/menu/menu_driver.c index 8ba5af0aae..4d9836ce36 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -283,14 +283,6 @@ struct menu_state *menu_state_get_ptr(void) return &menu_driver_state; } -menu_handle_t *menu_driver_get_ptr(void) -{ - struct menu_state *menu_st = &menu_driver_state; - if (!menu_st) - return NULL; - return menu_st->driver_data; -} - static bool menu_should_pop_stack(const char *label) { /* > Info box */ @@ -2537,7 +2529,7 @@ int menu_cbs_exit(void) #if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL) void menu_driver_set_last_shader_preset_path(const char *path) { - menu_handle_t *menu = menu_driver_get_ptr(); + menu_handle_t *menu = menu_driver_state.driver_data; if (menu) menu_driver_set_last_shader_path_int( path, @@ -2550,7 +2542,7 @@ void menu_driver_set_last_shader_preset_path(const char *path) void menu_driver_set_last_shader_pass_path(const char *path) { - menu_handle_t *menu = menu_driver_get_ptr(); + menu_handle_t *menu = menu_driver_state.driver_data; if (menu) menu_driver_set_last_shader_path_int( path, @@ -2563,7 +2555,7 @@ void menu_driver_set_last_shader_pass_path(const char *path) enum rarch_shader_type menu_driver_get_last_shader_preset_type(void) { - menu_handle_t *menu = menu_driver_get_ptr(); + menu_handle_t *menu = menu_driver_state.driver_data; if (!menu) return RARCH_SHADER_NONE; return menu->last_shader_selection.preset_type; @@ -2571,7 +2563,7 @@ enum rarch_shader_type menu_driver_get_last_shader_preset_type(void) enum rarch_shader_type menu_driver_get_last_shader_pass_type(void) { - menu_handle_t *menu = menu_driver_get_ptr(); + menu_handle_t *menu = menu_driver_state.driver_data; if (!menu) return RARCH_SHADER_NONE; return menu->last_shader_selection.pass_type; @@ -2581,7 +2573,7 @@ void menu_driver_get_last_shader_preset_path( const char **directory, const char **file_name) { settings_t *settings = config_get_ptr(); - menu_handle_t *menu = menu_driver_get_ptr(); + menu_handle_t *menu = menu_driver_state.driver_data; enum rarch_shader_type type = RARCH_SHADER_NONE; const char *shader_dir = NULL; const char *shader_file_name = NULL; @@ -2601,7 +2593,7 @@ void menu_driver_get_last_shader_preset_path( void menu_driver_get_last_shader_pass_path( const char **directory, const char **file_name) { - menu_handle_t *menu = menu_driver_get_ptr(); + menu_handle_t *menu = menu_driver_state.driver_data; settings_t *settings = config_get_ptr(); enum rarch_shader_type type = RARCH_SHADER_NONE; const char *shader_dir = NULL; @@ -4145,7 +4137,7 @@ end: const char *menu_driver_get_last_start_directory(void) { - menu_handle_t *menu = menu_driver_get_ptr(); + menu_handle_t *menu = menu_driver_state.driver_data; settings_t *settings = config_get_ptr(); bool use_last = settings->bools.use_last_start_directory; const char *default_directory = settings->paths.directory_menu_content; @@ -4163,7 +4155,7 @@ const char *menu_driver_get_last_start_directory(void) const char *menu_driver_get_last_start_file_name(void) { - menu_handle_t *menu = menu_driver_get_ptr(); + menu_handle_t *menu = menu_driver_state.driver_data; settings_t *settings = config_get_ptr(); bool use_last = settings->bools.use_last_start_directory; @@ -4179,7 +4171,7 @@ const char *menu_driver_get_last_start_file_name(void) void menu_driver_set_last_start_content(const char *start_content_path) { char archive_path[PATH_MAX_LENGTH]; - menu_handle_t *menu = menu_driver_get_ptr(); + menu_handle_t *menu = menu_driver_state.driver_data; settings_t *settings = config_get_ptr(); bool use_last = settings->bools.use_last_start_directory; const char *archive_delim = NULL; diff --git a/menu/menu_driver.h b/menu/menu_driver.h index 4c86f0f388..304f944d46 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -639,8 +639,6 @@ void menu_driver_set_last_start_content(const char *start_content_path); const char *menu_driver_get_pending_selection(void); void menu_driver_set_pending_selection(const char *pending_selection); -menu_handle_t *menu_driver_get_ptr(void); - struct menu_state *menu_state_get_ptr(void); enum action_iterate_type diff --git a/menu/menu_explore.c b/menu/menu_explore.c index fc25b26b14..ea5877ed11 100644 --- a/menu/menu_explore.c +++ b/menu/menu_explore.c @@ -1149,7 +1149,7 @@ SKIP_ENTRY:; int pl_idx; const struct playlist_entry *pl_entry = explore_state->entries[current_type - EXPLORE_TYPE_FIRSTITEM].playlist_entry; - menu_handle_t *menu = menu_driver_get_ptr(); + menu_handle_t *menu = menu_state_get_ptr()->driver_data; strlcpy(explore_state->title, pl_entry->label, sizeof(explore_state->title)); diff --git a/retroarch.c b/retroarch.c index 25e0b60d69..527bbca55c 100644 --- a/retroarch.c +++ b/retroarch.c @@ -575,7 +575,8 @@ bool menu_input_key_bind_set_mode( struct rarch_state *p_rarch = &rarch_st; input_driver_state_t *input_driver_st = &p_rarch->input_driver_state; - menu_handle_t *menu = menu_driver_get_ptr(); + struct menu_state *menu_st = menu_state_get_ptr(); + menu_handle_t *menu = menu_st->driver_data; const input_device_driver_t *joypad = input_driver_st->primary_joypad; #ifdef HAVE_MFI @@ -585,7 +586,6 @@ bool menu_input_key_bind_set_mode( const input_device_driver_t *sec_joypad = NULL; #endif - struct menu_state *menu_st = menu_state_get_ptr(); menu_input_t *menu_input = &menu_st->input_state; settings_t *settings = p_rarch->configuration_settings; struct menu_bind_state *binds = &menu_st->input_binds; @@ -1209,7 +1209,7 @@ int generic_menu_entry_action( struct menu_state *menu_st = menu_state_get_ptr(); const menu_ctx_driver_t *menu_driver_ctx = menu_st->driver_ctx; - menu_handle_t *menu = menu_driver_get_ptr(); + menu_handle_t *menu = menu_st->driver_data; settings_t *settings = p_rarch->configuration_settings; void *menu_userdata = menu_st->userdata; bool wraparound_enable = settings->bools.menu_navigation_wraparound_enable; diff --git a/tasks/task_content.c b/tasks/task_content.c index 70306d1325..92db6a8dad 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -1623,7 +1623,7 @@ static void task_push_to_history_list( #ifdef HAVE_MENU else { - menu_handle_t *menu = menu_driver_get_ptr(); + menu_handle_t *menu = menu_state_get_ptr()->driver_data; /* Set database name + checksum */ if (menu) { diff --git a/tasks/task_pl_thumbnail_download.c b/tasks/task_pl_thumbnail_download.c index 08aaeb2bdc..3d42e30d36 100644 --- a/tasks/task_pl_thumbnail_download.c +++ b/tasks/task_pl_thumbnail_download.c @@ -575,7 +575,7 @@ static void cb_task_pl_entry_thumbnail_refresh_menu( const char *left_thumbnail_path = NULL; bool do_refresh = false; playlist_t *current_playlist = playlist_get_cached(); - menu_handle_t *menu = menu_driver_get_ptr(); + menu_handle_t *menu = menu_state_get_ptr()->driver_data; const char *menu_driver = menu_driver_ident(); if (!task)