#ifndef PLAYLIST_H_ #define PLAYLIST_H_ #include "common.h" /** * Playlist - A thread-safe string queue with support for indexed insert/remove. */ typedef struct Playlist Playlist; Playlist *playlist_init (void); void playlist_free (Playlist *pl); int playlist_enqueue (Playlist *pl, const char *entry); /** * Fetch the next entry in the playlist, blocking the current thread and waiting * for an entry if needed. The function can be interrupted by sending a signal * to the waiting thread, in which case *entry remains untouched, -1 is * returned, and errno is set to EINTR. Returns 0 on success. */ int playlist_dequeue(Playlist *pl, struct Entry *entry); /** * Like playlist_dequeue, but returns -1 when the playlist is empty instead of * locking the thread. Returns 0 on success. */ int playlist_try_dequeue(Playlist *pl, struct Entry *entry); int playlist_insert (Playlist *pl, unsigned int id, const char *entry); int playlist_remove (Playlist *pl, unsigned int id, struct Entry *entry); int playlist_list (Playlist *pl, struct StateInfo *list); #endif // PLAYLIST_H_