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.
29 /** @brief Possible track states */
31 /** @brief Track failed to play */
34 /** @brief Track is a scratch and has not been played yet
36 * Going to become obsolete.
40 /** @brief Could not find a player
42 * Obsolete - nothing sets this any more
46 /** @brief Play completed successfully
48 * Currently this actually means it finished decoding - it might still be
49 * buffered in the speaker, RTP player, sound card, etc.
51 * It might also mean that it's a (short!) track that hasn't been played at
52 * all yet but has been fully decoded ahead of time! (This is very confusing
57 /** @brief Track is playing, but paused */
60 /** @brief Track is playing but the server is quitting */
63 /** @brief Track was randomly chosen and has not been played
65 * This is going to become obsolete eventually; it's equivalent to @ref
66 * playing_unplayed but for tracks with a different origin.
70 /** @brief Track was scratched */
73 /** @brief Track is now playing
75 * This refers to the actual playing track, not something being decoded ahead
80 /** @brief Track has not been played yet */
84 extern const char *const playing_states[];
86 /** @brief Possible track origins
88 * This is a newly introduced field. The aim is ultimately to separate the
89 * concepts of the track origin and its current state. NB that both are
90 * potentially mutable!
93 /** @brief Track was picked at random and then adopted by a user
95 * @c submitter identifies who adopted it. This isn't implemented
100 /** @brief Track was picked by a user
102 * @c submitter identifies who picked it
106 /** @brief Track was picked at random
108 * @c submitter will be NULL
112 /** @brief Track was scheduled by a user
114 * @c submitter identifies who picked it
118 /** @brief Track is a scratch
120 * @c submitter identifies who did the scratching
125 extern const char *const track_origins[];
127 /** @brief One queue/recently played entry
129 * The queue and recently played list form a doubly linked list with the head
130 * and tail referred to from @ref qhead and @ref phead.
133 /** @brief Next entry */
134 struct queue_entry *next;
136 /** @brief Previous entry */
137 struct queue_entry *prev;
139 /** @brief Path to track (a database key) */
142 /** @brief Submitter or NULL
144 * Adopter, if @c origin is @ref origin_adopted.
146 const char *submitter;
148 /** @brief When submitted */
151 /** @brief When played */
154 /** @brief Current state
156 * Currently this includes some origin information but this is being phased
158 enum playing_state state;
160 /** @brief Where track came from */
161 enum track_origin origin;
163 /** @brief Wait status from player
165 * Only valid in certain states (TODO).
169 /** @brief Who scratched this track or NULL */
170 const char *scratched;
172 /** @brief Unique ID string */
175 /** @brief Estimated starting time */
178 /** @brief Type word from plugin (playing/buffered tracks only) */
179 unsigned long type; /* type word from plugin */
181 /** @brief Plugin for this track (playing/buffered tracks only) */
182 const struct plugin *pl;
184 /** @brief Player-specific data (playing/buffered tracks only) */
187 /** @brief How much of track has been played so far (seconds) */
190 /** @brief True if decoder is connected to speaker */
192 /* For DISORDER_PLAYER_PAUSES only: */
194 /** @brief When last paused or 0 */
197 /** @brief When last resumed or 0 */
200 /** @brief How much of track was played up to last pause (seconds) */
203 /** @brief Owning queue (for Disobedience only) */
204 struct queuelike *ql;
207 void queue_insert_entry(struct queue_entry *b, struct queue_entry *n);
208 void queue_delete_entry(struct queue_entry *node);
210 int queue_unmarshall(struct queue_entry *q, const char *s,
211 void (*error_handler)(const char *, void *),
213 /* unmarshall UTF-8 string @s@ into @q@ */
215 int queue_unmarshall_vec(struct queue_entry *q, int nvec, char **vec,
216 void (*error_handler)(const char *, void *),
218 /* unmarshall pre-split string @vec@ into @q@ */
220 char *queue_marshall(const struct queue_entry *q);
221 /* marshall @q@ into a UTF-8 string */