configure.ac: Fix mysql configuration
[paraslash.git] / write.h
1 /*
2  * Copyright (C) 2006 Andre Noll <maan@systemlinux.org>
3  *
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.
8  *
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.
13  *
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.
17  */
18
19 /** \file write.h writer-related structures */
20
21 /** the list of supported writers */
22 enum writer_enum {WRITER_ENUM};
23
24 /**
25  * decbribes one running instance of a writer
26  */
27 struct writer_node {
28 /** points to the writer structure associated with this node */
29         struct writer *writer;
30 /** writer-specific data */
31         void *private_data;
32 /** send that many bytes in one go */
33         int chunk_bytes;
34 };
35
36 /** describes one supported writer */
37 struct writer {
38 /**
39  * the init function of the writer
40  *
41  * It must fill in all other function pointers of the given
42  * writer structure.
43  *
44  */
45 void (*init)(struct writer *w);
46 /**
47  *
48  * open one instance of this writer
49  *
50  * This function should perform any work necessary to write the incoming
51  * stream. If To this aim, it may allocate its private data structure and store
52  * a pointer to that structure via the given writer_node paramenter.
53  */
54 int (*open)(struct writer_node *);
55 /**
56  *
57  * write a chunk of audio data
58  *
59  * This is called from the driving application whenever a data block of \a
60  * chunk_bytes is available. It must return the number of bytes consumed from
61  * \a data on success, and negative on errors.
62  *
63  */
64 int (*write)(char *data, size_t nbytes, struct writer_node *);
65 /**
66  * close one instance of the writer
67  *
68  * This function is assumed to succeed.
69  */
70 void (*close)(struct writer_node *);
71 /**
72  * shutdown the writer
73  *
74  * This is a optional function pointer used for cleaning
75  * up.
76  */
77 void (*shutdown)(struct writer_node *);
78 };
79
80 /**
81  * describes a set of writer nodes that all write the same stream.
82  */
83 struct writer_node_group {
84 /** number of nodes belonging to this group */
85 unsigned num_writers;
86 /** array of pointers to the corresponding writer nodes */
87 struct writer_node *writer_nodes;
88 /** keeps track of how many bytes have been written by each node */
89 int *written;
90 /** the maximum of the chunk_bytes values of the writer nodes in this group */
91 size_t max_chunk_bytes;
92 /** non-zero if end of file was encountered */
93 int eof;
94 };
95
96 /** loop over each writer node in a writer group */
97 #define FOR_EACH_WRITER_NODE(i, wng) for (i = 0; i < (wng)->num_writers; i++)
98 /** loop over each supported writer */
99 #define FOR_EACH_WRITER(i) for (i = 0; i < NUM_SUPPORTED_WRITERS; i++)
100
101 /** declare the init functions of all supported writers */
102 DECLARE_WRITER_INITS;
103
104 /** array containing the name of each writer */
105 extern const char *writer_names[];
106
107 /** the writer structure for each supported writer */
108 extern struct writer writers[NUM_SUPPORTED_WRITERS];