From: Andre Noll Date: Thu, 4 Nov 2010 22:54:23 +0000 (+0100) Subject: Change the ->open method of writers to void. X-Git-Tag: v0.4.5~4^2~6 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=d56a8447f418cf9046077e743772a416b6f7b826 Change the ->open method of writers to void. These methods always succeed. Add missing documentation of the public register_writer_node() function while we're at it. --- diff --git a/alsa_write.c b/alsa_write.c index aa772daa..b685e4f7 100644 --- a/alsa_write.c +++ b/alsa_write.c @@ -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) diff --git a/file_write.c b/file_write.c index 7497dfaa..7bc1e437 100644 --- a/file_write.c +++ b/file_write.c @@ -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) diff --git a/oss_write.c b/oss_write.c index 5bc41bcc..2d820d33 100644 --- a/oss_write.c +++ b/oss_write.c @@ -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) diff --git a/osx_write.c b/osx_write.c index b0dfa89b..c2b7b2f4 100644 --- a/osx_write.c +++ b/osx_write.c @@ -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 fd0f4f6b..da6f1e75 100644 --- 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. * diff --git a/write_common.c b/write_common.c index fb7f4775..5bfba37d 100644 --- a/write_common.c +++ b/write_common.c @@ -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);