Change the ->open method of writers to void.
authorAndre Noll <maan@systemlinux.org>
Thu, 4 Nov 2010 22:54:23 +0000 (23:54 +0100)
committerAndre Noll <maan@systemlinux.org>
Tue, 23 Nov 2010 16:42:05 +0000 (17:42 +0100)
These methods always succeed. Add missing documentation of the public
register_writer_node() function while we're at it.

alsa_write.c
file_write.c
oss_write.c
osx_write.c
write.h
write_common.c

index aa772da..b685e4f 100644 (file)
@@ -143,10 +143,9 @@ static int alsa_init(struct private_alsa_write_data *pad,
 }
 
 /* Open an instance of the alsa writer. */
-static int alsa_open(struct writer_node *wn)
+static void alsa_open(struct writer_node *wn)
 {
        wn->private_data = para_calloc(sizeof(struct private_alsa_write_data));
-       return 1;
 }
 
 static void alsa_write_pre_select(struct sched *s, struct task *t)
index 7497dfa..7bc1e43 100644 (file)
@@ -50,13 +50,12 @@ __must_check __malloc static char *random_filename(void)
        return result;
 }
 
-static int file_write_open(struct writer_node *wn)
+static void file_write_open(struct writer_node *wn)
 {
        struct private_file_write_data *pfwd = para_calloc(sizeof(*pfwd));
 
        wn->private_data = pfwd;
        pfwd->fd = -1;
-       return 0;
 }
 
 static int prepare_output_file(struct writer_node *wn)
index 5bc41bc..2d820d3 100644 (file)
@@ -199,14 +199,12 @@ out:
                btr_remove_node(btrn);
 }
 
-static int oss_open(struct writer_node *wn)
+static void oss_open(struct writer_node *wn)
 {
-       struct private_oss_write_data *powd;
+       struct private_oss_write_data *powd = para_calloc(sizeof(*powd));
 
-       powd = para_calloc(sizeof(*powd));
-       wn->private_data = powd;
        powd->fd = -1;
-       return 1;
+       wn->private_data = powd;
 }
 
 __malloc static void *oss_parse_config_or_die(const char *options)
index b0dfa89..c2b7b2f 100644 (file)
@@ -187,13 +187,12 @@ static OSStatus osx_callback(void * inClientData,
 #define ENDIAN_FLAGS 0
 #endif
 
-static int osx_write_open(struct writer_node *wn)
+static void osx_write_open(struct writer_node *wn)
 {
        struct private_osx_write_data *powd = para_calloc(sizeof(*powd));
 
        wn->private_data = powd;
        init_buffers(wn);
-       return 0;
 }
 
 static int core_audio_init(struct writer_node *wn)
diff --git a/write.h b/write.h
index fd0f4f6..da6f1e7 100644 (file)
--- a/write.h
+++ b/write.h
@@ -53,11 +53,13 @@ struct writer {
        /**
         * Open one instance of this writer.
         *
-        * This function should perform any work necessary to write the incoming
-        * stream. To this aim, it may allocate its private data structure and store
-        * a pointer to that structure via the given writer_node parameter.
+        * Perform any preparations needed to write the incoming stream.
+        * Usually this function just allocates its private data structure and
+        * stores a pointer to that structure in the ->private data of the
+        * given parameter. This function must either succeed or terminate the
+        * process.
         */
-       int (*open)(struct writer_node *);
+       void (*open)(struct writer_node *);
        /**
         * Prepare the fd sets for select.
         *
index fb7f477..5bfba37 100644 (file)
@@ -73,18 +73,26 @@ void *check_writer_arg(const char *wa, int *writer_num)
        return NULL;
 }
 
+/**
+ * Open a writer node and register the corresponding task.
+ *
+ * \param wn The writer node to open.
+ * \param parent The parent btr node (the source for the writer node).
+ *
+ * The configuration of the writer node stored in \p wn->conf must be
+ * initialized before this function may be called.
+ */
 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(&(struct btr_node_description)
                EMBRACE(.name = name, .parent = parent,
                .handler = w->execute, .context = wn));
        strcpy(wn->task.status, name);
        free(name);
-       ret = w->open(wn);
+       w->open(wn);
        wn->task.post_select = w->post_select;
        wn->task.pre_select = w->pre_select;
        register_task(&wn->task);