1
0
mirror of https://github.com/libretro/RetroArch synced 2024-07-05 09:48:42 +00:00

Remove RARCH_MENU_CTL_PLAYLIST_ calls - use playlist_init_cached,

playlist_get_cached, and playlist_free_cached from now on (defined
in playlist.h) - no more menu dependencies on cached playlists
This commit is contained in:
twinaphex 2018-04-10 17:51:40 +02:00
parent bce7742745
commit 6e299065ce
6 changed files with 71 additions and 101 deletions

View File

@ -1708,14 +1708,8 @@ void command_playlist_update_write(
const char *db_name)
{
playlist_t *plist = (playlist_t*)data;
playlist_t *playlist = NULL;
playlist_t *playlist = plist ? plist : playlist_get_cached();
if (plist)
playlist = plist;
#ifdef HAVE_MENU
else
menu_driver_ctl(RARCH_MENU_CTL_PLAYLIST_GET, &playlist);
#endif
if (!playlist)
return;

View File

@ -1491,9 +1491,8 @@ static int action_ok_playlist_entry_collection(const char *path,
if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu))
return menu_cbs_exit();
new_core_path[0] = '\0';
menu_driver_ctl(RARCH_MENU_CTL_PLAYLIST_GET, &tmp_playlist);
new_core_path[0] = '\0';
tmp_playlist = playlist_get_cached();
if (!tmp_playlist)
{
@ -1540,17 +1539,18 @@ static int action_ok_playlist_entry_collection(const char *path,
return ret;
}
menu_driver_ctl(RARCH_MENU_CTL_PLAYLIST_GET, &tmp_playlist);
tmp_playlist = playlist_get_cached();
command_playlist_update_write(
tmp_playlist,
selection_ptr,
NULL,
NULL,
new_core_path,
core_info.inf->display_name,
NULL,
NULL);
if (tmp_playlist)
command_playlist_update_write(
tmp_playlist,
selection_ptr,
NULL,
NULL,
new_core_path,
core_info.inf->display_name,
NULL,
NULL);
}
else
strlcpy(new_core_path, core_path, sizeof(new_core_path));
@ -1656,14 +1656,12 @@ static int action_ok_playlist_entry_start_content(const char *path,
const char *entry_label = NULL;
const char *core_path = NULL;
const char *core_name = NULL;
playlist_t *tmp_playlist = NULL;
menu_handle_t *menu = NULL;
playlist_t *tmp_playlist = playlist_get_cached();
if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu))
return menu_cbs_exit();
menu_driver_ctl(RARCH_MENU_CTL_PLAYLIST_GET, &tmp_playlist);
if (!tmp_playlist)
{
tmp_playlist = playlist_init(
@ -1713,18 +1711,18 @@ static int action_ok_playlist_entry_start_content(const char *path,
return ret;
}
menu_driver_ctl(RARCH_MENU_CTL_PLAYLIST_GET, &tmp_playlist);
tmp_playlist = playlist_get_cached();
command_playlist_update_write(
tmp_playlist,
selection_ptr,
NULL,
NULL,
new_core_path,
core_info.inf->display_name,
NULL,
NULL);
if (tmp_playlist)
command_playlist_update_write(
tmp_playlist,
selection_ptr,
NULL,
NULL,
new_core_path,
core_info.inf->display_name,
NULL,
NULL);
}
if (!playlist || !menu_content_playlist_load(playlist, selection_ptr))
@ -1754,8 +1752,7 @@ static int action_ok_audio_add_to_mixer(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
const char *entry_path = NULL;
playlist_t *tmp_playlist = NULL;
menu_driver_ctl(RARCH_MENU_CTL_PLAYLIST_GET, &tmp_playlist);
playlist_t *tmp_playlist = playlist_get_cached();
if (!tmp_playlist)
return -1;
@ -2986,16 +2983,13 @@ static int action_ok_reset_core_association(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
const char *tmp_path = NULL;
playlist_t *tmp_playlist = NULL;
menu_handle_t *menu = NULL;
if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu))
return menu_cbs_exit();
menu_driver_ctl(RARCH_MENU_CTL_PLAYLIST_GET, &tmp_playlist);
playlist_t *tmp_playlist = playlist_get_cached();
if (!tmp_playlist)
return 0;
if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu))
return menu_cbs_exit();
playlist_get_index(tmp_playlist,
menu->rpl_entry_selection_ptr,
@ -3020,16 +3014,13 @@ static int action_ok_add_to_favorites_playlist(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
const char *tmp_path = NULL;
playlist_t *tmp_playlist = NULL;
menu_handle_t *menu = NULL;
if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu))
return menu_cbs_exit();
menu_driver_ctl(RARCH_MENU_CTL_PLAYLIST_GET, &tmp_playlist);
playlist_t *tmp_playlist = playlist_get_cached();
if (!tmp_playlist)
return 0;
if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu))
return menu_cbs_exit();
playlist_get_index(tmp_playlist,
menu->rpl_entry_selection_ptr, &tmp_path,
@ -3045,7 +3036,6 @@ static int action_ok_delete_entry(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
size_t new_selection_ptr;
playlist_t *playlist = NULL;
char *conf_path = NULL;
char *def_conf_path = NULL;
char *def_conf_music_path = NULL;
@ -3056,12 +3046,11 @@ static int action_ok_delete_entry(const char *path,
char *def_conf_img_path = NULL;
#endif
menu_handle_t *menu = NULL;
playlist_t *playlist = playlist_get_cached();
if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu))
return menu_cbs_exit();
menu_driver_ctl(RARCH_MENU_CTL_PLAYLIST_GET, &playlist);
conf_path = playlist_get_conf_path(playlist);
def_conf_path = playlist_get_conf_path(g_defaults.content_history);
def_conf_music_path = playlist_get_conf_path(g_defaults.music_history);

View File

@ -1019,7 +1019,7 @@ static void xmb_update_thumbnail_path(void *data, unsigned i, char pos)
goto end;
}
menu_driver_ctl(RARCH_MENU_CTL_PLAYLIST_GET, &playlist);
playlist = playlist_get_cached();
if (playlist)
{

View File

@ -2486,13 +2486,16 @@ static int menu_displaylist_parse_settings_enum(void *data,
static void menu_displaylist_set_new_playlist(
menu_handle_t *menu, const char *path)
{
menu_driver_ctl(RARCH_MENU_CTL_PLAYLIST_FREE, NULL);
menu_driver_ctl(RARCH_MENU_CTL_PLAYLIST_INIT,
(void*)path);
strlcpy(
menu->db_playlist_file,
path,
sizeof(menu->db_playlist_file));
menu->db_playlist_file[0] = '\0';
if (playlist_get_cached())
playlist_free_cached();
if (playlist_init_cached(path, COLLECTION_SIZE))
strlcpy(
menu->db_playlist_file,
path,
sizeof(menu->db_playlist_file));
}
@ -2545,12 +2548,15 @@ static int menu_displaylist_parse_horizontal_list(
menu_displaylist_set_new_playlist(menu, path_playlist);
}
menu_driver_ctl(RARCH_MENU_CTL_PLAYLIST_GET, &playlist);
playlist = playlist_get_cached();
playlist_qsort(playlist);
menu_displaylist_parse_playlist(info,
playlist, msg_hash_to_str(MENU_ENUM_LABEL_COLLECTION), is_historylist);
if (playlist)
{
playlist_qsort(playlist);
menu_displaylist_parse_playlist(info,
playlist,
msg_hash_to_str(MENU_ENUM_LABEL_COLLECTION), is_historylist);
}
return 0;
}
@ -2774,7 +2780,7 @@ static int menu_displaylist_parse_horizontal_content_actions(
const char *core_path = NULL;
const char *core_name = NULL;
const char *db_name = NULL;
playlist_t *playlist = NULL;
playlist_t *playlist = playlist_get_cached();
settings_t *settings = config_get_ptr();
const char *fullpath = path_get(RARCH_PATH_CONTENT);
@ -2783,10 +2789,9 @@ static int menu_displaylist_parse_horizontal_content_actions(
idx = menu->rpl_entry_selection_ptr;
menu_driver_ctl(RARCH_MENU_CTL_PLAYLIST_GET, &playlist);
playlist_get_index(playlist, idx,
&entry_path, &label, &core_path, &core_name, NULL, &db_name);
if (playlist)
playlist_get_index(playlist, idx,
&entry_path, &label, &core_path, &core_name, NULL, &db_name);
content_loaded = !rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL)
&& string_is_equal(menu->deferred_path, fullpath);
@ -2815,14 +2820,16 @@ static int menu_displaylist_parse_horizontal_content_actions(
msg_hash_to_str(MENU_ENUM_LABEL_RUN),
MENU_ENUM_LABEL_RUN, FILE_TYPE_PLAYLIST_ENTRY, 0, idx);
if (settings->bools.playlist_entry_rename && !settings->bools.kiosk_mode_enable)
if (settings->bools.playlist_entry_rename &&
!settings->bools.kiosk_mode_enable)
menu_entries_append_enum(info->list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RENAME_ENTRY),
msg_hash_to_str(MENU_ENUM_LABEL_RENAME_ENTRY),
MENU_ENUM_LABEL_RENAME_ENTRY,
FILE_TYPE_PLAYLIST_ENTRY, 0, idx);
if (settings->bools.playlist_entry_remove && !settings->bools.kiosk_mode_enable)
if (settings->bools.playlist_entry_remove &&
!settings->bools.kiosk_mode_enable)
menu_entries_append_enum(info->list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DELETE_ENTRY),
msg_hash_to_str(MENU_ENUM_LABEL_DELETE_ENTRY),
@ -3983,9 +3990,8 @@ static void menu_displaylist_parse_playlist_generic(
menu_displaylist_set_new_playlist(menu, playlist_path);
menu_driver_ctl(RARCH_MENU_CTL_PLAYLIST_GET, &playlist);
path_playlist = strdup(playlist_name);
playlist = playlist_get_cached();
path_playlist = strdup(playlist_name);
*ret = menu_displaylist_parse_playlist(info,
playlist, path_playlist, true);
@ -4414,12 +4420,15 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data)
msg_hash_to_str(MENU_ENUM_LABEL_COLLECTION),
sizeof(path_playlist));
menu_driver_ctl(RARCH_MENU_CTL_PLAYLIST_GET, &playlist);
playlist = playlist_get_cached();
playlist_qsort(playlist);
if (playlist)
{
playlist_qsort(playlist);
ret = menu_displaylist_parse_playlist(info,
playlist, path_playlist, false);
ret = menu_displaylist_parse_playlist(info,
playlist, path_playlist, false);
}
if (ret == 0)
{

View File

@ -1877,9 +1877,6 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data)
case RARCH_MENU_CTL_SET_PENDING_SHUTDOWN:
menu_driver_pending_shutdown = true;
break;
case RARCH_MENU_CTL_PLAYLIST_FREE:
playlist_free_cached();
break;
case RARCH_MENU_CTL_FIND_DRIVER:
{
int i;
@ -1920,22 +1917,6 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data)
}
}
break;
case RARCH_MENU_CTL_PLAYLIST_INIT:
{
const char *path = (const char*)data;
if (string_is_empty(path))
return false;
playlist_init_cached(path, COLLECTION_SIZE);
}
break;
case RARCH_MENU_CTL_PLAYLIST_GET:
{
playlist_t **playlist = (playlist_t**)data;
if (!playlist)
return false;
*playlist = playlist_get_cached();
}
break;
case RARCH_MENU_CTL_SET_PREVENT_POPULATE:
menu_driver_prevent_populate = true;
break;
@ -1967,7 +1948,7 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data)
if (menu_driver_data_own)
return true;
menu_driver_ctl(RARCH_MENU_CTL_PLAYLIST_FREE, NULL);
playlist_free_cached();
menu_shader_manager_free();
if (menu_driver_data)

View File

@ -100,9 +100,6 @@ enum rarch_menu_ctl_state
RARCH_MENU_CTL_SET_OWN_DRIVER,
RARCH_MENU_CTL_UNSET_OWN_DRIVER,
RARCH_MENU_CTL_OWNS_DRIVER,
RARCH_MENU_CTL_PLAYLIST_FREE,
RARCH_MENU_CTL_PLAYLIST_INIT,
RARCH_MENU_CTL_PLAYLIST_GET,
RARCH_MENU_CTL_FIND_DRIVER,
RARCH_MENU_CTL_LIST_FREE,
RARCH_MENU_CTL_LIST_SET_SELECTION,