Add docu of struct asf_header_info.
[paraslash.git] / write.h
1 /*
2 * Copyright (C) 2006-2009 Andre Noll <maan@systemlinux.org>
3 *
4 * Licensed under the GPL v2. For licencing details see COPYING.
5 */
6
7 /** \file write.h Writer-related structures. */
8
9 /** The list of supported writers. */
10 enum writer_enum {WRITER_ENUM};
11
12 /**
13 * Describes one running instance of a writer.
14 */
15 struct writer_node {
16 /** The number of this writer. */
17 int writer_num;
18 /** Writer-specific data. */
19 void *private_data;
20 /** Pointer to the group this node belongs to. */
21 struct writer_node_group *wng;
22 /** The writer-specific configuration of this node. */
23 void *conf;
24 /** How much of the wng's buffer is already written. */
25 size_t written;
26 };
27
28 /** Describes one supported writer. */
29 struct writer {
30 /**
31 * The init function of the writer.
32 *
33 * It must fill in all other function pointers of the given
34 * writer structure.
35 */
36 void (*init)(struct writer *w);
37 /**
38 * The command line parser of the writer.
39 *
40 * It should check whether the command line options given by \a options are
41 * valid. On success, it should return a pointer to the writer-specific
42 * configuration data determined by \a options. Note that this might be called
43 * more than once with different values of \a options.
44 */
45 void *(*parse_config)(const char *options);
46 /**
47 * Open one instance of this writer.
48 *
49 * This function should perform any work necessary to write the incoming
50 * stream. To this aim, it may allocate its private data structure and store
51 * a pointer to that structure via the given writer_node parameter.
52 */
53 int (*open)(struct writer_node *);
54 /**
55 * Prepare the fd sets for select.
56 *
57 * This is called from the writer node group task's pre_select(). It
58 * may use the sched pointer to add any file descriptors or to decrease
59 * the select timeout. It must return positive on success and negative
60 * on errors.
61 */
62 int (*pre_select)(struct sched *s, struct writer_node *wn);
63 /**
64 * Write audio data.
65 *
66 * Called from the post_select function of the wng task. It must keep
67 * track of the number of bytes consumed from the wng's buffer via
68 * the \p wn->written variable (which may be modified by the wng handling
69 * functions). This function must return positive on success and
70 * negative on errors.
71 */
72 int (*post_select)(struct sched *s, struct writer_node *wn);
73 /**
74 * Close one instance of the writer.
75 *
76 * This function is assumed to succeed.
77 */
78 void (*close)(struct writer_node *);
79 /**
80 * Shutdown the writer
81 *
82 * This is a optional function pointer used for cleaning up.
83 */
84 void (*shutdown)(struct writer_node *);
85 struct ggo_help help;
86 };
87
88 /**
89 * Describes a set of writer nodes that all write the same stream.
90 */
91 struct writer_node_group {
92 /** Number of nodes belonging to this group. */
93 unsigned num_writers;
94 /** Array of pointers to the corresponding writer nodes. */
95 struct writer_node *writer_nodes;
96 /** Non-zero if an error or end of file was encountered by the feeding task. */
97 int *input_error;
98 /** Current output buffer. */
99 char **bufp;
100 /** Number of bytes loaded in the output buffer. */
101 size_t *loaded;
102 /** Number of audio channels of the current stream. */
103 unsigned int *channels;
104 /** Sample rate of the current stream. */
105 unsigned int *samplerate;
106 /** The task associated to this group. */
107 struct task task;
108 /** Whether the group is open, i.e. wng_open() was called. */
109 int open;
110 /** Max number of bytes written in the previous post_select() call. */
111 int last_written;
112 };
113
114 /** Loop over each writer node in a writer group. */
115 #define FOR_EACH_WRITER_NODE(i, wng) for (i = 0; i < (wng)->num_writers; i++)
116 /** Loop over each supported writer. */
117 #define FOR_EACH_WRITER(i) for (i = 0; i < NUM_SUPPORTED_WRITERS; i++)
118
119 /** Declare the init functions of all supported writers. */
120 DECLARE_WRITER_INITS;
121
122 /** Array containing the name of each writer. */
123 extern const char *writer_names[];
124
125 /** The writer structure for each supported writer. */
126 extern struct writer writers[NUM_SUPPORTED_WRITERS];