- unsigned char *a = 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;
+ PARA_ERROR_LOG("task %p, ret: %d\n", t, t->ret);
+ int ret;
+ unregister_task(t);
+ wng->buf = sit.buf;
+ wng->loaded = &sit.loaded;
+ wng->eof = &sit.eof;
+ ret = wng_open(wng);
+ if (ret < 0) {
+ PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret));
+ exit(EXIT_FAILURE);
+ }
+}
+
+static void cwt_error_handler(struct task *t)
+{
+ PARA_ERROR_LOG("task %p, ret: %d\n", t, t->ret);
+ if (t->ret < 0) {
+ PARA_ERROR_LOG("%s\n", PARA_STRERROR(-t->ret));
+ if (t->ret != -E_NO_WAV_HEADER && t->ret != -E_PRE_EOF)
+ exit(EXIT_FAILURE);
+ if (t->ret == -E_PRE_EOF) {
+ conf.channels_arg = cwt.channels;
+ conf.sample_rate_arg = cwt.sample_rate;
+ }
+ }
+ unregister_task(t);
+ idt.task.pre_select = initial_delay_pre_select;
+ idt.task.private_data = &idt;
+ idt.task.error_handler = idt_error_handler;
+ idt.task.flags = PRE_EOF_IS_ERROR;
+ register_task(&idt.task);
+}
+
+static void stdin_error_handler(struct task *t)
+{
+ unregister_task(t);
+ PARA_INFO_LOG("task %p, ret: %d\n", t, t->ret);
+ if (t->ret < 0)
+ PARA_ERROR_LOG("%s\n", PARA_STRERROR(-t->ret));