From e6a35d1c2786c91fb64ac2bbe71bdf7662687007 Mon Sep 17 00:00:00 2001 Message-Id: From: Mark Wooding Date: Mon, 31 Dec 2007 17:25:21 +0000 Subject: [PATCH] player/tracklength directives for native formats are now built in Organization: Straylight/Edgeware From: Richard Kettlewell --- CHANGES | 4 ++-- README | 7 ++++--- debian/etc.disorder.config | 19 ------------------- examples/config.sample.in | 19 ------------------- lib/configuration.c | 36 ++++++++++++++++++++++++++++++++++++ 5 files changed, 42 insertions(+), 43 deletions(-) diff --git a/CHANGES b/CHANGES index 023bd9b..3bc13de 100644 --- 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. -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. diff --git a/README b/README index 9d80eb4..5f1c632 100644 --- 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: - * 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). - * 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. diff --git a/debian/etc.disorder.config b/debian/etc.disorder.config index 2faed13..f7b4991 100644 --- a/debian/etc.disorder.config +++ b/debian/etc.disorder.config @@ -9,25 +9,6 @@ # 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. diff --git a/examples/config.sample.in b/examples/config.sample.in index 2800421..3dc1cee 100644 --- a/examples/config.sample.in +++ b/examples/config.sample.in @@ -2,25 +2,6 @@ # # 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 diff --git a/lib/configuration.c b/lib/configuration.c index 90ae058..3cf276e 100644 --- a/lib/configuration.c +++ b/lib/configuration.c @@ -54,6 +54,7 @@ #include "regsub.h" #include "signame.h" #include "authhash.h" +#include "vector.h" /** @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)); } +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; @@ -1119,12 +1136,21 @@ static const char *const 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; + size_t n; cs.path = ""; 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"); + /* Default stopwords */ 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; } -- [mdw]