chiark / gitweb /
player/tracklength directives for native formats are now built in
authorRichard Kettlewell <richard@fanticule>
Mon, 31 Dec 2007 17:25:21 +0000 (17:25 +0000)
committerRichard Kettlewell <richard@fanticule>
Mon, 31 Dec 2007 17:25:21 +0000 (17:25 +0000)
CHANGES
README
debian/etc.disorder.config
examples/config.sample.in
lib/configuration.c

diff --git a/CHANGES b/CHANGES
index 023bd9b5345f7f68368e99cad85613be5202a19f..3bc13de755eb9776888c13abf0b356a824eacb43 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -6,8 +6,8 @@ See ChangeLog.d/* for detailed revision history.
 
 Users are now stored in the database rather than a configuration file.
 
 
 Users are now stored in the database rather than a configuration file.
 
-The server now has a built-in list of stopwords, so only additions need
-be mentioned in the configuration file.
+The server now has a built-in list of stopwords and players, so only
+additions to these need be mentioned in the configuration file.
 
 The default inter-track gap is now 0s.
 
 
 The default inter-track gap is now 0s.
 
diff --git a/README b/README
index 9d80eb4a436136635d97dd64f28bbc2187a33584..5f1c6329009109e44afe039476c28cc02bfdeb4c 100644 (file)
--- a/README
+++ b/README
@@ -117,11 +117,12 @@ skip steps 1 to 6 and configure it via debconf.  This is strongly recommended!
       filenames, which you should be sure to get right as recovery from an
       error here can be painful (see BUGS).
    Optionally you may also want to do the following:
       filenames, which you should be sure to get right as recovery from an
       error here can be painful (see BUGS).
    Optionally you may also want to do the following:
-    * add 'player' commands for any file formats not supported natively
+    * add 'player' and 'tracklength' commands for any file formats not
+      supported natively
     * edit the 'scratch' commands to supply scratch sounds (or delete them if
       you don't want any).
     * edit the 'scratch' commands to supply scratch sounds (or delete them if
       you don't want any).
-    * add or remove 'stopword' entries as necessary (these words won't take
-      part in track name searches from the web interface).
+    * add extra 'stopword' entries as necessary (these words won't take part in
+      track name searches from the web interface).
 
    See disorder_config(5) for more details.
 
 
    See disorder_config(5) for more details.
 
index 2faed13b67ce4f7f510081fef3686667512243c3..f7b4991f7d179fba31b5821b7e07910bce072612 100644 (file)
@@ -9,25 +9,6 @@
 # For anything else, you will need to edit this file.
 #
 
 # For anything else, you will need to edit this file.
 #
 
-# Player programs
-#
-# You can add new players for other formats.  For gapless and network
-# play to work, you will need a player that can use libao and DisOrder's
-# special driver - see "LIBAO driver" in disorder_config(5)
-player *.mp3 execraw disorder-decode
-player *.ogg execraw disorder-decode
-player *.wav execraw disorder-decode
-player *.flac execraw disorder-decode
-
-# Track length calculatorsiso-i
-#
-# If you add new formats then can add a plugin module to calculate the
-# length of a track.  See disorder(3) for the interface.
-tracklength *.mp3 disorder-tracklength
-tracklength *.ogg disorder-tracklength
-tracklength *.wav disorder-tracklength
-tracklength *.flac disorder-tracklength
-
 # This line just ensures that the pre-existing root user gets admin
 # rights and can be removed after upgrade to 2.1 or later, or if the
 # initial install is of 2.1 or later.
 # This line just ensures that the pre-existing root user gets admin
 # rights and can be removed after upgrade to 2.1 or later, or if the
 # initial install is of 2.1 or later.
index 280042197b6ad269f3e921685f8ba7ca68537802..3dc1ceee8863972faab6a9594848fbd89ededff8 100644 (file)
@@ -2,25 +2,6 @@
 #
 # You WILL need to edit this from the distributed version!
 
 #
 # You WILL need to edit this from the distributed version!
 
-# Player programs
-#
-# You can add new players for other formats.  For gapless and network
-# play to work, you will need a player that can use libao and DisOrder's
-# special driver - see "LIBAO driver" in disorder_config(5)
-player *.mp3 execraw disorder-decode
-player *.ogg execraw disorder-decode
-player *.wav execraw disorder-decode
-player *.flac execraw disorder-decode
-
-# Track length calculators
-#
-# If you add new formats then can add a plugin module to calculate the
-# length of a track.  See disorder(3) for the interface.
-tracklength *.mp3 disorder-tracklength
-tracklength *.ogg disorder-tracklength
-tracklength *.wav disorder-tracklength
-tracklength *.flac disorder-tracklength
-
 # Use the fs module to list files under /export/mp3.  The encoding
 # is ISO-8859-1.
 collection fs ISO-8859-1 /export/mp3
 # Use the fs module to list files under /export/mp3.  The encoding
 # is ISO-8859-1.
 collection fs ISO-8859-1 /export/mp3
index 90ae0586c51461d63277a41f34a8de8c9cb654ed..3cf276e821d972ef321b89129082cd11cd2a1521 100644 (file)
@@ -54,6 +54,7 @@
 #include "regsub.h"
 #include "signame.h"
 #include "authhash.h"
 #include "regsub.h"
 #include "signame.h"
 #include "authhash.h"
+#include "vector.h"
 
 /** @brief Path to config file 
  *
 
 /** @brief Path to config file 
  *
@@ -999,6 +1000,22 @@ static int config_set(const struct config_state *cs,
          || which->type->set(cs, which, nvec - 1, vec + 1));
 }
 
          || which->type->set(cs, which, nvec - 1, vec + 1));
 }
 
+static int config_set_args(const struct config_state *cs,
+                          const char *which, ...) {
+  va_list ap;
+  struct vector v[1];
+  char *s;
+
+  vector_init(v);
+  vector_append(v, (char *)which);
+  va_start(ap, which);
+  while((s = va_arg(ap, char *)))
+    vector_append(v, s);
+  va_end(ap);
+  vector_terminate(v);
+  return config_set(cs, v->nvec, v->vec);
+}
+
 /** @brief Error callback used by config_include() */
 static void config_error(const char *msg, void *u) {
   const struct config_state *cs = u;
 /** @brief Error callback used by config_include() */
 static void config_error(const char *msg, void *u) {
   const struct config_state *cs = u;
@@ -1119,12 +1136,21 @@ static const char *const default_stopwords[] = {
 };
 #define NDEFAULT_STOPWORDS (sizeof default_stopwords / sizeof *default_stopwords)
 
 };
 #define NDEFAULT_STOPWORDS (sizeof default_stopwords / sizeof *default_stopwords)
 
+static const char *const default_players[] = {
+  "*.ogg",
+  "*.flac",
+  "*.mp3",
+  "*.wav",
+};
+#define NDEFAULT_PLAYERS (sizeof default_players / sizeof *default_players)
+
 /** @brief Make a new default configuration */
 static struct config *config_default(void) {
   struct config *c = xmalloc(sizeof *c);
   const char *logname;
   struct passwd *pw;
   struct config_state cs;
 /** @brief Make a new default configuration */
 static struct config *config_default(void) {
   struct config *c = xmalloc(sizeof *c);
   const char *logname;
   struct passwd *pw;
   struct config_state cs;
+  size_t n;
 
   cs.path = "<internal>";
   cs.line = 0;
 
   cs.path = "<internal>";
   cs.line = 0;
@@ -1162,8 +1188,18 @@ static struct config *config_default(void) {
   c->cookie_login_lifetime = 86400;
   c->cookie_key_lifetime = 86400 * 7;
   c->smtp_server = xstrdup("127.0.0.1");
   c->cookie_login_lifetime = 86400;
   c->cookie_key_lifetime = 86400 * 7;
   c->smtp_server = xstrdup("127.0.0.1");
+  /* Default stopwords */
   if(config_set(&cs, (int)NDEFAULT_STOPWORDS, (char **)default_stopwords))
     exit(1);
   if(config_set(&cs, (int)NDEFAULT_STOPWORDS, (char **)default_stopwords))
     exit(1);
+  /* Default player configuration */
+  for(n = 0; n < NDEFAULT_PLAYERS; ++n) {
+    if(config_set_args(&cs, "player",
+                      default_players[n], "execraw", "disorder-decode", (char *)0))
+      exit(1);
+    if(config_set_args(&cs, "tracklength",
+                      default_players[n], "disorder-tracklength", (char *)0))
+      exit(1);
+  }
   return c;
 }
 
   return c;
 }