FilterPlugin: pass config_param reference
This commit is contained in:
parent
ca0d09c50f
commit
f54bcc1f16
@ -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;
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
Filter *
|
||||
filter_new(const struct filter_plugin *plugin,
|
||||
const struct config_param *param, GError **error_r)
|
||||
const config_param ¶m, 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 ¶m, 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");
|
||||
|
@ -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 ¶m, 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 ¶m, 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 ¶m, GError **error_r);
|
||||
|
||||
#endif
|
||||
|
@ -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 ¶m,
|
||||
|
||||
if (strcmp(replay_gain_handler, "none") != 0) {
|
||||
ao->replay_gain_filter = filter_new(&replay_gain_filter_plugin,
|
||||
¶m, 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,
|
||||
¶m, 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 ¶m,
|
||||
|
||||
/* 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);
|
||||
|
@ -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();
|
||||
|
@ -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 ¶m,
|
||||
gcc_unused GError **error_r)
|
||||
{
|
||||
return new ChainFilter();
|
||||
|
@ -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 ¶m,
|
||||
gcc_unused GError **error_r)
|
||||
{
|
||||
return new ConvertFilter();
|
||||
|
@ -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 ¶m,
|
||||
gcc_unused GError **error_r)
|
||||
{
|
||||
return new NormalizeFilter();
|
||||
|
@ -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 ¶m,
|
||||
gcc_unused GError **error_r)
|
||||
{
|
||||
return new NullFilter();
|
||||
|
@ -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 ¶m,
|
||||
gcc_unused GError **error_r)
|
||||
{
|
||||
return new ReplayGainFilter();
|
||||
|
@ -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 ¶m, 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 ¶m, 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 ¶m, GError **error_r)
|
||||
{
|
||||
RouteFilter *filter = new RouteFilter();
|
||||
if (!filter->Configure(param, error_r)) {
|
||||
|
@ -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 ¶m,
|
||||
gcc_unused GError **error_r)
|
||||
{
|
||||
return new VolumeFilter();
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user