X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=write.c;h=c3848946c8b124e1a0ba0f0672fbbf475d6de2a4;hp=def31334e5f89c0efc46055b8b28171a6107f614;hb=885700289d2c7ab64c3bc5a5ab8f6aba14e27632;hpb=651d670fd60c8699ef9fd92a41e1c6dc9c84c683 diff --git a/write.c b/write.c index def31334..c3848946 100644 --- a/write.c +++ b/write.c @@ -134,6 +134,7 @@ static int check_wav_exec(struct btr_node *btrn, const char *cmd, char **result) { struct check_wav_task_btr *cwt = btr_context(btrn); + if (!strcmp(cmd, "samplerate")) { if (cwt->state != CWS_HAVE_HEADER) return -ERRNO_TO_PARA_ERROR(ENAVAIL); @@ -143,7 +144,7 @@ static int check_wav_exec(struct btr_node *btrn, const char *cmd, char **result) if (!strcmp(cmd, "channels")) { if (cwt->state != CWS_HAVE_HEADER) return -ERRNO_TO_PARA_ERROR(ENAVAIL); - *result = make_message("%d", cwt->samplerate); + *result = make_message("%d", cwt->channels); return 1; } return -ERRNO_TO_PARA_ERROR(ENOTSUP); @@ -298,37 +299,35 @@ static int main_btr(struct sched *s) cwt->task.error = 0; register_task(&cwt->task); - wns = para_malloc(conf.writer_given * sizeof(*wns)); + PARA_CRIT_LOG("writers:\n"); - for (i = 0; i < conf.writer_given; i++) { - struct writer_node *wn = para_calloc(sizeof(*wn)); - struct writer *w; - const char *name; - - ret = -E_WRITE_SYNTAX; - wn->conf = check_writer_arg(conf.writer_arg[i], - &wn->writer_num); - if (!wn->conf) + ret = -E_WRITE_SYNTAX; + if (!conf.writer_given) { + i = 0; + wns = para_malloc(sizeof(*wns)); + wns[0] = setup_writer_node(NULL, cwt->btrn); + if (!wns[0]) goto out; - w = writers + wn->writer_num; - name = writer_names[wn->writer_num]; - wn->btrn = btr_new_node(name, cwt->btrn, w->execute, wn); - sprintf(wn->task.status, "%s", name); - w->open(wn); - wn->task.post_select = w->post_select_btr; - wn->task.pre_select = w->pre_select_btr; - register_task(&wn->task); - wns[i] = wn; + } else { + wns = para_malloc(conf.writer_given * sizeof(*wns)); + for (i = 0; i < conf.writer_given; i++) { + PARA_CRIT_LOG("i: %d\n", i); + wns[i] = setup_writer_node(conf.writer_arg[i], + cwt->btrn); + if (!wns[i]) + goto out; + } } - i--; s->default_timeout.tv_sec = 10; s->default_timeout.tv_usec = 50000; ret = schedule(s); out: - for (; i >= 0; i--) { + for (i--; i >= 0; i--) { struct writer_node *wn = wns[i]; - free(wn->conf); + struct writer *w = writers + wn->writer_num; + w->close(wn); + free(wn->conf); /* FIXME should call gengetopt cleanup funtion */ free(wn); } free(wns);