2 * Copyright (C) 2003-2010 The Music Player Daemon Project
3 * http://www.musicpd.org
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 * This header declares the filter_plugin class. It describes a
23 * plugin API for objects which filter raw PCM data.
26 #ifndef MPD_FILTER_PLUGIN_H
27 #define MPD_FILTER_PLUGIN_H
37 struct filter_plugin
{
41 * Allocates and configures a filter.
43 struct filter
*(*init
)(const struct config_param
*param
,
49 void (*finish
)(struct filter
*filter
);
54 * @param audio_format the audio format of incoming data; the
55 * plugin may modify the object to enforce another input
58 const struct audio_format
*
59 (*open
)(struct filter
*filter
,
60 struct audio_format
*audio_format
,
66 void (*close
)(struct filter
*filter
);
69 * Filters a block of PCM data.
71 const void *(*filter
)(struct filter
*filter
,
72 const void *src
, size_t src_size
,
73 size_t *dest_buffer_r
,
78 * Creates a new instance of the specified filter plugin.
80 * @param plugin the filter plugin
81 * @param param optional configuration section
82 * @param error location to store the error occuring, or NULL to
84 * @return a new filter object, or NULL on error
87 filter_new(const struct filter_plugin
*plugin
,
88 const struct config_param
*param
, GError
**error_r
);
91 * Creates a new filter, loads configuration and the plugin name from
92 * the specified configuration section.
94 * @param param the configuration section
95 * @param error location to store the error occuring, or NULL to
97 * @return a new filter object, or NULL on error
100 filter_configured_new(const struct config_param
*param
, GError
**error_r
);
103 * Deletes a filter. It must be closed prior to calling this
104 * function, see filter_close().
106 * @param filter the filter object
109 filter_free(struct filter
*filter
);
112 * Opens the filter, preparing it for filter_filter().
114 * @param filter the filter object
115 * @param audio_format the audio format of incoming data; the plugin
116 * may modify the object to enforce another input format
117 * @param error location to store the error occuring, or NULL to
119 * @return the format of outgoing data
121 const struct audio_format
*
122 filter_open(struct filter
*filter
, struct audio_format
*audio_format
,
126 * Closes the filter. After that, you may call filter_open() again.
128 * @param filter the filter object
131 filter_close(struct filter
*filter
);
134 * Filters a block of PCM data.
136 * @param filter the filter object
137 * @param src the input buffer
138 * @param src_size the size of #src_buffer in bytes
139 * @param dest_size_r the size of the returned buffer
140 * @param error location to store the error occuring, or NULL to
142 * @return the destination buffer on success (will be invalidated by
143 * filter_close() or filter_filter()), NULL on error
146 filter_filter(struct filter
*filter
, const void *src
, size_t src_size
,