+
+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;
+ wng->channels = &cwt.channels;
+ wng->samplerate = &cwt.samplerate;
+ 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);
+}
+
+/**
+ * para_write's main function
+ *
+ * \param argc the usual argument counter
+ * \param argv the usual argument vector
+ *
+ * It registers the stdin task, the check_wav_task, the task for initial delay
+ * and all tasks for actually writing out the stream.
+ *
+ * \return \p EXIT_SUCCESS or EXIT_FAILURE
+ */