2 * This file is part of DisOrder.
3 * Copyright (C) 2004, 2005, 2006, 2007 Richard Kettlewell
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
21 #ifndef SERVER_QUEUE_H
22 #define SERVER_QUEUE_H
24 extern struct queue_entry qhead;
25 /* queue of things yet to be played. the head will be played
28 extern struct queue_entry phead;
29 /* things that have been played in the past. the head is the oldest. */
31 void queue_read(void);
32 /* read the queue in. Calls @fatal@ on error. */
34 void queue_write(void);
35 /* write the queue out. Calls @fatal@ on error. */
37 void recent_read(void);
38 /* read the recently played list in. Calls @fatal@ on error. */
40 void recent_write(void);
41 /* write the recently played list out. Calls @fatal@ on error. */
43 struct queue_entry *queue_add(const char *track, const char *submitter,
45 #define WHERE_START 0 /* Add to head of queue */
46 #define WHERE_END 1 /* Add to end of queue */
47 #define WHERE_BEFORE_RANDOM 2 /* End, or before random track */
48 /* add an entry to the queue. Return a pointer to the new entry. */
50 void queue_remove(struct queue_entry *q, const char *who);
51 /* remove an from the queue */
53 struct queue_entry *queue_find(const char *key);
54 /* find a track in the queue by name or ID */
56 void queue_played(struct queue_entry *q);
57 /* add @q@ to the played list */
59 int queue_move(struct queue_entry *q, int delta, const char *who);
60 /* move element @q@ in the queue towards the front (@delta@ > 0) or towards the
61 * back (@delta@ < 0). The return value is the leftover delta once we've hit
62 * the end in whichever direction we were going. */
64 void queue_moveafter(struct queue_entry *target,
65 int nqs, struct queue_entry **qs, const char *who);
66 /* Move all the elements QS to just after TARGET, or to the head if
69 void queue_fix_sofar(struct queue_entry *q);
70 /* Fix up the sofar field for standalone players */
72 #endif /* SERVER_QUEUE_H */