- 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);
+ int i, n, ret, writer_given = OPT_GIVEN(WRITER, lpr);
+ struct btr_node *cw_btrn;
+ struct writer_node *wns;
+ static struct sched s;
+ struct wav_params wp;
+ struct write_task wt;
+
+ sit.btrn = btr_new_node(&(struct btr_node_description)
+ EMBRACE(.name = "stdin"));
+ stdin_task_register(&sit, &s);
+
+ LLS_COPY_WAV_PARMS(&wp, LSG_WRITE_PARA_WRITE, lpr);
+ wt.cwc = check_wav_init(sit.btrn, NULL, &wp, &cw_btrn);
+ wt.task = task_register(&(struct task_info) {
+ .name = "write",
+ .pre_select = write_pre_select,
+ .post_select = write_post_select,
+ .context = &wt,
+ }, &s);
+
+ n = writer_given? writer_given : 1;
+ wns = para_calloc(n * sizeof(*wns));
+ for (i = 0; i < n; i++) {
+ const char *arg = i < writer_given?
+ lls_string_val(i, OPT_RESULT(WRITER, lpr)) : NULL;
+ wns[i].wid = check_writer_arg_or_die(arg, &wns[i].lpr);
+ register_writer_node(wns + i, cw_btrn, &s);