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.
21
#include "filter_plugin.h"
22
#include "filter_internal.h"
23
#include "filter_registry.h"
27
#include "audio_format.h"
33
filter_new(const struct filter_plugin *plugin,
34
const struct config_param *param, GError **error_r)
36
assert(plugin != NULL);
37
assert(error_r == NULL || *error_r == NULL);
39
return plugin->init(param, error_r);
43
filter_configured_new(const struct config_param *param, GError **error_r)
45
const char *plugin_name;
46
const struct filter_plugin *plugin;
48
assert(param != NULL);
49
assert(error_r == NULL || *error_r == NULL);
51
plugin_name = config_get_block_string(param, "plugin", NULL);
52
if (plugin_name == NULL) {
53
g_set_error(error_r, config_quark(), 0,
54
"No filter plugin specified");
58
plugin = filter_plugin_by_name(plugin_name);
60
g_set_error(error_r, config_quark(), 0,
61
"No such filter plugin: %s", plugin_name);
65
return filter_new(plugin, param, error_r);
69
filter_free(struct filter *filter)
71
assert(filter != NULL);
73
filter->plugin->finish(filter);
76
const struct audio_format *
77
filter_open(struct filter *filter, struct audio_format *audio_format,
80
const struct audio_format *out_audio_format;
82
assert(filter != NULL);
83
assert(audio_format != NULL);
84
assert(audio_format_valid(audio_format));
85
assert(error_r == NULL || *error_r == NULL);
87
out_audio_format = filter->plugin->open(filter, audio_format, error_r);
89
assert(out_audio_format == NULL || audio_format_valid(audio_format));
90
assert(out_audio_format == NULL ||
91
audio_format_valid(out_audio_format));
93
return out_audio_format;
97
filter_close(struct filter *filter)
99
assert(filter != NULL);
101
filter->plugin->close(filter);
105
filter_filter(struct filter *filter, const void *src, size_t src_size,
109
assert(filter != NULL);
111
assert(src_size > 0);
112
assert(dest_size_r != NULL);
113
assert(error_r == NULL || *error_r == NULL);
115
return filter->plugin->filter(filter, src, src_size, dest_size_r, error_r);