signal.h: Add documentation of signal_pre_select().
[paraslash.git] / write.h
1 /*
2 * Copyright (C) 2006 Andre Noll <maan@tuebingen.mpg.de>
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 /** The writer-specific configuration of this node. */
21 void *conf;
22 /** The buffer tree node associated with this writer node. */
23 struct btr_node *btrn;
24 /** The task of this writer node. */
25 struct task *task;
26 /** The minimal input queue size (size of one audio sample). */
27 size_t min_iqs;
28 };
29
30 /** Describes one supported writer. */
31 struct writer {
32 /**
33 * The init function of the writer.
34 *
35 * It must fill in all other function pointers of the given
36 * writer structure.
37 */
38 void (*init)(struct writer *w);
39 /**
40 * The command line parser of the writer.
41 *
42 * It should check whether the command line options given by \a argv
43 * and \a argc are valid and return a pointer to the writer-specific
44 * configuration data determined by these options. This function must
45 * either succeed or call exit(). Note that parse_config_or_die() might
46 * be called more than once with different values of \a options. \sa
47 * \ref free_config().
48 */
49 void *(*parse_config_or_die)(int argc, char **argv);
50 /**
51 * Deallocate all configuration resources.
52 *
53 * This should free whatever was allocated by \ref parse_config_or_die().
54 */
55 void (*free_config)(void *config);
56 /**
57 * Prepare the fd sets for select.
58 *
59 * This is called from scheduler. It may use the sched pointer to add
60 * any file descriptors or to decrease the select timeout.
61 */
62 void (*pre_select)(struct sched *s, void *context);
63 /**
64 * Write audio data.
65 *
66 * Called from the post_select function of the writer node's task.
67 */
68 int (*post_select)(struct sched *s, void *context);
69 /**
70 * Close one instance of the writer.
71 *
72 * This function is assumed to succeed.
73 */
74 void (*close)(struct writer_node *);
75 /** The short and the log help text of this writer. */
76 struct ggo_help help;
77 /**
78 * The callback handler.
79 *
80 * Each writer may provide an ->execute callback which can be used for
81 * inter-node communication.
82 */
83 btr_command_handler execute;
84 };
85
86 /** Loop over each supported writer. */
87 #define FOR_EACH_WRITER(i) for (i = 0; i < NUM_SUPPORTED_WRITERS; i++)
88
89 /** Declare the init functions of all supported writers. */
90 DECLARE_WRITER_INITS;
91
92 /** Array containing the name of each writer. */
93 extern const char *writer_names[];
94
95 /** The writer structure for each supported writer. */
96 extern struct writer writers[NUM_SUPPORTED_WRITERS];