From cebe31278d4990696382196884fa42d897b15a3f Mon Sep 17 00:00:00 2001 Message-Id: From: Mark Wooding Date: Sat, 12 Apr 2008 12:22:21 +0100 Subject: [PATCH] New 'replay_min' directive defines lower bound on interval between a track being played and later picked at random. Fixes a long-standing TODO... Organization: Straylight/Edgeware From: Richard Kettlewell --- CHANGES | 9 +++++++++ doc/disorder_config.5.in | 6 ++++++ lib/configuration.c | 2 ++ lib/configuration.h | 3 +++ server/choose.c | 2 +- 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 803358c..f9c74b9 100644 --- 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. diff --git a/doc/disorder_config.5.in b/doc/disorder_config.5.in index 9027fb1..7288734 100644 --- a/doc/disorder_config.5.in +++ b/doc/disorder_config.5.in @@ -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: diff --git a/lib/configuration.c b/lib/configuration.c index 869f895..b93e1e9 100644 --- a/lib/configuration.c +++ b/lib/configuration.c @@ -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; diff --git a/lib/configuration.h b/lib/configuration.h index 9388568..de25197 100644 --- a/lib/configuration.h +++ b/lib/configuration.h @@ -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 */ diff --git a/server/choose.c b/server/choose.c index d5bc52e..6de1b45 100644 --- a/server/choose.c +++ b/server/choose.c @@ -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; } -- [mdw]