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 */
36 * Formerly denoted an unplayed scratch. This is now indicated by @p
37 * playing_unplayed and @p origin_scratch.
41 /** @brief Could not find a player
43 * Obsolete - nothing sets this any more
47 /** @brief Play completed successfully
49 * Currently this actually means it finished decoding - it might still be
50 * buffered in the speaker, RTP player, sound card, etc.
52 * It might also mean that it's a (short!) track that hasn't been played at
53 * all yet but has been fully decoded ahead of time! (This is very confusing
58 /** @brief Track is playing, but paused */
61 /** @brief Track is playing but the server is quitting */
66 * Formerly this meant a track that was picked at random and has not yet been
67 * played. This situation is now indicated by @p playing_unplayed and @p
68 * origin_random (or @p origin_adopted).
72 /** @brief Track was scratched */
75 /** @brief Track is now playing
77 * This refers to the actual playing track, not something being decoded ahead
82 /** @brief Track has not been played yet */
86 extern const char *const playing_states[];
88 /** @brief Possible track origins
90 * This is a newly introduced field. The aim is ultimately to separate the
91 * concepts of the track origin and its current state. NB that both are
92 * potentially mutable!
95 /** @brief Track was picked at random and then adopted by a user
97 * @c submitter identifies who adopted it. This isn't implemented
102 /** @brief Track was picked by a user
104 * @c submitter identifies who picked it
108 /** @brief Track was picked at random
110 * @c submitter will be NULL
114 /** @brief Track was scheduled by a user
116 * @c submitter identifies who picked it
120 /** @brief Track is a scratch
122 * @c submitter identifies who did the scratching
127 extern const char *const track_origins[];
129 /** @brief One queue/recently played entry
131 * The queue and recently played list form a doubly linked list with the head
132 * and tail referred to from @ref qhead and @ref phead.
135 /** @brief Next entry */
136 struct queue_entry *next;
138 /** @brief Previous entry */
139 struct queue_entry *prev;
141 /** @brief Path to track (a database key) */
144 /** @brief Submitter or NULL
146 * Adopter, if @c origin is @ref origin_adopted.
148 const char *submitter;
150 /** @brief When submitted */
153 /** @brief When played */
156 /** @brief Current state
158 * Currently this includes some origin information but this is being phased
160 enum playing_state state;
162 /** @brief Where track came from */
163 enum track_origin origin;
165 /** @brief Wait status from player
167 * Only valid in certain states (TODO).
171 /** @brief Who scratched this track or NULL */
172 const char *scratched;
174 /** @brief Unique ID string */
177 /** @brief Estimated starting time */
180 /** @brief Type word from plugin (playing/buffered tracks only) */
181 unsigned long type; /* type word from plugin */
183 /** @brief Plugin for this track (playing/buffered tracks only) */
184 const struct plugin *pl;
186 /** @brief Player-specific data (playing/buffered tracks only) */
189 /** @brief How much of track has been played so far (seconds) */
192 /** @brief True if decoder is connected to speaker */
194 /* For DISORDER_PLAYER_PAUSES only: */
196 /** @brief When last paused or 0 */
199 /** @brief When last resumed or 0 */
202 /** @brief How much of track was played up to last pause (seconds) */
205 /** @brief Owning queue (for Disobedience only) */
206 struct queuelike *ql;
209 void queue_insert_entry(struct queue_entry *b, struct queue_entry *n);
210 void queue_delete_entry(struct queue_entry *node);
212 int queue_unmarshall(struct queue_entry *q, const char *s,
213 void (*error_handler)(const char *, void *),
215 /* unmarshall UTF-8 string @s@ into @q@ */
217 int queue_unmarshall_vec(struct queue_entry *q, int nvec, char **vec,
218 void (*error_handler)(const char *, void *),
220 /* unmarshall pre-split string @vec@ into @q@ */
222 char *queue_marshall(const struct queue_entry *q);
223 /* marshall @q@ into a UTF-8 string */