79531b508839ea06947873cab38e770be0daba0f
2 * Copyright (C) 2006 Andre Noll <maan@systemlinux.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
19 /** \file write.h writer-related structures */
21 /** the list of supported writers */
22 enum writer_enum
{WRITER_ENUM
};
25 * decbribes one running instance of a writer
28 /** points to the writer structure associated with this node */
29 struct writer
*writer
; /* FIXME: Should better be only the number */
30 /** writer-specific data */
32 /** send that many bytes in one go */
34 /** pointer to the group this node belongs to */
35 struct writer_node_group
*wng
;
36 /** the writer-specific configuration of this node */
38 /** how much of the wng's buffer is already written */
42 /** describes one supported writer */
45 * the init function of the writer
47 * It must fill in all other function pointers of the given
51 void (*init
)(struct writer
*w
);
55 * the command line parser of the writer
57 * It should check whether the command line options given by \a options are
58 * valid. On success, it should return a pointer to the writer-specific
59 * configuration data determined by \a options. Note that this might be called
60 * more than once with different values of \a options.
63 void * (*parse_config
)(char *options
);
66 * open one instance of this writer
68 * This function should perform any work necessary to write the incoming
69 * stream. If To this aim, it may allocate its private data structure and store
70 * a pointer to that structure via the given writer_node paramenter.
72 int (*open
)(struct writer_node
*);
75 * write a chunk of audio data
77 * This is called from the driving application whenever a data block of \a
78 * chunk_bytes is available. It must return the number of bytes consumed from
79 * \a data on success, and negative on errors.
82 int (*write
)(char *data
, size_t nbytes
, struct writer_node
*);
83 int (*pre_select
)(struct sched
*s
, struct writer_node
*wn
);
84 int (*post_select
)(struct sched
*s
, struct writer_node
*wn
);
86 * close one instance of the writer
88 * This function is assumed to succeed.
90 void (*close
)(struct writer_node
*);
94 * This is a optional function pointer used for cleaning
97 void (*shutdown
)(struct writer_node
*);
101 * describes a set of writer nodes that all write the same stream.
103 struct writer_node_group
{
104 /** number of nodes belonging to this group */
105 unsigned num_writers
;
106 /** array of pointers to the corresponding writer nodes */
107 struct writer_node
*writer_nodes
;
108 /** the maximum of the chunk_bytes values of the writer nodes in this group */
109 size_t max_chunk_bytes
;
110 /** non-zero if end of file was encountered */
114 unsigned int *channels
;
115 unsigned int *samplerate
;
120 /** loop over each writer node in a writer group */
121 #define FOR_EACH_WRITER_NODE(i, wng) for (i = 0; i < (wng)->num_writers; i++)
122 /** loop over each supported writer */
123 #define FOR_EACH_WRITER(i) for (i = 0; i < NUM_SUPPORTED_WRITERS; i++)
125 /** declare the init functions of all supported writers */
126 DECLARE_WRITER_INITS
;
128 /** array containing the name of each writer */
129 extern const char *writer_names
[];
131 /** the writer structure for each supported writer */
132 extern struct writer writers
[NUM_SUPPORTED_WRITERS
];