core/playlists/system: Clean up system playlist initialization
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
8a5163fb68
commit
8af9148606
|
@ -26,19 +26,6 @@ static bool sys_pl_delete_clear(struct playlist *playlist)
|
|||
return false;
|
||||
}
|
||||
|
||||
static void sys_pl_generic_init(struct playlist *playlist, unsigned int flags,
|
||||
struct queue_ops *ops)
|
||||
{
|
||||
playlist_generic_init(playlist, 0, ops);
|
||||
}
|
||||
|
||||
static void sys_pl_update_init(struct playlist *playlist, unsigned int flags,
|
||||
struct queue_ops *ops)
|
||||
{
|
||||
sys_pl_generic_init(playlist, flags, ops);
|
||||
pl_system_update(playlist->pl_name);
|
||||
}
|
||||
|
||||
static bool sys_pl_generic_add_front(struct playlist *playlist,
|
||||
struct track *track)
|
||||
{
|
||||
|
@ -65,7 +52,6 @@ static struct playlist_ops favorites_ops = {
|
|||
static struct sys_playlist sys_favorites = {
|
||||
.spl_playlist = DEFINE_PLAYLIST(PL_SYSTEM, "Favorites",
|
||||
SYS_PL_FAVORITES, &favorites_ops),
|
||||
.spl_init = playlist_generic_init,
|
||||
};
|
||||
|
||||
|
||||
|
@ -122,7 +108,6 @@ static struct playlist_ops hidden_ops = {
|
|||
static struct sys_playlist sys_hidden = {
|
||||
.spl_playlist = DEFINE_PLAYLIST(PL_SYSTEM, "Hidden",
|
||||
SYS_PL_HIDDEN, &hidden_ops),
|
||||
.spl_init = playlist_generic_init,
|
||||
};
|
||||
|
||||
|
||||
|
@ -151,12 +136,6 @@ static bool sys_pl_queued_load()
|
|||
return true;
|
||||
}
|
||||
|
||||
static void sys_pl_queued_init(struct playlist *playlist,
|
||||
unsigned int flags, struct queue_ops *ops)
|
||||
{
|
||||
queue_init(&playlist->pl_queue, 0, ops, playlist);
|
||||
}
|
||||
|
||||
static struct track *sys_pl_queued_next(struct playlist *playlist)
|
||||
{
|
||||
struct track *track = playlist_generic_next(playlist);
|
||||
|
@ -180,7 +159,6 @@ static struct playlist_ops queued_ops = {
|
|||
static struct sys_playlist sys_queued = {
|
||||
.spl_playlist = DEFINE_PLAYLIST(PL_SYSTEM, "Queued Tracks",
|
||||
SYS_PL_QUEUED, &queued_ops),
|
||||
.spl_init = sys_pl_queued_init,
|
||||
};
|
||||
|
||||
|
||||
|
@ -217,7 +195,6 @@ static struct playlist_ops collection_ops = {
|
|||
static struct sys_playlist sys_collection = {
|
||||
.spl_playlist = DEFINE_PLAYLIST(PL_SYSTEM, "Collection",
|
||||
SYS_PL_COLLECTION, &collection_ops),
|
||||
.spl_init = sys_pl_update_init,
|
||||
.spl_update = sys_pl_collection_update,
|
||||
};
|
||||
|
||||
|
@ -225,12 +202,6 @@ static struct sys_playlist sys_collection = {
|
|||
/*
|
||||
* History playlist operations.
|
||||
*/
|
||||
static void sys_pl_history_init(struct playlist *playlist,
|
||||
unsigned int flags, struct queue_ops *ops)
|
||||
{
|
||||
queue_init(&playlist->pl_queue, 0, ops, playlist);
|
||||
}
|
||||
|
||||
static bool sys_pl_history_add(struct playlist *playlist, struct track *track)
|
||||
{
|
||||
queue_add_front(&playlist->pl_queue, track);
|
||||
|
@ -246,7 +217,6 @@ static struct playlist_ops history_ops = {
|
|||
static struct sys_playlist sys_history = {
|
||||
.spl_playlist = DEFINE_PLAYLIST(PL_SYSTEM, "History",
|
||||
SYS_PL_HISTORY, &history_ops),
|
||||
.spl_init = sys_pl_history_init,
|
||||
};
|
||||
|
||||
|
||||
|
@ -271,7 +241,6 @@ static struct playlist_ops unplayed_ops = {
|
|||
static struct sys_playlist sys_unplayed = {
|
||||
.spl_playlist = DEFINE_PLAYLIST(PL_SYSTEM, "Unplayed",
|
||||
SYS_PL_UNPLAYED, &unplayed_ops),
|
||||
.spl_init = sys_pl_update_init,
|
||||
.spl_update = sys_pl_unplayed_update,
|
||||
};
|
||||
|
||||
|
@ -298,7 +267,6 @@ static struct playlist_ops most_played_ops = {
|
|||
static struct sys_playlist sys_most_played = {
|
||||
.spl_playlist = DEFINE_PLAYLIST(PL_SYSTEM, "Most Played",
|
||||
SYS_PL_MOST_PLAYED, &most_played_ops),
|
||||
.spl_init = sys_pl_update_init,
|
||||
.spl_update = sys_pl_most_played_update,
|
||||
};
|
||||
|
||||
|
@ -325,7 +293,6 @@ static struct playlist_ops least_played_ops = {
|
|||
static struct sys_playlist sys_least_played = {
|
||||
.spl_playlist = DEFINE_PLAYLIST(PL_SYSTEM, "Least Played",
|
||||
SYS_PL_LEAST_PLAYED, &least_played_ops),
|
||||
.spl_init = sys_pl_update_init,
|
||||
.spl_update = sys_pl_least_played_update,
|
||||
};
|
||||
|
||||
|
@ -490,14 +457,29 @@ struct playlist_type pl_system = {
|
|||
|
||||
void pl_system_init(struct queue_ops *ops)
|
||||
{
|
||||
struct sys_playlist *sys_pl;
|
||||
struct playlist *playlist;
|
||||
unsigned int i;
|
||||
|
||||
idle_schedule(IDLE_SYNC, __sys_pl_load_new, NULL);
|
||||
|
||||
for (i = 0; i < SYS_PL_NUM_PLAYLISTS; i++) {
|
||||
sys_pl = sys_playlists[i];
|
||||
sys_pl->spl_init(&sys_pl->spl_playlist, 0, ops);
|
||||
playlist = pl_system_get(i);
|
||||
|
||||
switch (i) {
|
||||
case SYS_PL_QUEUED:
|
||||
case SYS_PL_HISTORY:
|
||||
queue_init(&playlist->pl_queue, 0, ops, playlist);
|
||||
break;
|
||||
case SYS_PL_COLLECTION:
|
||||
case SYS_PL_UNPLAYED:
|
||||
case SYS_PL_MOST_PLAYED:
|
||||
case SYS_PL_LEAST_PLAYED:
|
||||
pl_system_update(playlist->pl_name);
|
||||
case SYS_PL_FAVORITES:
|
||||
case SYS_PL_HIDDEN:
|
||||
playlist_generic_init(playlist, 0, ops);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@ enum sys_playlist_t {
|
|||
struct sys_playlist {
|
||||
struct playlist spl_playlist;
|
||||
|
||||
void (*spl_init)(struct playlist *, unsigned int, struct queue_ops *);
|
||||
bool (*spl_update)(struct playlist *, struct track *);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue