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 803358c..f9c74b9 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 9027fb1..7288734 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 869f895..b93e1e9 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 9388568..de25197 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 d5bc52e..6de1b45 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;
   }