Kill unused filter_node->fc.
[paraslash.git] / filter.h
1 /*
2 * Copyright (C) 2005-2009 Andre Noll <maan@systemlinux.org>
3 *
4 * Licensed under the GPL v2. For licencing details see COPYING.
5 */
6
7 /** \file filter.h Filter-related structures and exported symbols from filter_common.c. */
8
9 /** The list of supported filters. */
10 enum filter_enum {FILTER_ENUM};
11
12 /**
13 * Describes one running instance of a filter.
14 */
15 struct filter_node {
16 /** The number in the array of available filters. */
17 unsigned filter_num;
18 /**
19 * Each filter may store any filter-specific information about the particular
20 * instance of the filter here.
21 */
22 void *private_data;
23 /** The output buffer. */
24 char *buf;
25 /** The size of the output buffer. */
26 size_t bufsize;
27 /** The number of bytes currently loaded in \a buf. */
28 size_t loaded;
29 /** The list of registered callbacks. */
30 struct list_head callbacks;
31 /** A pointer to the configuration of this instance. */
32 void *conf;
33 struct btr_node *btrn;
34 struct task task;
35 size_t min_iqs;
36 };
37
38 /**
39 * The structure associated with a paraslash filter.
40 *
41 * Paraslash filters are "modules" which are used to transform an audio stream.
42 * struct filter contains pointers to functions that must be supplied by the
43 * filter code in order to be used by the driving application (currently
44 * para_audiod and para_filter).
45 *
46 * Note: As several instances of the same filter may be running at the same
47 * time, all these filter functions must be reentrant; no static non-constant
48 * variables may be used.
49 * \sa mp3dec_filter.c, oggdec_filter.c, wav_filter.c, compress_filter.c, filter_node
50 */
51 struct filter {
52 /** The name of the filter. */
53 const char *name;
54 /**
55 * Pointer to the filter init routine.
56 *
57 * This function is only called once at startup. It must initialize the
58 * other non-optional function pointers of this structure.
59 */
60 void (*init)(struct filter *f);
61 /**
62 * Open one instance of this filter.
63 *
64 * This should allocate the output buffer of the given filter node and do any
65 * other filter-specific preparations like initializing the private_data member
66 * of \a fn suitably. The open function is assumed to succeed.
67 */
68 void (*open)(struct filter_node *fn);
69 /**
70 * Close one instance of this filter.
71 *
72 * Free all resources of associated with \a fn that were previously allocated
73 * by the open() function.
74 */
75 void (*close)(struct filter_node *fn);
76 /**
77 * A pointer to the filter's command line parser.
78 *
79 * If this optional function pointer is not NULL, any filter options
80 * are passed from the main program to this command line parser once at
81 * application startup. The command line parser should check its
82 * command line options given by \a argc and \a argv and abort on
83 * errors. Success must be indicated by a non-negative return value. In
84 * this case the function should return a pointer to the
85 * filter-specific configuration data determined by \a argc and \a
86 * argv. On failure, a negative paraslash error code must be returned.
87 */
88 int (*parse_config)(int argc, char **argv, void **config);
89 void (*free_config)(void *conf);
90
91 /** The help texts for this filter. */
92 struct ggo_help help;
93 void (*pre_select)(struct sched *s, struct task *t);
94 /**
95 * Convert (filter) the given data.
96 *
97 * Pointer to the converting function of the filter. It should convert as
98 * input data as possible. On errors, the post_select function is supposed
99 * to set t->error to a (negative) error code.
100 */
101 void (*post_select)(struct sched *s, struct task *t);
102 btr_command_handler execute;
103 };
104
105 void filter_init(void);
106 int check_filter_arg(char *filter_arg, void **conf);
107 void print_filter_helps(int detailed);
108 void generic_filter_pre_select(struct sched *s, struct task *t);
109
110 static inline void write_int16_host_endian(char *buf, int val)
111 {
112 #ifdef WORDS_BIGENDIAN
113 *buf = val >> 8;
114 *(buf + 1) = val & 0xff;
115 #else
116 *buf = val & 0xff;
117 *(buf + 1) = val >> 8;
118 #endif
119 }
120
121 DECLARE_FILTER_INITS
122
123 #define FOR_EACH_SUPPORTED_FILTER(j) for (j = 0; j < NUM_SUPPORTED_FILTERS; j++)
124
125 /** The filter array, one structure for each supported filter. */
126 extern struct filter filters[NUM_SUPPORTED_FILTERS];