aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-08-04 13:38:13 +0200
committerMax Kellermann <max@duempel.org>2013-08-04 14:07:50 +0200
commitf54bcc1f16f815fb507ac8a8ffd7913f686969d2 (patch)
tree94bfc2ab6640e54fd28e2518c7820ccb89933d7a
parentca0d09c50fc4246fdae67b8a33799ea580b68593 (diff)
downloadmpd-f54bcc1f16f815fb507ac8a8ffd7913f686969d2.tar.gz
mpd-f54bcc1f16f815fb507ac8a8ffd7913f686969d2.tar.xz
mpd-f54bcc1f16f815fb507ac8a8ffd7913f686969d2.zip
FilterPlugin: pass config_param reference
-rw-r--r--src/FilterConfig.cxx9
-rw-r--r--src/FilterPlugin.cxx8
-rw-r--r--src/FilterPlugin.hxx6
-rw-r--r--src/OutputInit.cxx10
-rw-r--r--src/filter/AutoConvertFilterPlugin.cxx4
-rw-r--r--src/filter/ChainFilterPlugin.cxx2
-rw-r--r--src/filter/ConvertFilterPlugin.cxx2
-rw-r--r--src/filter/NormalizeFilterPlugin.cxx2
-rw-r--r--src/filter/NullFilterPlugin.cxx2
-rw-r--r--src/filter/ReplayGainFilterPlugin.cxx2
-rw-r--r--src/filter/RouteFilterPlugin.cxx13
-rw-r--r--src/filter/VolumeFilterPlugin.cxx2
-rw-r--r--src/mixer/SoftwareMixerPlugin.cxx4
-rw-r--r--test/run_filter.cxx5
14 files changed, 36 insertions, 35 deletions
diff --git a/src/FilterConfig.cxx b/src/FilterConfig.cxx
index e56c5a988..389afa99d 100644
--- a/src/FilterConfig.cxx
+++ b/src/FilterConfig.cxx
@@ -48,8 +48,7 @@ filter_plugin_config(const char *filter_template_name, GError **error_r)
const struct config_param *param = NULL;
while ((param = config_get_next_param(CONF_AUDIO_FILTER, param)) != NULL) {
- const char *name =
- config_get_block_string(param, "name", NULL);
+ const char *name = param->GetBlockValue("name");
if (name == NULL) {
g_set_error(error_r, filter_quark(), 1,
"filter configuration without 'name' name in line %d",
@@ -100,14 +99,14 @@ filter_chain_parse(Filter &chain, const char *spec, GError **error_r)
}
// Instantiate one of those filter plugins with the template name as a hint
- Filter *f = filter_configured_new(cfg, error_r);
+ Filter *f = filter_configured_new(*cfg, error_r);
if (f == NULL) {
// The error has already been set, just stop.
break;
}
- const char *plugin_name =
- config_get_block_string(cfg, "plugin", "unknown");
+ const char *plugin_name = cfg->GetBlockValue("plugin",
+ "unknown");
filter_chain_append(chain, plugin_name, f);
++added_filters;
diff --git a/src/FilterPlugin.cxx b/src/FilterPlugin.cxx
index 953f404ed..076056fbe 100644
--- a/src/FilterPlugin.cxx
+++ b/src/FilterPlugin.cxx
@@ -28,7 +28,7 @@
Filter *
filter_new(const struct filter_plugin *plugin,
- const struct config_param *param, GError **error_r)
+ const config_param &param, GError **error_r)
{
assert(plugin != NULL);
assert(error_r == NULL || *error_r == NULL);
@@ -37,15 +37,13 @@ filter_new(const struct filter_plugin *plugin,
}
Filter *
-filter_configured_new(const struct config_param *param, GError **error_r)
+filter_configured_new(const config_param &param, GError **error_r)
{
- const char *plugin_name;
const struct filter_plugin *plugin;
- assert(param != NULL);
assert(error_r == NULL || *error_r == NULL);
- plugin_name = config_get_block_string(param, "plugin", NULL);
+ const char *plugin_name = param.GetBlockValue("plugin");
if (plugin_name == NULL) {
g_set_error(error_r, config_quark(), 0,
"No filter plugin specified");
diff --git a/src/FilterPlugin.hxx b/src/FilterPlugin.hxx
index 80bb8a0b6..af1e2f699 100644
--- a/src/FilterPlugin.hxx
+++ b/src/FilterPlugin.hxx
@@ -39,7 +39,7 @@ struct filter_plugin {
/**
* Allocates and configures a filter.
*/
- Filter *(*init)(const struct config_param *param, GError **error_r);
+ Filter *(*init)(const config_param &param, GError **error_r);
};
/**
@@ -53,7 +53,7 @@ struct filter_plugin {
*/
Filter *
filter_new(const struct filter_plugin *plugin,
- const struct config_param *param, GError **error_r);
+ const config_param &param, GError **error_r);
/**
* Creates a new filter, loads configuration and the plugin name from
@@ -65,6 +65,6 @@ filter_new(const struct filter_plugin *plugin,
* @return a new filter object, or NULL on error
*/
Filter *
-filter_configured_new(const struct config_param *param, GError **error_r);
+filter_configured_new(const config_param &param, GError **error_r);
#endif
diff --git a/src/OutputInit.cxx b/src/OutputInit.cxx
index 4ba33be1d..053e1e633 100644
--- a/src/OutputInit.cxx
+++ b/src/OutputInit.cxx
@@ -183,7 +183,8 @@ ao_base_init(struct audio_output *ao,
if (config_get_bool(CONF_VOLUME_NORMALIZATION, false)) {
Filter *normalize_filter =
- filter_new(&normalize_filter_plugin, NULL, NULL);
+ filter_new(&normalize_filter_plugin, config_param(),
+ nullptr);
assert(normalize_filter != NULL);
filter_chain_append(*ao->filter, "normalize",
@@ -227,13 +228,13 @@ audio_output_setup(struct audio_output *ao, const config_param &param,
if (strcmp(replay_gain_handler, "none") != 0) {
ao->replay_gain_filter = filter_new(&replay_gain_filter_plugin,
- &param, NULL);
+ param, NULL);
assert(ao->replay_gain_filter != NULL);
ao->replay_gain_serial = 0;
ao->other_replay_gain_filter = filter_new(&replay_gain_filter_plugin,
- &param, NULL);
+ param, NULL);
assert(ao->other_replay_gain_filter != NULL);
ao->other_replay_gain_serial = 0;
@@ -271,7 +272,8 @@ audio_output_setup(struct audio_output *ao, const config_param &param,
/* the "convert" filter must be the last one in the chain */
- ao->convert_filter = filter_new(&convert_filter_plugin, NULL, NULL);
+ ao->convert_filter = filter_new(&convert_filter_plugin, config_param(),
+ nullptr);
assert(ao->convert_filter != NULL);
filter_chain_append(*ao->filter, "convert", ao->convert_filter);
diff --git a/src/filter/AutoConvertFilterPlugin.cxx b/src/filter/AutoConvertFilterPlugin.cxx
index 1ad42c2ab..19495acbc 100644
--- a/src/filter/AutoConvertFilterPlugin.cxx
+++ b/src/filter/AutoConvertFilterPlugin.cxx
@@ -24,6 +24,7 @@
#include "FilterInternal.hxx"
#include "FilterRegistry.hxx"
#include "AudioFormat.hxx"
+#include "ConfigData.hxx"
#include <assert.h>
@@ -68,7 +69,8 @@ AutoConvertFilter::Open(AudioFormat &in_audio_format, GError **error_r)
if (in_audio_format != child_audio_format) {
/* yes - create a convert_filter */
- convert = filter_new(&convert_filter_plugin, nullptr, error_r);
+ const config_param empty;
+ convert = filter_new(&convert_filter_plugin, empty, error_r);
if (convert == nullptr) {
filter->Close();
return AudioFormat::Undefined();
diff --git a/src/filter/ChainFilterPlugin.cxx b/src/filter/ChainFilterPlugin.cxx
index 2d7fdf938..fbb91795d 100644
--- a/src/filter/ChainFilterPlugin.cxx
+++ b/src/filter/ChainFilterPlugin.cxx
@@ -73,7 +73,7 @@ filter_quark(void)
}
static Filter *
-chain_filter_init(gcc_unused const struct config_param *param,
+chain_filter_init(gcc_unused const config_param &param,
gcc_unused GError **error_r)
{
return new ChainFilter();
diff --git a/src/filter/ConvertFilterPlugin.cxx b/src/filter/ConvertFilterPlugin.cxx
index f98184489..4dc0d0333 100644
--- a/src/filter/ConvertFilterPlugin.cxx
+++ b/src/filter/ConvertFilterPlugin.cxx
@@ -63,7 +63,7 @@ public:
};
static Filter *
-convert_filter_init(gcc_unused const struct config_param *param,
+convert_filter_init(gcc_unused const config_param &param,
gcc_unused GError **error_r)
{
return new ConvertFilter();
diff --git a/src/filter/NormalizeFilterPlugin.cxx b/src/filter/NormalizeFilterPlugin.cxx
index 31bcabd36..63b562fa0 100644
--- a/src/filter/NormalizeFilterPlugin.cxx
+++ b/src/filter/NormalizeFilterPlugin.cxx
@@ -41,7 +41,7 @@ public:
};
static Filter *
-normalize_filter_init(gcc_unused const struct config_param *param,
+normalize_filter_init(gcc_unused const config_param &param,
gcc_unused GError **error_r)
{
return new NormalizeFilter();
diff --git a/src/filter/NullFilterPlugin.cxx b/src/filter/NullFilterPlugin.cxx
index 3ff78aa6f..f76c05d3f 100644
--- a/src/filter/NullFilterPlugin.cxx
+++ b/src/filter/NullFilterPlugin.cxx
@@ -49,7 +49,7 @@ public:
};
static Filter *
-null_filter_init(gcc_unused const struct config_param *param,
+null_filter_init(gcc_unused const config_param &param,
gcc_unused GError **error_r)
{
return new NullFilter();
diff --git a/src/filter/ReplayGainFilterPlugin.cxx b/src/filter/ReplayGainFilterPlugin.cxx
index be6c7ad2b..5548483da 100644
--- a/src/filter/ReplayGainFilterPlugin.cxx
+++ b/src/filter/ReplayGainFilterPlugin.cxx
@@ -153,7 +153,7 @@ ReplayGainFilter::Update()
}
static Filter *
-replay_gain_filter_init(gcc_unused const struct config_param *param,
+replay_gain_filter_init(gcc_unused const config_param &param,
gcc_unused GError **error_r)
{
return new ReplayGainFilter();
diff --git a/src/filter/RouteFilterPlugin.cxx b/src/filter/RouteFilterPlugin.cxx
index 4f4ceacde..ceb944822 100644
--- a/src/filter/RouteFilterPlugin.cxx
+++ b/src/filter/RouteFilterPlugin.cxx
@@ -118,7 +118,7 @@ public:
* @param filter a route_filter whose min_channels and sources[] to set
* @return true on success, false on error
*/
- bool Configure(const config_param *param, GError **error_r);
+ bool Configure(const config_param &param, GError **error_r);
virtual AudioFormat Open(AudioFormat &af, GError **error_r) override;
virtual void Close();
@@ -127,7 +127,7 @@ public:
};
bool
-RouteFilter::Configure(const config_param *param, GError **error_r) {
+RouteFilter::Configure(const config_param &param, GError **error_r) {
/* TODO:
* With a more clever way of marking "don't copy to output N",
@@ -139,8 +139,7 @@ RouteFilter::Configure(const config_param *param, GError **error_r) {
int number_of_copies;
// A cowardly default, just passthrough stereo
- const char *routes =
- config_get_block_string(param, "routes", "0>0, 1>1");
+ const char *const routes = param.GetBlockValue("routes", "0>0, 1>1");
min_input_channels = 0;
min_output_channels = 0;
@@ -163,7 +162,7 @@ RouteFilter::Configure(const config_param *param, GError **error_r) {
if (g_strv_length(sd) != 2) {
g_set_error(error_r, config_quark(), 1,
"Invalid copy around %d in routes spec: %s",
- param->line, tokens[c]);
+ param.line, tokens[c]);
g_strfreev(sd);
g_strfreev(tokens);
return false;
@@ -210,7 +209,7 @@ RouteFilter::Configure(const config_param *param, GError **error_r) {
if (g_strv_length(sd) != 2) {
g_set_error(error_r, config_quark(), 1,
"Invalid copy around %d in routes spec: %s",
- param->line, tokens[c]);
+ param.line, tokens[c]);
g_strfreev(sd);
g_strfreev(tokens);
return false;
@@ -230,7 +229,7 @@ RouteFilter::Configure(const config_param *param, GError **error_r) {
}
static Filter *
-route_filter_init(const config_param *param, GError **error_r)
+route_filter_init(const config_param &param, GError **error_r)
{
RouteFilter *filter = new RouteFilter();
if (!filter->Configure(param, error_r)) {
diff --git a/src/filter/VolumeFilterPlugin.cxx b/src/filter/VolumeFilterPlugin.cxx
index 3888cefe4..fc7120c2d 100644
--- a/src/filter/VolumeFilterPlugin.cxx
+++ b/src/filter/VolumeFilterPlugin.cxx
@@ -69,7 +69,7 @@ volume_quark(void)
}
static Filter *
-volume_filter_init(gcc_unused const struct config_param *param,
+volume_filter_init(gcc_unused const config_param &param,
gcc_unused GError **error_r)
{
return new VolumeFilter();
diff --git a/src/mixer/SoftwareMixerPlugin.cxx b/src/mixer/SoftwareMixerPlugin.cxx
index 88702310c..bb0b890ca 100644
--- a/src/mixer/SoftwareMixerPlugin.cxx
+++ b/src/mixer/SoftwareMixerPlugin.cxx
@@ -25,6 +25,7 @@
#include "FilterInternal.hxx"
#include "filter/VolumeFilterPlugin.hxx"
#include "pcm/PcmVolume.hxx"
+#include "ConfigData.hxx"
#include <assert.h>
#include <math.h>
@@ -36,7 +37,8 @@ struct SoftwareMixer final : public Mixer {
SoftwareMixer()
:Mixer(software_mixer_plugin),
- filter(filter_new(&volume_filter_plugin, nullptr, nullptr)),
+ filter(filter_new(&volume_filter_plugin, config_param(),
+ nullptr)),
volume(100)
{
assert(filter != nullptr);
diff --git a/test/run_filter.cxx b/test/run_filter.cxx
index db4a2ee89..761bc14e8 100644
--- a/test/run_filter.cxx
+++ b/test/run_filter.cxx
@@ -58,8 +58,7 @@ find_named_config_block(ConfigOption option, const char *name)
const struct config_param *param = NULL;
while ((param = config_get_next_param(option, param)) != NULL) {
- const char *current_name =
- config_get_block_string(param, "name", NULL);
+ const char *current_name = param->GetBlockValue("name");
if (current_name != NULL && strcmp(current_name, name) == 0)
return param;
}
@@ -79,7 +78,7 @@ load_filter(const char *name)
return nullptr;
}
- Filter *filter = filter_configured_new(param, &error);
+ Filter *filter = filter_configured_new(*param, &error);
if (filter == NULL) {
g_printerr("Failed to load filter: %s\n", error->message);
g_error_free(error);