X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/blobdiff_plain/05b75f8d50b83e943af3be4071449304d82dbdcd..5dba54ab01bce6ca8a6f1fd64b46cd304501b596:/server/disorder-server.h
diff --git a/server/disorder-server.h b/server/disorder-server.h
index 361bd4f..78b8cfa 100644
--- a/server/disorder-server.h
+++ b/server/disorder-server.h
@@ -1,21 +1,22 @@
/*
* This file is part of DisOrder
- * Copyright (C) 2008 Richard Kettlewell
+ * Copyright (C) 2008-2012 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 server/disorder-server.h
+ * @brief Definitions for server and allied utilities
*/
#ifndef DISORDER_SERVER_H
@@ -32,7 +33,6 @@
#include
#include
#include
-#include
#include
#include
#include
@@ -41,6 +41,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -65,7 +66,6 @@
#include "logfd.h"
#include "mem.h"
#include "mime.h"
-#include "mixer.h"
#include "printf.h"
#include "queue.h"
#include "random.h"
@@ -79,12 +79,15 @@
#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"
@@ -95,8 +98,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
@@ -120,10 +133,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);
@@ -162,13 +178,16 @@ void play(ev_source *ev);
/* try to play something, if playing is enabled and nothing is playing
* already */
+/** @brief Return true if @p represents a true flag */
+int flag_enabled(const char *s);
+
int playing_is_enabled(void);
/* return true iff playing is enabled */
void enable_playing(const char *who, ev_source *ev);
/* enable playing */
-void disable_playing(const char *who);
+void disable_playing(const char *who, ev_source *ev);
/* disable playing. */
int random_is_enabled(void);
@@ -177,7 +196,7 @@ int random_is_enabled(void);
void enable_random(const char *who, ev_source *ev);
/* enable random play */
-void disable_random(const char *who);
+void disable_random(const char *who, ev_source *ev);
/* disable random play */
void scratch(const char *who, const char *id);
@@ -214,12 +233,16 @@ void add_random_track(ev_source *ev);
int server_start(ev_source *ev, int pf,
size_t socklen, const struct sockaddr *sa,
- const char *name);
+ const char *name,
+ int privileged);
/* start listening. Return the fd. */
int server_stop(ev_source *ev, int fd);
/* Stop listening on @fd@ */
+void rtp_request(const struct sockaddr_storage *sa);
+void rtp_request_cancel(const struct sockaddr_storage *sa);
+
extern int volume_left, volume_right; /* last known volume */
extern int wideopen; /* blindly accept all logins */
@@ -320,6 +343,44 @@ 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 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 */
+
+void periodic_mount_check(ev_source *ev_);
+
+/** @brief How often to check for new (or old) filesystems */
+# define MOUNT_CHECK_INTERVAL 5 /* seconds */
+
#endif /* DISORDER_SERVER_H */
/*