chiark / gitweb /
New 'replay_min' directive defines lower bound on interval between a
authorRichard Kettlewell <rjk@greenend.org.uk>
Sat, 12 Apr 2008 11:22:21 +0000 (12:22 +0100)
committerRichard Kettlewell <rjk@greenend.org.uk>
Sat, 12 Apr 2008 11:22:21 +0000 (12:22 +0100)
track being played and later picked at random.  Fixes a long-standing
TODO...

CHANGES
doc/disorder_config.5.in
lib/configuration.c
lib/configuration.h
server/choose.c

diff --git a/CHANGES b/CHANGES
index 803358c8601aac576d7dd056b017c1ecacc59cfb..f9c74b9a5790ea48eb7ca364a627bafd3ed109b9 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -5,6 +5,15 @@
 The 'gap' directive will no longer work.  It could be restored if there
 is real demand.
 
+*** Random Track Choice
+
+This has been completely rewritten to support new features:
+   - tracks in the recently-played list or in the queue are no longer
+     eligible for random choice
+   - there is a new configuration item replay_min defining the minimum
+     time before a played track can be picked at random.  The default is
+     8 hours (which matches the earlier behaviour).
+
 * Changes up to version 3.0
 
 Important!  See README.upgrades when upgrading.
index 9027fb1849472b8ee069030b9157de7c0d2afd9c..72887341015eb9011534f0559c7839031450ad44 100644 (file)
@@ -584,6 +584,12 @@ The default is 10.
 The minimum number of seconds that must elapse between password reminders.
 The default is 600, i.e. 10 minutes.
 .TP
+.B replay_min \fISECONDS\fR
+The minimum number of seconds that must elapse after a track has been played
+before it can be picked at random.  The default is 8 hours.  If this is set to
+0 then there is no limit, though current \fBdisorder-choose\fR will not pick
+anything currently listed in the recently-played list.
+.TP
 .B sample_format \fIBITS\fB/\fIRATE\fB/\fICHANNELS
 Describes the sample format expected by the \fBspeaker_command\fR (below).
 The components of the format specification are as follows:
index 869f8957c79f49ff731c303f4dc866ee81385bc2..b93e1e9ea16217b06ff9b21cb70c5c1a4486a3f1 100644 (file)
@@ -957,6 +957,7 @@ static const struct conf conf[] = {
   { C(plugins),          &type_string_accum,     validate_isdir },
   { C(prefsync),         &type_integer,          validate_positive },
   { C(queue_pad),        &type_integer,          validate_positive },
+  { C(replay_min),       &type_integer,          validate_non_negative },
   { C(refresh),          &type_integer,          validate_positive },
   { C(reminder_interval), &type_integer,         validate_positive },
   { C2(restrict, restrictions),         &type_restrict,         validate_any },
@@ -1178,6 +1179,7 @@ static struct config *config_default(void) {
   c->sample_format.channels = 2;
   c->sample_format.endian = ENDIAN_NATIVE;
   c->queue_pad = 10;
+  c->replay_min = 8 * 3600;
   c->api = -1;
   c->multicast_ttl = 1;
   c->multicast_loop = 1;
index 93885689f8cfee7270f4a574fde985634edb5e65..de251970855cc103316b2f503bf192e0dc6528ff 100644 (file)
@@ -226,6 +226,9 @@ struct config {
   /** @brief Target queue length */
   long queue_pad;
 
+  /** @brief Minimum time between a track being played again */
+  long replay_min;
+  
   struct namepartlist namepart;                /* transformations */
 
   /** @brief Termination signal for subprocesses */
index d5bc52ebe9e63e9ac9d19af700bda8665cf723e3..6de1b45d9faa718bd37bf680ccbeb64b427c4137 100644 (file)
@@ -153,7 +153,7 @@ static unsigned long compute_weight(const char *track,
   if((s = kvp_get(prefs, "played_time"))) {
     last = atoll(s);
     now = time(0);
-    if(now < last + 8 * 3600)       /* TODO configurable */
+    if(now < last + config->replay_min)
       return 0;
   }