2 * This file is part of DisOrder.
3 * Copyright (C) 2004-2008 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 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU 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, see <http://www.gnu.org/licenses/>.
21 * Used for the queue, the recently played list and the currently playing
22 * track, both in the server and in clients.
31 playing_failed, /* failed to play */
32 playing_isscratch, /* this is a scratch track */
33 playing_no_player, /* couldn't find a player */
34 playing_ok, /* played OK */
35 playing_paused, /* started but paused */
36 playing_quitting, /* interrupt because server quit */
37 playing_random, /* unplayed randomly chosen track */
38 playing_scratched, /* was scratched */
39 playing_started, /* started to play */
40 playing_unplayed /* haven't played this track yet */
43 extern const char *playing_states[];
45 /* queue entries form a circular doubly-linked list */
47 struct queue_entry *next; /* next entry */
48 struct queue_entry *prev; /* previous entry */
49 const char *track; /* path to track */
50 const char *submitter; /* name of submitter */
51 time_t when; /* time submitted */
52 time_t played; /* when played */
53 enum playing_state state; /* state */
54 long wstat; /* wait status */
55 const char *scratched; /* scratched by */
56 const char *id; /* queue entry ID */
57 time_t expected; /* expected started time */
58 /* for playing or soon-to-be-played tracks only: */
59 unsigned long type; /* type word from plugin */
60 const struct plugin *pl; /* plugin that's playing this track */
61 void *data; /* player data */
62 long sofar; /* how much played so far */
63 int prepared; /* true when connected to speaker */
64 /* For DISORDER_PLAYER_PAUSES only: */
65 time_t lastpaused, lastresumed; /* when last paused/resumed, or 0 */
66 long uptopause; /* how much played up to last pause */
67 /* For Disobedience */
68 struct queuelike *ql; /* owning queue */
71 void queue_insert_entry(struct queue_entry *b, struct queue_entry *n);
72 void queue_delete_entry(struct queue_entry *node);
74 int queue_unmarshall(struct queue_entry *q, const char *s,
75 void (*error_handler)(const char *, void *),
77 /* unmarshall UTF-8 string @s@ into @q@ */
79 int queue_unmarshall_vec(struct queue_entry *q, int nvec, char **vec,
80 void (*error_handler)(const char *, void *),
82 /* unmarshall pre-split string @vec@ into @q@ */
84 char *queue_marshall(const struct queue_entry *q);
85 /* marshall @q@ into a UTF-8 string */