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