- unsigned char *a = (unsigned char*)audiobuf;
- if (a[0] != 'R' || a[1] != 'I' || a[2] != 'F' || a[3] != 'F')
- return WAV_HEADER_LEN;
- conf.channels_arg = (unsigned) a[22];
- conf.sample_rate_arg = a[24] + (a[25] << 8) + (a[26] << 16) + (a[27] << 24);
- return 0;
+ struct writer_node_group *g = t->private_data;
+
+ PARA_INFO_LOG("%s\n", PARA_STRERROR(-t->ret));
+ unregister_task(t);
+ wng_close(g);
+ wng_destroy(g);
+}
+
+
+static void idt_event_handler(struct task *t)
+{
+ int ret;
+
+ PARA_INFO_LOG("%s\n", PARA_STRERROR(-t->ret));
+ unregister_task(t);
+ wng->buf = sit.buf;
+ wng->loaded = &sit.loaded;
+ wng->input_eof = &sit.eof;
+ wng->task.event_handler = wng_event_handler;
+ ret = wng_open(wng);
+ if (ret < 0) {
+ PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret));
+ exit(EXIT_FAILURE);
+ }
+}
+
+static void cwt_event_handler(struct task *t)
+{
+ if (t->ret != -E_NO_WAV_HEADER && t->ret != -E_WAV_HEADER_SUCCESS) {
+ PARA_ERROR_LOG("%s\n", PARA_STRERROR(-t->ret));
+ exit(EXIT_FAILURE);
+ }
+ PARA_INFO_LOG("%s\n", PARA_STRERROR(-t->ret));
+ unregister_task(t);
+// if (t->ret == -E_WAV_HEADER_SUCCESS) {
+// conf.channels_arg = cwt.channels;
+// conf.sample_rate_arg = cwt.sample_rate;
+// }
+ idt.task.pre_select = initial_delay_pre_select;
+ idt.task.private_data = &idt;
+ idt.task.event_handler = idt_event_handler;
+ sprintf(idt.task.status, "initial_delay");
+ register_task(&idt.task);