chiark / gitweb /
Doxygen-clean
[disorder] / lib / queue.h
CommitLineData
460b9539 1/*
2 * This file is part of DisOrder.
5aff007d 3 * Copyright (C) 2004-2008 Richard Kettlewell
460b9539 4 *
e7eb3a27 5 * This program is free software: you can redistribute it and/or modify
460b9539 6 * it under the terms of the GNU General Public License as published by
e7eb3a27 7 * the Free Software Foundation, either version 3 of the License, or
460b9539 8 * (at your option) any later version.
e7eb3a27
RK
9 *
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.
14 *
460b9539 15 * You should have received a copy of the GNU General Public License
e7eb3a27 16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
460b9539 17 */
18
19#ifndef QUEUE_H
20#define QUEUE_H
21
05b75f8d
RK
22#include <time.h>
23
24
460b9539 25enum playing_state {
26 playing_failed, /* failed to play */
27 playing_isscratch, /* this is a scratch track */
28 playing_no_player, /* couldn't find a player */
29 playing_ok, /* played OK */
30 playing_paused, /* started but paused */
31 playing_quitting, /* interrupt because server quit */
32 playing_random, /* unplayed randomly chosen track */
33 playing_scratched, /* was scratched */
34 playing_started, /* started to play */
35 playing_unplayed /* haven't played this track yet */
36};
37
38extern const char *playing_states[];
39
40/* queue entries form a circular doubly-linked list */
41struct queue_entry {
42 struct queue_entry *next; /* next entry */
43 struct queue_entry *prev; /* previous entry */
44 const char *track; /* path to track */
45 const char *submitter; /* name of submitter */
46 time_t when; /* time submitted */
47 time_t played; /* when played */
48 enum playing_state state; /* state */
49 long wstat; /* wait status */
50 const char *scratched; /* scratched by */
51 const char *id; /* queue entry ID */
52 time_t expected; /* expected started time */
53 /* for playing or soon-to-be-played tracks only: */
54 unsigned long type; /* type word from plugin */
55 const struct plugin *pl; /* plugin that's playing this track */
56 void *data; /* player data */
57 long sofar; /* how much played so far */
66bb2e02 58 int prepared; /* true when connected to speaker */
460b9539 59 /* For DISORDER_PLAYER_PAUSES only: */
60 time_t lastpaused, lastresumed; /* when last paused/resumed, or 0 */
61 long uptopause; /* how much played up to last pause */
62 /* For Disobedience */
63 struct queuelike *ql; /* owning queue */
64};
65
05b75f8d
RK
66void queue_insert_entry(struct queue_entry *b, struct queue_entry *n);
67void queue_delete_entry(struct queue_entry *node);
68
460b9539 69int queue_unmarshall(struct queue_entry *q, const char *s,
70 void (*error_handler)(const char *, void *),
71 void *u);
72/* unmarshall UTF-8 string @s@ into @q@ */
73
74int queue_unmarshall_vec(struct queue_entry *q, int nvec, char **vec,
75 void (*error_handler)(const char *, void *),
76 void *u);
77/* unmarshall pre-split string @vec@ into @q@ */
78
79char *queue_marshall(const struct queue_entry *q);
80/* marshall @q@ into a UTF-8 string */
81
460b9539 82#endif /* QUEUE_H */
83
84/*
85Local Variables:
86c-basic-offset:2
87comment-column:40
88fill-column:79
89End:
90*/