X-Git-Url: https://git.distorted.org.uk/~mdw/disorder/blobdiff_plain/763d5e6ad88ef3ba1cd1d7742d060e4f1e54c6b8..132a5a4a47f9dbc7c52ee15234d70258c59ccf8e:/lib/queue.h diff --git a/lib/queue.h b/lib/queue.h index fa9aa81..a084502 100644 --- a/lib/queue.h +++ b/lib/queue.h @@ -1,26 +1,32 @@ /* * This file is part of DisOrder. - * Copyright (C) 2004, 2005, 2006 Richard Kettlewell + * Copyright (C) 2004-2008 Richard Kettlewell * - * This program is free software; you can redistribute it and/or modify + * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA + * along with this program. If not, see . + */ +/** @file lib/queue.h + * @brief Track queues + * + * Used for the queue, the recently played list and the currently playing + * track, both in the server and in clients. */ - #ifndef QUEUE_H #define QUEUE_H +#include + + enum playing_state { playing_failed, /* failed to play */ playing_isscratch, /* this is a scratch track */ @@ -54,6 +60,7 @@ struct queue_entry { const struct plugin *pl; /* plugin that's playing this track */ void *data; /* player data */ long sofar; /* how much played so far */ + int prepared; /* true when connected to speaker */ /* For DISORDER_PLAYER_PAUSES only: */ time_t lastpaused, lastresumed; /* when last paused/resumed, or 0 */ long uptopause; /* how much played up to last pause */ @@ -61,40 +68,8 @@ struct queue_entry { struct queuelike *ql; /* owning queue */ }; -extern struct queue_entry qhead; -/* queue of things yet to be played. the head will be played - * soonest. */ - -extern struct queue_entry phead; -/* things that have been played in the past. the head is the oldest. */ - -void queue_read(void); -/* read the queue in. Calls @fatal@ on error. */ - -void queue_write(void); -/* write the queue out. Calls @fatal@ on error. */ - -void recent_read(void); -/* read the recently played list in. Calls @fatal@ on error. */ - -void recent_write(void); -/* write the recently played list out. Calls @fatal@ on error. */ - -struct queue_entry *queue_add(const char *track, const char *submitter, - int where); -#define WHERE_START 0 /* Add to head of queue */ -#define WHERE_END 1 /* Add to end of queue */ -#define WHERE_BEFORE_RANDOM 2 /* End, or before random track */ -/* add an entry to the queue. Return a pointer to the new entry. */ - -void queue_remove(struct queue_entry *q, const char *who); -/* remove an from the queue */ - -struct queue_entry *queue_find(const char *key); -/* find a track in the queue by name or ID */ - -void queue_played(struct queue_entry *q); -/* add @q@ to the played list */ +void queue_insert_entry(struct queue_entry *b, struct queue_entry *n); +void queue_delete_entry(struct queue_entry *node); int queue_unmarshall(struct queue_entry *q, const char *s, void (*error_handler)(const char *, void *), @@ -109,22 +84,6 @@ int queue_unmarshall_vec(struct queue_entry *q, int nvec, char **vec, char *queue_marshall(const struct queue_entry *q); /* marshall @q@ into a UTF-8 string */ -void queue_id(struct queue_entry *q); -/* give @q@ an ID */ - -int queue_move(struct queue_entry *q, int delta, const char *who); -/* move element @q@ in the queue towards the front (@delta@ > 0) or towards the - * back (@delta@ < 0). The return value is the leftover delta once we've hit - * the end in whichever direction we were going. */ - -void queue_moveafter(struct queue_entry *target, - int nqs, struct queue_entry **qs, const char *who); -/* Move all the elements QS to just after TARGET, or to the head if - * TARGET=0. */ - -void queue_fix_sofar(struct queue_entry *q); -/* Fix up the sofar field for standalone players */ - #endif /* QUEUE_H */ /*