From a5048b7349e87f323b4de87da44c564c619fc605 Mon Sep 17 00:00:00 2001
From: Andre <maan@ensslin.(none)>
Date: Tue, 6 Jun 2006 02:23:10 +0200
Subject: [PATCH] struct writer: kill unused write_pointer and update
 documentation

The file writer even had an implementation of the unused write function.
---
 file_writer.c | 10 ----------
 write.h       | 26 +++++++++++++++++++-------
 2 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/file_writer.c b/file_writer.c
index 1ea95032..e90647d2 100644
--- a/file_writer.c
+++ b/file_writer.c
@@ -59,15 +59,6 @@ static int file_writer_open(struct writer_node *wn)
 	return -E_FW_OPEN;
 }
 
-static int file_writer_write(char *data, size_t nbytes, struct writer_node *wn)
-{
-	struct private_file_writer_data *pfwd = wn->private_data;
-	int ret = write(pfwd->fd, data, nbytes);
-	if (ret < 0)
-		ret = -E_FW_WRITE;
-	return ret;
-}
-
 static int file_writer_pre_select(struct sched *s, struct writer_node *wn)
 {
 	struct private_file_writer_data *pfwd = wn->private_data;
@@ -128,7 +119,6 @@ __malloc void *file_writer_parse_config(char *options)
 void file_writer_init(struct writer *w)
 {
 	w->open = file_writer_open;
-	w->write = file_writer_write;
 	w->pre_select = file_writer_pre_select;
 	w->post_select = file_writer_post_select;
 	w->parse_config = file_writer_parse_config;
diff --git a/write.h b/write.h
index 79531b50..63efbfed 100644
--- a/write.h
+++ b/write.h
@@ -74,13 +74,19 @@ struct writer {
 	 *
 	 * write a chunk of audio data
 	 *
-	 * This is called from the driving application whenever a data block of \a
-	 * chunk_bytes is available. It must return the number of bytes consumed from
-	 * \a data on success, and negative on errors.
-	 *
+	 * This is called from the writer node group task's pre_select(). It
+	 * may use the sched pointer to add any file descriptors or to decrease
+	 * the select timeout. It must return positive on success and negative
+	 * on errors.
 	 */
-	int (*write)(char *data, size_t nbytes, struct writer_node *);
 	int (*pre_select)(struct sched *s, struct writer_node *wn);
+	/*
+	 * Called from the post_select function of the wng task. It must keep
+	 * track of the the number of bytes consumed from the wng's buffer via
+	 * the wn->written variable (which may be modified by the wng handling
+	 * functions). This function must return positive on success and
+	 * negative on errors.
+	 */
 	int (*post_select)(struct sched *s, struct writer_node *wn);
 	/**
 	 * close one instance of the writer
@@ -107,13 +113,19 @@ struct writer_node_group {
 	struct writer_node *writer_nodes;
 	/** the maximum of the chunk_bytes values of the writer nodes in this group */
 	size_t max_chunk_bytes;
-	/** non-zero if end of file was encountered */
+	/** non-zero if end of file was encountered by the feeding task */
 	int *input_eof;
+	/** non-zero if end of file was encountered */
 	int eof;
+	/** current output buffer */
 	char *buf;
+	/** number of bytes loaded in the output buffer */
+	size_t *loaded;
+	/** number of audio channels of the current stream */
 	unsigned int *channels;
+	/** sample rate of the current stream */
 	unsigned int *samplerate;
-	size_t *loaded;
+	/** the task associated to this group */
 	struct task task;
 };
 
-- 
2.39.5