Switch audiod over to the buffer tree API.
[paraslash.git] / write_common.c
index 9af8d68..8c33b39 100644 (file)
@@ -237,6 +237,21 @@ struct writer_node_group *setup_default_wng(void)
        return wng;
 }
 
+void register_writer_node(struct writer_node *wn, struct btr_node *parent)
+{
+       struct writer *w = writers + wn->writer_num;
+       char *name = make_message("%s writer", writer_names[wn->writer_num]);
+       int ret;
+
+       wn->btrn = btr_new_node(name, parent, w->execute, wn);
+       strcpy(wn->task.status, name);
+       free(name);
+       ret = w->open(wn);
+       wn->task.post_select = w->post_select_btr;
+       wn->task.pre_select = w->pre_select_btr;
+       register_task(&wn->task);
+}
+
 /**
  * Setup a writer node with the default writer.
  *
@@ -253,32 +268,19 @@ struct writer_node_group *setup_default_wng(void)
  *
  * \return A pointer to the allocated writer node group.
  */
-struct writer_node *setup_writer_node(const char *arg, struct btr_node *parent)
+int setup_writer_node(const char *arg, struct btr_node *parent,
+               struct writer_node *wn)
 {
-       struct writer_node *wn = para_calloc(sizeof(*wn));
-       struct writer *w;
-       char *name;
-
        if (arg)
                wn->conf = check_writer_arg(arg, &wn->writer_num);
        else {
                wn->writer_num = DEFAULT_WRITER;
                wn->conf = writers[DEFAULT_WRITER].parse_config("");
        }
-       if (!wn->conf) {
-               free(wn);
-               return NULL;
-       }
-       w = writers + wn->writer_num;
-       name = make_message("%s writer", writer_names[wn->writer_num]);
-       wn->btrn = btr_new_node(name, parent, w->execute, wn);
-       strcpy(wn->task.status, name);
-       free(name);
-       w->open(wn);
-       wn->task.post_select = w->post_select_btr;
-       wn->task.pre_select = w->pre_select_btr;
-       register_task(&wn->task);
-       return wn;
+       if (!wn->conf)
+               return -E_WRITE_COMMON_SYNTAX;
+       register_writer_node(wn, parent);
+       return 1;
 }