libtests/t-wstat
libtests/t-macros
libtests/t-cgi
+libtests/t-configuration
doc/*.tmpl
doc/disorder_templates.5
oc/disorder_templates.5.html
/*
* This file is part of DisOrder.
- * Copyright (C) 2004-2009 Richard Kettlewell
+ * Copyright (C) 2004-2010 Richard Kettlewell
* Portions copyright (C) 2007 Mark Wooding
*
* This program is free software: you can redistribute it and/or modify
{ C(checkpoint_min), &type_integer, validate_non_negative },
{ C(collection), &type_collections, validate_any },
{ C(connect), &type_netaddress, validate_destaddr },
- { C(cookie_login_lifetime), &type_integer, validate_positive },
{ C(cookie_key_lifetime), &type_integer, validate_positive },
+ { C(cookie_login_lifetime), &type_integer, validate_positive },
{ C(dbversion), &type_integer, validate_positive },
{ C(default_rights), &type_rights, validate_any },
{ C(device), &type_string, validate_any },
{ 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 },
{ C(remote_userman), &type_boolean, validate_any },
+ { C(replay_min), &type_integer, validate_non_negative },
{ C2(restrict, restrictions), &type_restrict, validate_any },
{ C(rtp_delay_threshold), &type_integer, validate_positive },
{ C(sample_format), &type_sample_format, validate_sample_format },
return 0;
}
+/** @brief Verify configuration table.
+ * @return The number of problems found
+*/
+int config_verify(void) {
+ int fails = 0;
+ for(size_t n = 1; n < sizeof conf / sizeof *conf; ++n)
+ if(strcmp(conf[n-1].name, conf[n].name) >= 0) {
+ fprintf(stderr, "%s >= %s\n", conf[n-1].name, conf[n].name);
+ ++fails;
+ }
+ return fails;
+}
+
/*
Local Variables:
c-basic-offset:2
/*
* This file is part of DisOrder.
- * Copyright (C) 2004-2009 Richard Kettlewell
+ * Copyright (C) 2004-2010 Richard Kettlewell
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
char *config_private(void);
/* get the private config file */
+int config_verify(void);
+
extern char *configfile;
extern int config_per_user;
/** @brief How much of track has been played so far (seconds) */
long sofar;
+ /** @brief True if track preparation is underway
+ *
+ * This is set when a decoder has been started and is expected to connect to
+ * the speaker, but the speaker has not sent as @ref SM_ARRIVED message back
+ * yet. */
+ int preparing;
+
/** @brief True if decoder is connected to speaker
*
* This is not a @ref playing_state for a couple of reasons
* - @ref SM_FINISHED
* - @ref SM_PLAYING
* - @ref SM_UNKNOWN
+ * - @ref SM_ARRIVED
*/
int type;
/** @brief Cancelled track @c id which wasn't playing */
#define SM_STILLBORN 133
+/** @brief A connection for track @c id arrived */
+#define SM_ARRIVED 134
+
void speaker_send(int fd, const struct speaker_message *sm);
/* Send a message. */
t-cookies t-dateparse t-event t-filepart t-hash t-heap t-hex \
t-kvp t-mime t-printf t-regsub t-selection t-signame t-sink \
t-split t-syscalls t-trackname t-unicode t-url t-utf8 t-vector \
- t-words t-wstat t-macros t-cgi t-eventdist t-resample
+ t-words t-wstat t-macros t-cgi t-eventdist t-resample \
+ t-configuration
noinst_PROGRAMS=$(TESTS)
t_eventdist_SOURCES=t-eventdist.c test.c test.h
t_resample_SOURCES=t-resample.c test.c test.h
t_resample_LDFLAGS=$(LIBSAMPLERATE)
+t_configuration_SOURCES=t-configuration.c test.c test.h
+t_configuration_LDFLAGS=$(LIBGCRYPT)
check-report: before-check check make-coverage-reports
before-check:
--- /dev/null
+/*
+ * This file is part of DisOrder.
+ * Copyright (C) 2010 Richard Kettlewell
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#include "test.h"
+
+static void test_configuration(void) {
+ insist(config_verify() == 0);
+}
+
+TEST(configuration);
+
+/*
+Local Variables:
+c-basic-offset:2
+comment-column:40
+fill-column:79
+indent-tabs-mode:nil
+End:
+*/
D(("SM_PLAYING %s %ld", sm.id, sm.data));
playing->sofar = sm.data;
break;
+ case SM_ARRIVED: {
+ /* track ID is now prepared */
+ struct queue_entry *q;
+ for(q = qhead.next; q != &qhead && strcmp(q->id, sm.id); q = q->next)
+ ;
+ if(q && q->preparing) {
+ q->preparing = 0;
+ q->prepared = 1;
+ /* We might be waiting to play the now-prepared track */
+ play(ev);
+ }
+ break;
+ }
default:
disorder_error(0, "unknown speaker message type %d", sm.type);
}
if(q->pid >= 0)
return START_OK;
/* If the track is already prepared, do nothing */
- if(q->prepared)
+ if(q->prepared || q->preparing)
return START_OK;
/* Find the player plugin */
if(!(player = find_player(q)) < 0)
q->type = play_get_type(q->pl);
if((q->type & DISORDER_PLAYER_TYPEMASK) != DISORDER_PLAYER_RAW)
return START_OK; /* Not a raw player */
- const int rc = play_background(ev, player, q, prepare_child, NULL);
+ int rc = play_background(ev, player, q, prepare_child, NULL);
if(rc == START_OK) {
ev_child(ev, q->pid, 0, player_finished, q);
- q->prepared = 1;
+ q->preparing = 1;
+ /* Actually the track is still "in flight" */
+ rc = START_SOFTFAIL;
}
return rc;
}
nonblock(fd);
t->fd = fd; /* yay */
}
+ /* Notify the server that the connection arrived */
+ sm.type = SM_ARRIVED;
+ strcpy(sm.id, id);
+ speaker_send(1, &sm);
}
} else
disorder_error(errno, "accept");