/* * Copyright 2016 (c) Anna Schumaker. */ #ifndef OCARINA_CORE_PLAYLISTS_GENERIC_H #define OCARINA_CORE_PLAYLISTS_GENERIC_H #include #include enum playlist_save_flags { PL_SAVE_FLAGS = (1 << 0), /* Save playlist random and sort data. */ PL_SAVE_ITER = (1 << 1), /* Save playlist iterator position. */ PL_SAVE_TRACKS = (1 << 2), /* Save playlist tracks. */ }; #define PL_SAVE_METADATA (PL_SAVE_FLAGS | PL_SAVE_ITER) #define PL_SAVE_ALL (PL_SAVE_TRACKS | PL_SAVE_METADATA) struct playlist_callbacks { /* Called to notify that a new playlist has been allocated. */ void (*pl_cb_alloc)(struct playlist *); /* Called to notify that a track has been added. */ void (*pl_cb_added)(struct playlist *, struct track *); /* * Called to notify that N instances of a track have been removed. * Track may be NULL to indicate that several different tracks were * removed at once. */ void (*pl_cb_removed)(struct playlist *, struct track *, unsigned int n); /* * Called to notify that a track has been updated. * If the track is NULL, then the entire playlist should be updated. */ void (*pl_cb_updated)(struct playlist *, struct track *); }; /* Called to set playlist callbacks. */ void playlist_generic_set_callbacks(struct playlist_callbacks *); /* Generic playlist init functions. */ void playlist_generic_init(struct playlist *, unsigned int, ...); /* Generic playlist deinit function. */ void playlist_generic_deinit(struct playlist *); /* Generic playlist alloc function. */ struct playlist *playlist_generic_alloc(gchar *, enum playlist_type_t, unsigned int, struct playlist_ops *, unsigned int, ...); /* Generic playlist free function. */ void playlist_generic_free(struct playlist *); /* Generic playlist save function. */ void playlist_generic_save(struct playlist *, struct file *, unsigned int); /* Generic playlist load function. */ void playlist_generic_load(struct playlist *, struct file *, unsigned int); /* Generic playlist can-select function. */ bool playlist_generic_can_select(struct playlist *); /* Generic playlist clear operation. */ void playlist_generic_clear(struct playlist *); /* Generic playlist add track operations. */ bool playlist_generic_add(struct playlist *, struct track *); bool playlist_generic_add_front(struct playlist *, struct track *); /* Generic playlist remove track operation. */ bool playlist_generic_remove(struct playlist *, struct track *); /* Generic playlist update track operation. */ void playlist_generic_update(struct playlist *, struct track *); /* Generic playlist set_random operation. */ void playlist_generic_set_random(struct playlist *, bool); /* Generic playlist sorting operations. */ void playlist_generic_sort(struct playlist *, enum compare_t); void playlist_generic_resort(struct playlist *); /* Generic playlist rearranging operation. */ bool playlist_generic_rearrange(struct playlist *, unsigned int, unsigned int); /* Generic playlist next track operation. */ struct track *playlist_generic_next(struct playlist *); #endif /* OCARINA_CORE_PLAYLISTS_GENERIC_H */