core/playlist: Clean up how we fill in static playlists
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
4e6028cf6e
commit
73992ed912
|
@ -16,23 +16,6 @@ public:
|
|||
queue_clear(this);
|
||||
}
|
||||
|
||||
void fill(index_entry *ent)
|
||||
{
|
||||
struct set_iter it;
|
||||
|
||||
clear();
|
||||
if (!ent)
|
||||
return;
|
||||
|
||||
queue_set_flag(this, Q_ADD_FRONT);
|
||||
|
||||
set_for_each(&ent->ie_set, &it)
|
||||
queue_add(this, track_get(it.it_val));
|
||||
|
||||
queue_unset_flag(this, Q_ADD_FRONT);
|
||||
queue_resort(this);
|
||||
}
|
||||
|
||||
unsigned int find_average_count()
|
||||
{
|
||||
struct db_entry *track, *next;
|
||||
|
@ -99,6 +82,24 @@ static inline bool __playlist_is_dynamic(const gchar *name)
|
|||
return string_compare(name, "Unplayed") == 0;
|
||||
}
|
||||
|
||||
static void __playlist_fill(const gchar *name, struct set *set)
|
||||
{
|
||||
struct set_iter it;
|
||||
|
||||
queue_clear(&playlist_q);
|
||||
cur_plist = name;
|
||||
|
||||
if (!set)
|
||||
return;
|
||||
|
||||
queue_set_flag(&playlist_q, Q_ADD_FRONT);
|
||||
set_for_each(set, &it)
|
||||
queue_add(&playlist_q, track_get(it.it_val));
|
||||
queue_unset_flag(&playlist_q, Q_ADD_FRONT);
|
||||
|
||||
queue_resort(&playlist_q);
|
||||
}
|
||||
|
||||
|
||||
void playlist_init(struct queue_ops *ops)
|
||||
{
|
||||
|
@ -165,20 +166,18 @@ bool playlist_has(const gchar *name, struct track *track)
|
|||
|
||||
void playlist_select(const gchar *name)
|
||||
{
|
||||
index_entry *ent;
|
||||
struct index_entry *ent;
|
||||
|
||||
if (!name)
|
||||
return;
|
||||
|
||||
if (__playlist_is_static(name)) {
|
||||
ent = INDEX_ENTRY(db_get(&playlist_db, name));
|
||||
playlist_q.fill(ent);
|
||||
} else if (__playlist_is_dynamic(name))
|
||||
__playlist_fill(name, ent ? &ent->ie_set : NULL);
|
||||
} else if (__playlist_is_dynamic(name)) {
|
||||
playlist_q.dynamic_fill(name);
|
||||
else
|
||||
return;
|
||||
|
||||
cur_plist = name;
|
||||
cur_plist = name;
|
||||
}
|
||||
}
|
||||
|
||||
index_entry *playlist :: get_tracks(const std::string &name)
|
||||
|
|
Loading…
Reference in New Issue