Remove favourites init/deinit from command event, and replace with seperate functions in retroarch.h/.c

This commit is contained in:
jdgleaver 2019-07-31 11:32:19 +01:00
parent 5220dc9084
commit 9617856c5c
6 changed files with 42 additions and 37 deletions

View File

@ -106,10 +106,6 @@ enum event_command
CMD_EVENT_HISTORY_DEINIT,
/* Initializes history playlist. */
CMD_EVENT_HISTORY_INIT,
/* Deinitializes favourties playlist. */
CMD_EVENT_FAVORITES_DEINIT,
/* Initializes favourties playlist. */
CMD_EVENT_FAVORITES_INIT,
/* Deinitializes core information. */
CMD_EVENT_CORE_INFO_DEINIT,
/* Initializes core information. */

View File

@ -2465,7 +2465,7 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data)
menu_entries_ctl(MENU_ENTRIES_CTL_DEINIT, NULL);
command_event(CMD_EVENT_HISTORY_DEINIT, NULL);
command_event(CMD_EVENT_FAVORITES_DEINIT, NULL);
rarch_favorites_deinit();
menu_dialog_reset();

View File

@ -6051,8 +6051,8 @@ void general_write_handler(rarch_setting_t *setting)
/* In all cases, need to close and reopen
* playlist file (to update maximum capacity) */
command_event(CMD_EVENT_FAVORITES_DEINIT, NULL);
command_event(CMD_EVENT_FAVORITES_INIT, NULL);
rarch_favorites_deinit();
rarch_favorites_init();
}
}
break;

View File

@ -4210,34 +4210,6 @@ TODO: Add a setting for these tweaks */
#endif
}
break;
case CMD_EVENT_FAVORITES_DEINIT:
if (g_defaults.content_favorites)
{
playlist_write_file(g_defaults.content_favorites);
playlist_free(g_defaults.content_favorites);
g_defaults.content_favorites = NULL;
}
break;
case CMD_EVENT_FAVORITES_INIT:
{
settings_t *settings = configuration_settings;
unsigned content_favorites_size;
if (settings->ints.content_favorites_size < 0)
content_favorites_size = COLLECTION_SIZE;
else
content_favorites_size = (unsigned)settings->ints.content_favorites_size;
command_event(CMD_EVENT_FAVORITES_DEINIT, NULL);
RARCH_LOG("%s: [%s].\n",
msg_hash_to_str(MSG_LOADING_FAVORITES_FILE),
settings->paths.path_content_favorites);
g_defaults.content_favorites = playlist_init(
settings->paths.path_content_favorites,
content_favorites_size);
}
break;
case CMD_EVENT_CORE_INFO_DEINIT:
core_info_deinit_list();
core_info_free_current_core();
@ -5174,7 +5146,7 @@ int rarch_main(int argc, char *argv[], void *data)
libretro_free_system_info(&runloop_system.info);
command_event(CMD_EVENT_HISTORY_DEINIT, NULL);
command_event(CMD_EVENT_FAVORITES_DEINIT, NULL);
rarch_favorites_deinit();
configuration_settings = (settings_t*)calloc(1, sizeof(settings_t));
@ -24776,6 +24748,39 @@ enum retro_language rarch_get_language_from_iso(const char *iso639)
return lang;
}
void rarch_favorites_init(void)
{
settings_t *settings = configuration_settings;
unsigned content_favorites_size;
if (!settings)
return;
if (settings->ints.content_favorites_size < 0)
content_favorites_size = COLLECTION_SIZE;
else
content_favorites_size = (unsigned)settings->ints.content_favorites_size;
rarch_favorites_deinit();
RARCH_LOG("%s: [%s].\n",
msg_hash_to_str(MSG_LOADING_FAVORITES_FILE),
settings->paths.path_content_favorites);
g_defaults.content_favorites = playlist_init(
settings->paths.path_content_favorites,
content_favorites_size);
}
void rarch_favorites_deinit(void)
{
if (g_defaults.content_favorites)
{
playlist_write_file(g_defaults.content_favorites);
playlist_free(g_defaults.content_favorites);
g_defaults.content_favorites = NULL;
}
}
/* Libretro core loader */
static void retro_run_null(void)

View File

@ -380,6 +380,10 @@ void rarch_log_file_deinit(void);
enum retro_language rarch_get_language_from_iso(const char *lang);
void rarch_favorites_init(void);
void rarch_favorites_deinit(void);
/* Audio */
#ifdef HAVE_AUDIOMIXER

View File

@ -658,7 +658,7 @@ static bool content_load(content_ctx_info_t *info)
#endif
command_event(CMD_EVENT_HISTORY_INIT, NULL);
command_event(CMD_EVENT_FAVORITES_INIT, NULL);
rarch_favorites_init();
command_event(CMD_EVENT_RESUME, NULL);
command_event(CMD_EVENT_VIDEO_SET_ASPECT_RATIO, NULL);