chiark / gitweb /
Improve scratch handling to cope better with slow decoding. The
[disorder] / server / disorder-server.h
index c3a0e6913c8a4fcddcb174b2ac275fb5dba7e8c1..e8f4dabd17c6aea1a3df02eb623766a0bbe82d7e 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * This file is part of DisOrder
- * Copyright (C) 2008 Richard Kettlewell
+ * Copyright (C) 2008, 2009 Richard Kettlewell
  *
  * 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
@@ -15,6 +15,9 @@
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
+/** @file server/disorder-server.h
+ * @brief Definitions for server and allied utilities
+ */
 
 #ifndef DISORDER_SERVER_H
 #define DISORDER_SERVER_H
@@ -39,6 +42,7 @@
 #include <sys/time.h>
 #include <sys/types.h>
 #include <sys/un.h>
+#include <sys/resource.h>
 #include <syslog.h>
 #include <time.h>
 #include <unistd.h>
@@ -63,7 +67,6 @@
 #include "logfd.h"
 #include "mem.h"
 #include "mime.h"
-#include "mixer.h"
 #include "printf.h"
 #include "queue.h"
 #include "random.h"
 #include "trackdb-int.h"
 #include "trackdb.h"
 #include "trackname.h"
+#include "uaudio.h"
 #include "unicode.h"
 #include "user.h"
 #include "vector.h"
 #include "version.h"
 #include "wstat.h"
 
+extern const struct uaudio *api;
+
 void daemonize(const char *tag, int fac, const char *pidfile);
 /* Go into background.  Send stdout/stderr to syslog.
  * If @pri@ is non-null, it should be "facility.level"
@@ -93,8 +99,18 @@ void daemonize(const char *tag, int fac, const char *pidfile);
 void quit(ev_source *ev) attribute((noreturn));
 /* terminate the daemon */
 
-int reconfigure(ev_source *ev, int reload);
-/* reconfigure.  If @reload@ is nonzero, update the configuration. */
+int reconfigure(ev_source *ev, unsigned flags);
+/* reconfigure */
+
+void reset_sockets(ev_source *ev);
+
+/** @brief Set when starting server */
+#define RECONFIGURE_FIRST 0x0001
+
+/** @brief Set when reloading after SIGHUP etc */
+#define RECONFIGURE_RELOADING 0x0002
+
+void dbparams_check(void);
 
 extern struct queue_entry qhead;
 /* queue of things yet to be played.  the head will be played
@@ -118,10 +134,13 @@ 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);
+                             int where, const char *target,
+                              enum track_origin origin);
 #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 */
+#define WHERE_AFTER 3                   /* After the target */
+#define WHERE_NOWHERE 4                 /* Don't add to queue at all */
 /* add an entry to the queue.  Return a pointer to the new entry. */
 
 void queue_remove(struct queue_entry *q, const char *who);
@@ -318,6 +337,41 @@ int play_pause(const struct plugin *pl, long *playedp, void *data);
 void play_resume(const struct plugin *pl, void *data);
 /* Resume track. */
 
+/* background process support *************************************************/
+
+/** @brief Child process parameters */
+struct pbgc_params {
+  /** @brief Length of player command */
+  int argc;
+  /** @brief Player command */
+  const char **argv;
+  /** @brief Device to wait for or NULL */
+  const char *waitdevice;
+  /** @brief Raw track name */
+  const char *rawpath;
+};
+
+/** @brief Callback to play or prepare a track
+ * @param q Track to play or decode
+ * @param bgdata User data pointer
+ * @return Exit code
+ */
+typedef int play_background_child_fn(struct queue_entry *q,
+                                     const struct pbgc_params *params,
+                                     void *bgdata);
+
+int play_background(ev_source *ev,
+                    const struct stringlist *player,
+                    struct queue_entry *q,
+                    play_background_child_fn *child,
+                    void *bgdata);
+
+/* Return values from start(),  prepare() and play_background() */
+
+#define START_OK 0        /**< @brief Succeeded. */
+#define START_HARDFAIL 1   /**< @brief Track is broken. */
+#define START_SOFTFAIL 2   /**< @brief Track OK, system (temporarily?) broken */
+
 #endif /* DISORDER_SERVER_H */
 
 /*