+ PARA_INFO_LOG("found wav header\n");
+ cwt->state = CWS_HAVE_HEADER;
+ sprintf(t->status, "check wav: have header");
+ cwt->channels = (unsigned) a[22];
+ cwt->samplerate = a[24] + (a[25] << 8) + (a[26] << 16) + (a[27] << 24);
+consume:
+ PARA_INFO_LOG("channels: %d, sample rate: %d\n", cwt->channels, cwt->samplerate);
+ btr_consume(cwt->btrn, WAV_HEADER_LEN);
+out:
+ if (sz) {
+ btr_pushdown(cwt->btrn);
+ s->timeout.tv_sec = 0;
+ s->timeout.tv_usec = 1;
+ } else {
+ if (btr_no_parent(cwt->btrn))
+ t->error = -E_WRITE_EOF;
+ }
+err:
+ if (t->error < 0)
+ btr_del_node(cwt->btrn);
+}
+
+static void initial_delay_pre_select(struct sched *s, struct task *t)
+{
+ struct initial_delay_task *idt = container_of(t, struct initial_delay_task, task);
+ struct timeval diff;
+
+ if (!idt->start_time.tv_sec && !idt->start_time.tv_usec) {
+ t->error = -E_NO_DELAY;
+ goto register_check_wav;
+ }
+ if (tv_diff(now, &idt->start_time, &diff) > 0) {
+ t->error = -E_DELAY_TIMEOUT;
+ goto register_check_wav;
+ }
+ if (tv_diff(&s->timeout , &diff, NULL) > 0)
+ s->timeout = diff;
+ return;
+register_check_wav:
+ register_task(&the_check_wav_task.task);
+ s->timeout.tv_sec = 0;
+ s->timeout.tv_usec = 1;
+}
+
+static int loglevel;
+INIT_STDERR_LOGGING(loglevel)
+
+static struct writer_node_group *check_args(void)
+{
+ int i, ret = -E_WRITE_SYNTAX;
+ struct writer_node_group *g = NULL;
+ struct initial_delay_task *idt = &the_initial_delay_task;
+
+ loglevel = get_loglevel_by_name(conf.loglevel_arg);