+ t->error = -E_WRITE_EOF;
+ goto err;
+ }
+ cwt->channels = 2;
+ cwt->samplerate = 44100;
+ btr_next_buffer(cwt->btrn, (char **)&a);
+ if (a[0] != 'R' || a[1] != 'I' || a[2] != 'F' || a[3] != 'F') {
+ PARA_NOTICE_LOG("wav header not found\n");
+ cwt->state = CWS_NO_HEADER;
+ sprintf(t->status, "check wav: no header");
+ goto out;
+ }
+ 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);
+ 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);
+ else {
+ if (btr_no_parent(cwt->btrn))
+ t->error = -E_WRITE_EOF;
+ }
+err:
+ if (t->error < 0)
+ btr_remove_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;