blob: ed4b19d56a5dc9ed64294139b0365c7836d348ec (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#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_
|