2016-04-24 10:36:15 -04:00
|
|
|
/*
|
|
|
|
* Copyright 2016 (c) Anna Schumaker.
|
|
|
|
*/
|
2016-09-16 08:00:48 -04:00
|
|
|
#ifndef OCARINA_CORE_PLAYLISTS_PLAYLIST_H
|
|
|
|
#define OCARINA_CORE_PLAYLISTS_PLAYLIST_H
|
2016-04-24 10:36:15 -04:00
|
|
|
#include <core/queue.h>
|
|
|
|
#include <core/tags/track.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
2016-09-09 10:17:37 -04:00
|
|
|
struct playlist;
|
|
|
|
|
2016-05-06 08:05:21 -04:00
|
|
|
enum playlist_type_t {
|
|
|
|
PL_SYSTEM,
|
2016-05-15 10:19:31 -04:00
|
|
|
PL_ARTIST,
|
2016-05-09 07:52:10 -04:00
|
|
|
PL_LIBRARY,
|
2016-08-14 10:20:15 -04:00
|
|
|
PL_USER,
|
2016-05-06 08:05:21 -04:00
|
|
|
PL_MAX_TYPE,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-09-09 10:17:37 -04:00
|
|
|
struct playlist_ops {
|
2016-09-10 12:08:11 -04:00
|
|
|
/* Called to add a track to a playlist. */
|
|
|
|
bool (*pl_add)(struct playlist *, struct track *);
|
|
|
|
|
2016-09-12 13:08:24 -04:00
|
|
|
/* Called to check if a playlist can be selected. */
|
|
|
|
bool (*pl_can_select)(struct playlist *);
|
|
|
|
|
2016-09-09 10:17:37 -04:00
|
|
|
/* Called to delete a playlist. */
|
|
|
|
bool (*pl_delete)(struct playlist *);
|
2016-09-10 13:11:18 -04:00
|
|
|
|
2016-09-13 08:47:45 -04:00
|
|
|
/* Called to pick the next track from a playlist. */
|
|
|
|
struct track *(*pl_next)(struct playlist *);
|
|
|
|
|
2016-09-10 13:11:18 -04:00
|
|
|
/* Called to remove a track from the playlist. */
|
|
|
|
bool (*pl_remove)(struct playlist *, struct track *);
|
2016-09-12 08:17:41 -04:00
|
|
|
|
|
|
|
/* Called to set a playlist flag. */
|
|
|
|
void (*pl_set_flag)(struct playlist *, enum queue_flags, bool);
|
2016-09-12 09:49:35 -04:00
|
|
|
|
|
|
|
/* Called to sort the playlist. */
|
|
|
|
void (*pl_sort)(struct playlist *, enum compare_t, bool);
|
2016-09-09 10:17:37 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-05-02 08:13:35 -04:00
|
|
|
struct playlist {
|
2016-09-16 08:00:48 -04:00
|
|
|
enum playlist_type_t pl_type; /* This playlist's type. */
|
|
|
|
gchar *pl_name; /* This playlist's name. */
|
|
|
|
unsigned int pl_id; /* This playlist's identifier. */
|
|
|
|
|
|
|
|
void *pl_private; /* This playlist's private data. */
|
|
|
|
struct queue pl_queue; /* This playlist's queue of tracks. */
|
2016-09-09 10:17:37 -04:00
|
|
|
|
|
|
|
const struct playlist_ops *pl_ops; /* This playlist's supported operations. */
|
2016-05-02 08:13:35 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-09-12 15:42:56 -04:00
|
|
|
#define DEFINE_PLAYLIST(type, name, id, ops) { \
|
2016-09-09 10:17:37 -04:00
|
|
|
.pl_type = type, \
|
|
|
|
.pl_name = name, \
|
2016-09-12 15:42:56 -04:00
|
|
|
.pl_id = id, \
|
2016-09-09 10:17:37 -04:00
|
|
|
.pl_ops = ops, \
|
|
|
|
}
|
2016-05-02 08:13:35 -04:00
|
|
|
|
|
|
|
|
2016-04-24 10:36:15 -04:00
|
|
|
struct playlist_type {
|
2016-08-12 16:12:17 -04:00
|
|
|
/* Called to save all playlists of the given type. */
|
|
|
|
void (*pl_save)(void);
|
|
|
|
|
2016-09-12 13:49:27 -04:00
|
|
|
/* Called to look up playlists. */
|
|
|
|
struct playlist *(*pl_lookup)(const gchar *);
|
2016-09-12 10:59:46 -04:00
|
|
|
struct playlist *(*pl_get)(unsigned int);
|
2016-04-24 10:36:15 -04:00
|
|
|
|
2016-05-09 10:38:47 -04:00
|
|
|
/* Called to create a new playlist. */
|
2016-09-09 08:35:52 -04:00
|
|
|
struct playlist *(*pl_new)(const gchar *);
|
2016-05-09 10:38:47 -04:00
|
|
|
|
2016-09-13 10:59:20 -04:00
|
|
|
/* Called to notify that a track has been played. */
|
|
|
|
void (*pl_played)(struct track *);
|
2016-04-24 10:36:15 -04:00
|
|
|
};
|
|
|
|
|
2016-09-16 08:00:48 -04:00
|
|
|
#endif /* OCARINA_CORE_PLAYLISTS_PLAYLIST_H */
|