Create playlist_cached functions inside playlist.c
This commit is contained in:
parent
00da860681
commit
bce7742745
|
@ -182,9 +182,6 @@ static bool menu_driver_pending_shutdown = false;
|
||||||
/* Are we binding a button inside the menu? */
|
/* Are we binding a button inside the menu? */
|
||||||
static bool menu_driver_is_binding = false;
|
static bool menu_driver_is_binding = false;
|
||||||
|
|
||||||
/* The currently active playlist that we are using inside the menu */
|
|
||||||
static playlist_t *menu_driver_playlist = NULL;
|
|
||||||
|
|
||||||
static menu_handle_t *menu_driver_data = NULL;
|
static menu_handle_t *menu_driver_data = NULL;
|
||||||
static const menu_ctx_driver_t *menu_driver_ctx = NULL;
|
static const menu_ctx_driver_t *menu_driver_ctx = NULL;
|
||||||
static void *menu_userdata = NULL;
|
static void *menu_userdata = NULL;
|
||||||
|
@ -1881,9 +1878,7 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data)
|
||||||
menu_driver_pending_shutdown = true;
|
menu_driver_pending_shutdown = true;
|
||||||
break;
|
break;
|
||||||
case RARCH_MENU_CTL_PLAYLIST_FREE:
|
case RARCH_MENU_CTL_PLAYLIST_FREE:
|
||||||
if (menu_driver_playlist)
|
playlist_free_cached();
|
||||||
playlist_free(menu_driver_playlist);
|
|
||||||
menu_driver_playlist = NULL;
|
|
||||||
break;
|
break;
|
||||||
case RARCH_MENU_CTL_FIND_DRIVER:
|
case RARCH_MENU_CTL_FIND_DRIVER:
|
||||||
{
|
{
|
||||||
|
@ -1930,8 +1925,7 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data)
|
||||||
const char *path = (const char*)data;
|
const char *path = (const char*)data;
|
||||||
if (string_is_empty(path))
|
if (string_is_empty(path))
|
||||||
return false;
|
return false;
|
||||||
menu_driver_playlist = playlist_init(path,
|
playlist_init_cached(path, COLLECTION_SIZE);
|
||||||
COLLECTION_SIZE);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case RARCH_MENU_CTL_PLAYLIST_GET:
|
case RARCH_MENU_CTL_PLAYLIST_GET:
|
||||||
|
@ -1939,7 +1933,7 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data)
|
||||||
playlist_t **playlist = (playlist_t**)data;
|
playlist_t **playlist = (playlist_t**)data;
|
||||||
if (!playlist)
|
if (!playlist)
|
||||||
return false;
|
return false;
|
||||||
*playlist = menu_driver_playlist;
|
*playlist = playlist_get_cached();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case RARCH_MENU_CTL_SET_PREVENT_POPULATE:
|
case RARCH_MENU_CTL_SET_PREVENT_POPULATE:
|
||||||
|
|
24
playlist.c
24
playlist.c
|
@ -52,6 +52,7 @@ struct content_playlist
|
||||||
char *conf_path;
|
char *conf_path;
|
||||||
struct playlist_entry *entries;
|
struct playlist_entry *entries;
|
||||||
};
|
};
|
||||||
|
static playlist_t *playlist_cached = NULL;
|
||||||
|
|
||||||
typedef int (playlist_sort_fun_t)(
|
typedef int (playlist_sort_fun_t)(
|
||||||
const struct playlist_entry *a,
|
const struct playlist_entry *a,
|
||||||
|
@ -554,6 +555,29 @@ end:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void playlist_free_cached(void)
|
||||||
|
{
|
||||||
|
playlist_free(playlist_cached);
|
||||||
|
playlist_cached = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
playlist_t *playlist_get_cached(void)
|
||||||
|
{
|
||||||
|
if (playlist_cached)
|
||||||
|
return playlist_cached;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool playlist_init_cached(const char *path, size_t size)
|
||||||
|
{
|
||||||
|
playlist_t *playlist = playlist_init(path, size);
|
||||||
|
if (!playlist)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
playlist_cached = playlist;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* playlist_init:
|
* playlist_init:
|
||||||
* @path : Path to playlist contents file.
|
* @path : Path to playlist contents file.
|
||||||
|
|
|
@ -129,6 +129,12 @@ void playlist_write_file(playlist_t *playlist);
|
||||||
|
|
||||||
void playlist_qsort(playlist_t *playlist);
|
void playlist_qsort(playlist_t *playlist);
|
||||||
|
|
||||||
|
void playlist_free_cached(void);
|
||||||
|
|
||||||
|
playlist_t *playlist_get_cached(void);
|
||||||
|
|
||||||
|
bool playlist_init_cached(const char *path, size_t size);
|
||||||
|
|
||||||
RETRO_END_DECLS
|
RETRO_END_DECLS
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue