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;
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;
*
* 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
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;
};