aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/config/Block.cxx97
-rw-r--r--src/config/Block.hxx72
-rw-r--r--src/config/ConfigFile.cxx139
-rw-r--r--src/config/ConfigGlobal.cxx38
-rw-r--r--src/config/ConfigGlobal.hxx9
-rw-r--r--src/config/ConfigOption.hxx19
-rw-r--r--src/config/ConfigTemplates.cxx157
-rw-r--r--src/config/ConfigTemplates.hxx4
-rw-r--r--src/config/Data.cxx6
-rw-r--r--src/config/Data.hxx2
-rw-r--r--src/config/Param.cxx94
-rw-r--r--src/config/Param.hxx39
-rw-r--r--src/db/Configured.cxx9
-rw-r--r--src/db/DatabaseGlue.cxx8
-rw-r--r--src/db/DatabaseGlue.hxx4
-rw-r--r--src/db/DatabasePlugin.hxx4
-rw-r--r--src/db/plugins/ProxyDatabasePlugin.cxx18
-rw-r--r--src/db/plugins/simple/SimpleDatabasePlugin.cxx14
-rw-r--r--src/db/plugins/simple/SimpleDatabasePlugin.hxx6
-rw-r--r--src/db/plugins/upnp/UpnpDatabasePlugin.cxx12
-rw-r--r--src/decoder/DecoderAPI.hxx2
-rw-r--r--src/decoder/DecoderList.cxx8
-rw-r--r--src/decoder/DecoderPlugin.hxx8
-rw-r--r--src/decoder/plugins/AdPlugDecoderPlugin.cxx4
-rw-r--r--src/decoder/plugins/AudiofileDecoderPlugin.cxx2
-rw-r--r--src/decoder/plugins/DsdiffDecoderPlugin.cxx4
-rw-r--r--src/decoder/plugins/FfmpegDecoderPlugin.cxx2
-rw-r--r--src/decoder/plugins/FlacDecoderPlugin.cxx2
-rw-r--r--src/decoder/plugins/FluidsynthDecoderPlugin.cxx6
-rw-r--r--src/decoder/plugins/MadDecoderPlugin.cxx2
-rw-r--r--src/decoder/plugins/MikmodDecoderPlugin.cxx8
-rw-r--r--src/decoder/plugins/ModplugDecoderPlugin.cxx6
-rw-r--r--src/decoder/plugins/Mpg123DecoderPlugin.cxx2
-rw-r--r--src/decoder/plugins/OpusDecoderPlugin.cxx2
-rw-r--r--src/decoder/plugins/SidplayDecoderPlugin.cxx10
-rw-r--r--src/decoder/plugins/SndfileDecoderPlugin.cxx2
-rw-r--r--src/decoder/plugins/VorbisDecoderPlugin.cxx2
-rw-r--r--src/decoder/plugins/WildmidiDecoderPlugin.cxx4
-rw-r--r--src/encoder/EncoderAPI.hxx2
-rw-r--r--src/encoder/EncoderPlugin.hxx8
-rw-r--r--src/encoder/plugins/FlacEncoderPlugin.cxx10
-rw-r--r--src/encoder/plugins/LameEncoderPlugin.cxx16
-rw-r--r--src/encoder/plugins/NullEncoderPlugin.cxx2
-rw-r--r--src/encoder/plugins/OpusEncoderPlugin.cxx14
-rw-r--r--src/encoder/plugins/ShineEncoderPlugin.cxx13
-rw-r--r--src/encoder/plugins/TwolameEncoderPlugin.cxx16
-rw-r--r--src/encoder/plugins/VorbisEncoderPlugin.cxx14
-rw-r--r--src/encoder/plugins/WaveEncoderPlugin.cxx2
-rw-r--r--src/filter/FilterConfig.cxx6
-rw-r--r--src/filter/FilterPlugin.cxx12
-rw-r--r--src/filter/FilterPlugin.hxx8
-rw-r--r--src/filter/plugins/AutoConvertFilterPlugin.cxx4
-rw-r--r--src/filter/plugins/ChainFilterPlugin.cxx2
-rw-r--r--src/filter/plugins/ConvertFilterPlugin.cxx2
-rw-r--r--src/filter/plugins/NormalizeFilterPlugin.cxx2
-rw-r--r--src/filter/plugins/NullFilterPlugin.cxx2
-rw-r--r--src/filter/plugins/ReplayGainFilterPlugin.cxx2
-rw-r--r--src/filter/plugins/RouteFilterPlugin.cxx14
-rw-r--r--src/filter/plugins/VolumeFilterPlugin.cxx2
-rw-r--r--src/input/Init.cxx16
-rw-r--r--src/input/InputPlugin.hxx4
-rw-r--r--src/input/plugins/CdioParanoiaInputPlugin.cxx6
-rw-r--r--src/input/plugins/CurlInputPlugin.cxx16
-rw-r--r--src/input/plugins/FfmpegInputPlugin.cxx2
-rw-r--r--src/input/plugins/NfsInputPlugin.cxx2
-rw-r--r--src/input/plugins/SmbclientInputPlugin.cxx4
-rw-r--r--src/mixer/MixerControl.cxx4
-rw-r--r--src/mixer/MixerControl.hxx4
-rw-r--r--src/mixer/MixerPlugin.hxx4
-rw-r--r--src/mixer/plugins/AlsaMixerPlugin.cxx14
-rw-r--r--src/mixer/plugins/NullMixerPlugin.cxx2
-rw-r--r--src/mixer/plugins/OssMixerPlugin.cxx14
-rw-r--r--src/mixer/plugins/PulseMixerPlugin.cxx2
-rw-r--r--src/mixer/plugins/RoarMixerPlugin.cxx2
-rw-r--r--src/mixer/plugins/SoftwareMixerPlugin.cxx6
-rw-r--r--src/mixer/plugins/WinmmMixerPlugin.cxx2
-rw-r--r--src/neighbor/Glue.cxx16
-rw-r--r--src/neighbor/NeighborPlugin.hxx4
-rw-r--r--src/neighbor/plugins/SmbclientNeighborPlugin.cxx2
-rw-r--r--src/neighbor/plugins/UpnpNeighborPlugin.cxx2
-rw-r--r--src/output/Init.cxx57
-rw-r--r--src/output/Internal.hxx6
-rw-r--r--src/output/MultipleOutputs.cxx14
-rw-r--r--src/output/OutputAPI.hxx2
-rw-r--r--src/output/OutputPlugin.cxx4
-rw-r--r--src/output/OutputPlugin.hxx7
-rw-r--r--src/output/Wrapper.hxx6
-rw-r--r--src/output/plugins/AlsaOutputPlugin.cxx30
-rw-r--r--src/output/plugins/AoOutputPlugin.cxx22
-rw-r--r--src/output/plugins/FifoOutputPlugin.cxx10
-rw-r--r--src/output/plugins/JackOutputPlugin.cxx28
-rw-r--r--src/output/plugins/NullOutputPlugin.cxx12
-rw-r--r--src/output/plugins/OSXOutputPlugin.cxx10
-rw-r--r--src/output/plugins/OpenALOutputPlugin.cxx14
-rw-r--r--src/output/plugins/OssOutputPlugin.cxx14
-rw-r--r--src/output/plugins/PipeOutputPlugin.cxx14
-rw-r--r--src/output/plugins/PulseOutputPlugin.cxx20
-rw-r--r--src/output/plugins/RecorderOutputPlugin.cxx24
-rw-r--r--src/output/plugins/RoarOutputPlugin.cxx20
-rw-r--r--src/output/plugins/ShoutOutputPlugin.cxx54
-rw-r--r--src/output/plugins/SolarisOutputPlugin.cxx10
-rw-r--r--src/output/plugins/WinmmOutputPlugin.cxx6
-rw-r--r--src/output/plugins/httpd/HttpdInternal.hxx12
-rw-r--r--src/output/plugins/httpd/HttpdOutputPlugin.cxx26
-rw-r--r--src/output/plugins/sles/SlesOutputPlugin.cxx14
-rw-r--r--src/playlist/PlaylistPlugin.hxx8
-rw-r--r--src/playlist/PlaylistRegistry.cxx6
-rw-r--r--src/playlist/plugins/SoundCloudPlaylistPlugin.cxx6
108 files changed, 851 insertions, 713 deletions
diff --git a/src/config/Block.cxx b/src/config/Block.cxx
index ba26c560f..a74903b10 100644
--- a/src/config/Block.cxx
+++ b/src/config/Block.cxx
@@ -20,8 +20,12 @@
#include "config.h"
#include "Block.hxx"
#include "ConfigParser.hxx"
+#include "ConfigPath.hxx"
#include "system/FatalError.hxx"
+#include "fs/AllocatedPath.hxx"
+#include "util/Error.hxx"
+#include <assert.h>
#include <stdlib.h>
int
@@ -57,3 +61,96 @@ BlockParam::GetBoolValue() const
return value2;
}
+
+ConfigBlock::~ConfigBlock()
+{
+ delete next;
+}
+
+const BlockParam *
+ConfigBlock::GetBlockParam(const char *name) const
+{
+ for (const auto &i : block_params) {
+ if (i.name == name) {
+ i.used = true;
+ return &i;
+ }
+ }
+
+ return nullptr;
+}
+
+const char *
+ConfigBlock::GetBlockValue(const char *name, const char *default_value) const
+{
+ const BlockParam *bp = GetBlockParam(name);
+ if (bp == nullptr)
+ return default_value;
+
+ return bp->value.c_str();
+}
+
+AllocatedPath
+ConfigBlock::GetBlockPath(const char *name, const char *default_value,
+ Error &error) const
+{
+ assert(!error.IsDefined());
+
+ int line2 = line;
+ const char *s;
+
+ const BlockParam *bp = GetBlockParam(name);
+ if (bp != nullptr) {
+ line2 = bp->line;
+ s = bp->value.c_str();
+ } else {
+ if (default_value == nullptr)
+ return AllocatedPath::Null();
+
+ s = default_value;
+ }
+
+ AllocatedPath path = ParsePath(s, error);
+ if (gcc_unlikely(path.IsNull()))
+ error.FormatPrefix("Invalid path in \"%s\" at line %i: ",
+ name, line2);
+
+ return path;
+}
+
+AllocatedPath
+ConfigBlock::GetBlockPath(const char *name, Error &error) const
+{
+ return GetBlockPath(name, nullptr, error);
+}
+
+int
+ConfigBlock::GetBlockValue(const char *name, int default_value) const
+{
+ const BlockParam *bp = GetBlockParam(name);
+ if (bp == nullptr)
+ return default_value;
+
+ return bp->GetIntValue();
+}
+
+unsigned
+ConfigBlock::GetBlockValue(const char *name, unsigned default_value) const
+{
+ const BlockParam *bp = GetBlockParam(name);
+ if (bp == nullptr)
+ return default_value;
+
+ return bp->GetUnsignedValue();
+}
+
+gcc_pure
+bool
+ConfigBlock::GetBlockValue(const char *name, bool default_value) const
+{
+ const BlockParam *bp = GetBlockParam(name);
+ if (bp == nullptr)
+ return default_value;
+
+ return bp->GetBoolValue();
+}
diff --git a/src/config/Block.hxx b/src/config/Block.hxx
index c2194eff9..23b064695 100644
--- a/src/config/Block.hxx
+++ b/src/config/Block.hxx
@@ -21,9 +21,14 @@
#define MPD_CONFIG_BLOCK_HXX
#include "check.h"
+#include "Param.hxx"
#include "Compiler.h"
#include <string>
+#include <vector>
+
+class Error;
+class AllocatedPath;
struct BlockParam {
std::string name;
@@ -50,4 +55,71 @@ struct BlockParam {
bool GetBoolValue() const;
};
+struct ConfigBlock {
+ /**
+ * The next #ConfigBlock with the same name. The destructor
+ * deletes the whole chain.
+ */
+ ConfigBlock *next;
+
+ int line;
+
+ std::vector<BlockParam> block_params;
+
+ /**
+ * This flag is false when nobody has queried the value of
+ * this option yet.
+ */
+ bool used;
+
+ explicit ConfigBlock(int _line=-1)
+ :next(nullptr), line(_line), used(false) {}
+
+ ConfigBlock(const ConfigBlock &) = delete;
+
+ ~ConfigBlock();
+
+ ConfigBlock &operator=(const ConfigBlock &) = delete;
+
+ /**
+ * Determine if this is a "null" instance, i.e. an empty
+ * object that was synthesized and not loaded from a
+ * configuration file.
+ */
+ bool IsNull() const {
+ return line < 0;
+ }
+
+ gcc_nonnull_all
+ void AddBlockParam(const char *_name, const char *_value,
+ int _line=-1) {
+ block_params.emplace_back(_name, _value, _line);
+ }
+
+ gcc_nonnull_all gcc_pure
+ const BlockParam *GetBlockParam(const char *_name) const;
+
+ gcc_pure
+ const char *GetBlockValue(const char *name,
+ const char *default_value=nullptr) const;
+
+ /**
+ * Same as config_get_path(), but looks up the setting in the
+ * specified block.
+ */
+ AllocatedPath GetBlockPath(const char *name, const char *default_value,
+ Error &error) const;
+
+ AllocatedPath GetBlockPath(const char *name, Error &error) const;
+
+ gcc_pure
+ int GetBlockValue(const char *name, int default_value) const;
+
+ gcc_pure
+ unsigned GetBlockValue(const char *name, unsigned default_value) const;
+
+ gcc_pure
+ bool GetBlockValue(const char *name, bool default_value) const;
+};
+
#endif
diff --git a/src/config/ConfigFile.cxx b/src/config/ConfigFile.cxx
index 38945f8ec..a5ad020d4 100644
--- a/src/config/ConfigFile.cxx
+++ b/src/config/ConfigFile.cxx
@@ -21,6 +21,7 @@
#include "ConfigFile.hxx"
#include "Data.hxx"
#include "Param.hxx"
+#include "Block.hxx"
#include "ConfigTemplates.hxx"
#include "util/Tokenizer.hxx"
#include "util/StringUtil.hxx"
@@ -38,7 +39,7 @@ static constexpr char CONF_COMMENT = '#';
static constexpr Domain config_file_domain("config_file");
static bool
-config_read_name_value(struct config_param *param, char *input, unsigned line,
+config_read_name_value(ConfigBlock &block, char *input, unsigned line,
Error &error)
{
Tokenizer tokenizer(input);
@@ -65,7 +66,7 @@ config_read_name_value(struct config_param *param, char *input, unsigned line,
return false;
}
- const BlockParam *bp = param->GetBlockParam(name);
+ const BlockParam *bp = block.GetBlockParam(name);
if (bp != nullptr) {
error.Format(config_file_domain,
"\"%s\" is duplicate, first defined on line %i",
@@ -73,14 +74,14 @@ config_read_name_value(struct config_param *param, char *input, unsigned line,
return false;
}
- param->AddBlockParam(name, value, line);
+ block.AddBlockParam(name, value, line);
return true;
}
-static struct config_param *
+static ConfigBlock *
config_read_block(BufferedReader &reader, Error &error)
{
- struct config_param *ret = new config_param(reader.GetLineNumber());
+ auto *ret = new ConfigBlock(reader.GetLineNumber());
while (true) {
char *line = reader.ReadLine();
@@ -115,7 +116,7 @@ config_read_block(BufferedReader &reader, Error &error)
/* parse name and value */
- if (!config_read_name_value(ret, line, reader.GetLineNumber(),
+ if (!config_read_name_value(*ret, line, reader.GetLineNumber(),
error)) {
assert(*line != 0);
delete ret;
@@ -127,6 +128,64 @@ config_read_block(BufferedReader &reader, Error &error)
gcc_nonnull_all
static void
+Append(ConfigBlock *&head, ConfigBlock *p)
+{
+ assert(p->next == nullptr);
+
+ auto **i = &head;
+ while (*i != nullptr)
+ i = &(*i)->next;
+
+ *i = p;
+}
+
+static bool
+ReadConfigBlock(ConfigData &config_data, BufferedReader &reader,
+ const char *name, ConfigOption o,
+ Tokenizer &tokenizer,
+ Error &error)
+{
+ const unsigned i = unsigned(o);
+ const ConfigTemplate &option = config_block_templates[i];
+ ConfigBlock *&head = config_data.blocks[i];
+
+ if (head != nullptr && !option.repeatable) {
+ ConfigBlock *block = head;
+ error.Format(config_file_domain,
+ "config parameter \"%s\" is first defined "
+ "on line %d and redefined on line %u\n",
+ name, block->line,
+ reader.GetLineNumber());
+ return false;
+ }
+
+ /* now parse the block or the value */
+
+ if (tokenizer.CurrentChar() != '{') {
+ error.Format(config_file_domain,
+ "line %u: '{' expected",
+ reader.GetLineNumber());
+ return false;
+ }
+
+ char *line = StripLeft(tokenizer.Rest() + 1);
+ if (*line != 0 && *line != CONF_COMMENT) {
+ error.Format(config_file_domain,
+ "line %u: Unknown tokens after '{'",
+ reader.GetLineNumber());
+ return false;
+ }
+
+ auto *param = config_read_block(reader, error);
+ if (param == nullptr)
+ return false;
+
+ Append(head, param);
+ return true;
+}
+
+gcc_nonnull_all
+static void
Append(config_param *&head, config_param *p)
{
assert(p->next == nullptr);
@@ -145,7 +204,7 @@ ReadConfigParam(ConfigData &config_data, BufferedReader &reader,
Error &error)
{
const unsigned i = unsigned(o);
- const ConfigTemplate &option = config_templates[i];
+ const ConfigTemplate &option = config_param_templates[i];
config_param *&head = config_data.params[i];
if (head != nullptr && !option.repeatable) {
@@ -160,57 +219,28 @@ ReadConfigParam(ConfigData &config_data, BufferedReader &reader,
/* now parse the block or the value */
- struct config_param *param;
- if (option.block) {
- /* it's a block, call config_read_block() */
-
- if (tokenizer.CurrentChar() != '{') {
- error.Format(config_file_domain,
- "line %u: '{' expected",
- reader.GetLineNumber());
- return false;
- }
-
- char *line = StripLeft(tokenizer.Rest() + 1);
- if (*line != 0 && *line != CONF_COMMENT) {
+ const char *value = tokenizer.NextString(error);
+ if (value == nullptr) {
+ if (tokenizer.IsEnd())
error.Format(config_file_domain,
- "line %u: Unknown tokens after '{'",
+ "line %u: Value missing",
reader.GetLineNumber());
- return false;
- }
+ else
+ error.FormatPrefix("line %u: ",
+ reader.GetLineNumber());
- param = config_read_block(reader, error);
- if (param == nullptr) {
- return false;
- }
- } else {
- /* a string value */
-
- const char *value = tokenizer.NextString(error);
- if (value == nullptr) {
- if (tokenizer.IsEnd())
- error.Format(config_file_domain,
- "line %u: Value missing",
- reader.GetLineNumber());
- else
- error.FormatPrefix("line %u: ",
- reader.GetLineNumber());
-
- return false;
- }
-
- if (!tokenizer.IsEnd() &&
- tokenizer.CurrentChar() != CONF_COMMENT) {
- error.Format(config_file_domain,
- "line %u: Unknown tokens after value",
- reader.GetLineNumber());
- return false;
- }
+ return false;
+ }
- param = new config_param(value,
- reader.GetLineNumber());
+ if (!tokenizer.IsEnd() &&
+ tokenizer.CurrentChar() != CONF_COMMENT) {
+ error.Format(config_file_domain,
+ "line %u: Unknown tokens after value",
+ reader.GetLineNumber());
+ return false;
}
+ auto *param = new config_param(value, reader.GetLineNumber());
Append(head, param);
return true;
}
@@ -242,10 +272,15 @@ ReadConfigFile(ConfigData &config_data, BufferedReader &reader, Error &error)
"repeatable" flag */
const ConfigOption o = ParseConfigOptionName(name);
+ ConfigBlockOption bo;
if (o != ConfigOption::MAX) {
if (!ReadConfigParam(config_data, reader, name, o,
tokenizer, error))
return false;
+ } else if ((bo = ParseConfigBlockOptionName(name)) != ConfigBlockOption::MAX) {
+ if (!ReadConfigBlock(config_data, reader, name, o,
+ tokenizer, error))
+ return false;
} else {
error.Format(config_file_domain,
"unrecognized parameter in config file at "
diff --git a/src/config/ConfigGlobal.cxx b/src/config/ConfigGlobal.cxx
index 5c04ea93e..192baffec 100644
--- a/src/config/ConfigGlobal.cxx
+++ b/src/config/ConfigGlobal.cxx
@@ -22,6 +22,7 @@
#include "ConfigParser.hxx"
#include "Data.hxx"
#include "Param.hxx"
+#include "Block.hxx"
#include "ConfigFile.hxx"
#include "ConfigPath.hxx"
#include "ConfigError.hxx"
@@ -51,15 +52,15 @@ ReadConfigFile(Path path, Error &error)
}
static void
-Check(const config_param *param)
+Check(const ConfigBlock &block)
{
- if (!param->used)
- /* this whole config_param was not queried at all -
+ if (!block.used)
+ /* this whole block was not queried at all -
the feature might be disabled at compile time?
Silently ignore it here. */
return;
- for (const auto &i : param->block_params) {
+ for (const auto &i : block.block_params) {
if (!i.used)
FormatWarning(config_domain,
"option '%s' on line %i was not recognized",
@@ -69,9 +70,9 @@ Check(const config_param *param)
void config_global_check(void)
{
- for (auto i : config_data.params)
- for (const config_param *p = i; p != nullptr; p = p->next)
- Check(p);
+ for (auto i : config_data.blocks)
+ for (const auto *p = i; p != nullptr; p = p->next)
+ Check(*p);
}
const config_param *
@@ -83,18 +84,27 @@ config_get_param(ConfigOption option)
return param;
}
-const config_param *
-config_find_block(ConfigOption option, const char *key, const char *value)
+const ConfigBlock *
+config_get_block(ConfigBlockOption option)
+{
+ ConfigBlock *block = config_data.blocks[unsigned(option)];
+ if (block != nullptr)
+ block->used = true;
+ return block;
+}
+
+const ConfigBlock *
+config_find_block(ConfigBlockOption option, const char *key, const char *value)
{
- for (const config_param *param = config_get_param(option);
- param != nullptr; param = param->next) {
- const char *value2 = param->GetBlockValue(key);
+ for (const auto *block = config_get_block(option);
+ block != nullptr; block = block->next) {
+ const char *value2 = block->GetBlockValue(key);
if (value2 == nullptr)
FormatFatalError("block without '%s' name in line %d",
- key, param->line);
+ key, block->line);
if (strcmp(value2, value) == 0)
- return param;
+ return block;
}
return nullptr;
diff --git a/src/config/ConfigGlobal.hxx b/src/config/ConfigGlobal.hxx
index ac7d5c4fd..3c6a938a6 100644
--- a/src/config/ConfigGlobal.hxx
+++ b/src/config/ConfigGlobal.hxx
@@ -27,6 +27,7 @@ class Error;
class Path;
class AllocatedPath;
struct config_param;
+struct ConfigBlock;
void config_global_init(void);
void config_global_finish(void);
@@ -44,6 +45,10 @@ gcc_pure
const config_param *
config_get_param(enum ConfigOption option);
+gcc_pure
+const ConfigBlock *
+config_get_block(enum ConfigBlockOption option);
+
/**
* Find a block with a matching attribute.
*
@@ -52,8 +57,8 @@ config_get_param(enum ConfigOption option);
* @param value the expected attribute value
*/
gcc_pure
-const config_param *
-config_find_block(ConfigOption option, const char *key, const char *value);
+const ConfigBlock *
+config_find_block(ConfigBlockOption option, const char *key, const char *value);
/* Note on gcc_pure: Some of the functions declared pure are not
really pure in strict sense. They have side effect such that they
diff --git a/src/config/ConfigOption.hxx b/src/config/ConfigOption.hxx
index c3f4c9aad..8cc0d42d5 100644
--- a/src/config/ConfigOption.hxx
+++ b/src/config/ConfigOption.hxx
@@ -49,7 +49,6 @@ enum class ConfigOption {
ZEROCONF_ENABLED,
PASSWORD,
DEFAULT_PERMS,
- AUDIO_OUTPUT,
AUDIO_OUTPUT_FORMAT,
MIXER_TYPE,
REPLAYGAIN,
@@ -73,15 +72,20 @@ enum class ConfigOption {
ID3V1_ENCODING,
METADATA_TO_USE,
SAVE_ABSOLUTE_PATHS,
- DECODER,
- INPUT,
GAPLESS_MP3_PLAYBACK,
- PLAYLIST_PLUGIN,
AUTO_UPDATE,
AUTO_UPDATE_DEPTH,
DESPOTIFY_USER,
DESPOTIFY_PASSWORD,
DESPOTIFY_HIGH_BITRATE,
+ MAX
+};
+
+enum class ConfigBlockOption {
+ AUDIO_OUTPUT,
+ DECODER,
+ INPUT,
+ PLAYLIST_PLUGIN,
AUDIO_FILTER,
DATABASE,
NEIGHBORS,
@@ -99,4 +103,11 @@ gcc_pure
enum ConfigOption
ParseConfigOptionName(const char *name);
+/**
+ * @return #ConfigOption::MAX if not found
+ */
+gcc_pure
+enum ConfigBlockOption
+ParseConfigBlockOptionName(const char *name);
+
#endif
diff --git a/src/config/ConfigTemplates.cxx b/src/config/ConfigTemplates.cxx
index 8f01d4104..1ceef9119 100644
--- a/src/config/ConfigTemplates.cxx
+++ b/src/config/ConfigTemplates.cxx
@@ -23,76 +23,105 @@
#include <string.h>
-const ConfigTemplate config_templates[] = {
- { "music_directory", false, false },
- { "playlist_directory", false, false },
- { "follow_inside_symlinks", false, false },
- { "follow_outside_symlinks", false, false },
- { "db_file", false, false },
- { "sticker_file", false, false },
- { "log_file", false, false },
- { "pid_file", false, false },
- { "state_file", false, false },
- { "state_file_interval", false, false },
- { "restore_paused", false, false },
- { "user", false, false },
- { "group", false, false },
- { "bind_to_address", true, false },
- { "port", false, false },
- { "log_level", false, false },
- { "zeroconf_name", false, false },
- { "zeroconf_enabled", false, false },
- { "password", true, false },
- { "default_permissions", false, false },
- { "audio_output", true, true },
- { "audio_output_format", false, false },
- { "mixer_type", false, false },
- { "replaygain", false, false },
- { "replaygain_preamp", false, false },
- { "replaygain_missing_preamp", false, false },
- { "replaygain_limit", false, false },
- { "volume_normalization", false, false },
- { "samplerate_converter", false, false },
- { "audio_buffer_size", false, false },
- { "buffer_before_play", false, false },
- { "http_proxy_host", false, false },
- { "http_proxy_port", false, false },
- { "http_proxy_user", false, false },
- { "http_proxy_password", false, false },
- { "connection_timeout", false, false },
- { "max_connections", false, false },
- { "max_playlist_length", false, false },
- { "max_command_list_size", false, false },
- { "max_output_buffer_size", false, false },
- { "filesystem_charset", false, false },
- { "id3v1_encoding", false, false },
- { "metadata_to_use", false, false },
- { "save_absolute_paths_in_playlists", false, false },
- { "decoder", true, true },
- { "input", true, true },
- { "gapless_mp3_playback", false, false },
- { "playlist_plugin", true, true },
- { "auto_update", false, false },
- { "auto_update_depth", false, false },
- { "despotify_user", false, false },
- { "despotify_password", false, false},
- { "despotify_high_bitrate", false, false },
- { "filter", true, true },
- { "database", false, true },
- { "neighbors", true, true },
+const ConfigTemplate config_param_templates[] = {
+ { "music_directory", false },
+ { "playlist_directory", false },
+ { "follow_inside_symlinks", false },
+ { "follow_outside_symlinks", false },
+ { "db_file", false },
+ { "sticker_file", false },
+ { "log_file", false },
+ { "pid_file", false },
+ { "state_file", false },
+ { "state_file_interval", false },
+ { "restore_paused", false },
+ { "user", false },
+ { "group", false },
+ { "bind_to_address", true },
+ { "port", false },
+ { "log_level", false },
+ { "zeroconf_name", false },
+ { "zeroconf_enabled", false },
+ { "password", true },
+ { "default_permissions", false },
+ { "audio_output_format", false },
+ { "mixer_type", false },
+ { "replaygain", false },
+ { "replaygain_preamp", false },
+ { "replaygain_missing_preamp", false },
+ { "replaygain_limit", false },
+ { "volume_normalization", false },
+ { "samplerate_converter", false },
+ { "audio_buffer_size", false },
+ { "buffer_before_play", false },
+ { "http_proxy_host", false },
+ { "http_proxy_port", false },
+ { "http_proxy_user", false },
+ { "http_proxy_password", false },
+ { "connection_timeout", false },
+ { "max_connections", false },
+ { "max_playlist_length", false },
+ { "max_command_list_size", false },
+ { "max_output_buffer_size", false },
+ { "filesystem_charset", false },
+ { "id3v1_encoding", false },
+ { "metadata_to_use", false },
+ { "save_absolute_paths_in_playlists", false },
+ { "gapless_mp3_playback", false },
+ { "auto_update", false },
+ { "auto_update_depth", false },
+ { "despotify_user", false },
+ { "despotify_password", false },
+ { "despotify_high_bitrate", false },
};
-static constexpr unsigned n_config_templates = ARRAY_SIZE(config_templates);
+static constexpr unsigned n_config_param_templates =
+ ARRAY_SIZE(config_param_templates);
-static_assert(n_config_templates == unsigned(ConfigOption::MAX),
- "Wrong number of config_templates");
+static_assert(n_config_param_templates == unsigned(ConfigOption::MAX),
+ "Wrong number of config_param_templates");
+
+const ConfigTemplate config_block_templates[] = {
+ { "audio_output", true },
+ { "decoder", true },
+ { "input", true },
+ { "playlist_plugin", true },
+ { "filter", true },
+ { "database", false },
+ { "neighbors", true },
+};
+
+static constexpr unsigned n_config_block_templates =
+ ARRAY_SIZE(config_block_templates);
+
+static_assert(n_config_block_templates == unsigned(ConfigBlockOption::MAX),
+ "Wrong number of config_block_templates");
+
+gcc_pure
+static inline unsigned
+ParseConfigTemplateName(const ConfigTemplate templates[], unsigned count,
+ const char *name)
+{
+ unsigned i = 0;
+ for (; i < count; ++i)
+ if (strcmp(templates[i].name, name) == 0)
+ break;
+
+ return i;
+}
ConfigOption
ParseConfigOptionName(const char *name)
{
- for (unsigned i = 0; i < n_config_templates; ++i)
- if (strcmp(config_templates[i].name, name) == 0)
- return ConfigOption(i);
+ return ConfigOption(ParseConfigTemplateName(config_param_templates,
+ n_config_param_templates,
+ name));
+}
- return ConfigOption::MAX;
+ConfigBlockOption
+ParseConfigBlockOptionName(const char *name)
+{
+ return ConfigBlockOption(ParseConfigTemplateName(config_block_templates,
+ n_config_block_templates,
+ name));
}
diff --git a/src/config/ConfigTemplates.hxx b/src/config/ConfigTemplates.hxx
index f034773e3..1aa6c6e8d 100644
--- a/src/config/ConfigTemplates.hxx
+++ b/src/config/ConfigTemplates.hxx
@@ -23,9 +23,9 @@
struct ConfigTemplate {
const char *const name;
const bool repeatable;
- const bool block;
};
-extern const ConfigTemplate config_templates[];
+extern const ConfigTemplate config_param_templates[];
+extern const ConfigTemplate config_block_templates[];
#endif
diff --git a/src/config/Data.cxx b/src/config/Data.cxx
index 4aae9f7dc..52521e31a 100644
--- a/src/config/Data.cxx
+++ b/src/config/Data.cxx
@@ -20,6 +20,7 @@
#include "config.h"
#include "Data.hxx"
#include "Param.hxx"
+#include "Block.hxx"
void
ConfigData::Clear()
@@ -28,4 +29,9 @@ ConfigData::Clear()
delete i;
i = nullptr;
}
+
+ for (auto &i : blocks) {
+ delete i;
+ i = nullptr;
+ }
}
diff --git a/src/config/Data.hxx b/src/config/Data.hxx
index 56e7d2553..6036c49e6 100644
--- a/src/config/Data.hxx
+++ b/src/config/Data.hxx
@@ -25,9 +25,11 @@
#include <array>
struct config_param;
+struct ConfigBlock;
struct ConfigData {
std::array<config_param *, std::size_t(ConfigOption::MAX)> params;
+ std::array<ConfigBlock *, std::size_t(ConfigBlockOption::MAX)> blocks;
void Clear();
};
diff --git a/src/config/Param.cxx b/src/config/Param.cxx
index 376f50ee7..bfd9743d2 100644
--- a/src/config/Param.cxx
+++ b/src/config/Param.cxx
@@ -19,12 +19,6 @@
#include "config.h"
#include "Param.hxx"
-#include "ConfigPath.hxx"
-#include "util/Error.hxx"
-#include "fs/AllocatedPath.hxx"
-
-#include <assert.h>
-#include <stdlib.h>
config_param::config_param(const char *_value, int _line)
:next(nullptr), value(_value), line(_line), used(false) {}
@@ -33,91 +27,3 @@ config_param::~config_param()
{
delete next;
}
-
-const BlockParam *
-config_param::GetBlockParam(const char *name) const
-{
- for (const auto &i : block_params) {
- if (i.name == name) {
- i.used = true;
- return &i;
- }
- }
-
- return nullptr;
-}
-
-const char *
-config_param::GetBlockValue(const char *name, const char *default_value) const
-{
- const BlockParam *bp = GetBlockParam(name);
- if (bp == nullptr)
- return default_value;
-
- return bp->value.c_str();
-}
-
-AllocatedPath
-config_param::GetBlockPath(const char *name, const char *default_value,
- Error &error) const
-{
- assert(!error.IsDefined());
-
- int line2 = line;
- const char *s;
-
- const BlockParam *bp = GetBlockParam(name);
- if (bp != nullptr) {
- line2 = bp->line;
- s = bp->value.c_str();
- } else {
- if (default_value == nullptr)
- return AllocatedPath::Null();
-
- s = default_value;
- }
-
- AllocatedPath path = ParsePath(s, error);
- if (gcc_unlikely(path.IsNull()))
- error.FormatPrefix("Invalid path in \"%s\" at line %i: ",
- name, line2);
-
- return path;
-}
-
-AllocatedPath
-config_param::GetBlockPath(const char *name, Error &error) const
-{
- return GetBlockPath(name, nullptr, error);
-}
-
-int
-config_param::GetBlockValue(const char *name, int default_value) const
-{
- const BlockParam *bp = GetBlockParam(name);
- if (bp == nullptr)
- return default_value;
-
- return bp->GetIntValue();
-}
-
-unsigned
-config_param::GetBlockValue(const char *name, unsigned default_value) const
-{
- const BlockParam *bp = GetBlockParam(name);
- if (bp == nullptr)
- return default_value;
-
- return bp->GetUnsignedValue();
-}
-
-gcc_pure
-bool
-config_param::GetBlockValue(const char *name, bool default_value) const
-{
- const BlockParam *bp = GetBlockParam(name);
- if (bp == nullptr)
- return default_value;
-
- return bp->GetBoolValue();
-}
diff --git a/src/config/Param.hxx b/src/config/Param.hxx
index a3cd3f83a..e6a039c2a 100644
--- a/src/config/Param.hxx
+++ b/src/config/Param.hxx
@@ -20,14 +20,10 @@
#ifndef MPD_CONFIG_PARAM_HXX
#define MPD_CONFIG_PARAM_HXX
-#include "Block.hxx"
+#include "check.h"
#include "Compiler.h"
#include <string>
-#include <vector>
-
-class AllocatedPath;
-class Error;
struct config_param {
/**
@@ -40,8 +36,6 @@ struct config_param {
int line;
- std::vector<BlockParam> block_params;
-
/**
* This flag is false when nobody has queried the value of
* this option yet.
@@ -68,37 +62,6 @@ struct config_param {
bool IsNull() const {
return line < 0;
}
-
- gcc_nonnull_all
- void AddBlockParam(const char *_name, const char *_value,
- int _line=-1) {
- block_params.emplace_back(_name, _value, _line);
- }
-
- gcc_nonnull_all gcc_pure
- const BlockParam *GetBlockParam(const char *_name) const;
-
- gcc_pure
- const char *GetBlockValue(const char *name,
- const char *default_value=nullptr) const;
-
- /**
- * Same as config_get_path(), but looks up the setting in the
- * specified block.
- */
- AllocatedPath GetBlockPath(const char *name, const char *default_value,
- Error &error) const;
-
- AllocatedPath GetBlockPath(const char *name, Error &error) const;
-
- gcc_pure
- int GetBlockValue(const char *name, int default_value) const;
-
- gcc_pure
- unsigned GetBlockValue(const char *name, unsigned default_value) const;
-
- gcc_pure
- bool GetBlockValue(const char *name, bool default_value) const;
};
#endif
diff --git a/src/db/Configured.cxx b/src/db/Configured.cxx
index 5d53e5951..9ada7f34a 100644
--- a/src/db/Configured.cxx
+++ b/src/db/Configured.cxx
@@ -22,6 +22,7 @@
#include "DatabaseGlue.hxx"
#include "config/ConfigGlobal.hxx"
#include "config/Param.hxx"
+#include "config/Block.hxx"
#include "config/ConfigError.hxx"
#include "fs/AllocatedPath.hxx"
#include "fs/StandardDirectory.hxx"
@@ -32,7 +33,7 @@ Database *
CreateConfiguredDatabase(EventLoop &loop, DatabaseListener &listener,
Error &error)
{
- const auto *param = config_get_param(ConfigOption::DATABASE);
+ const auto *param = config_get_block(ConfigBlockOption::DATABASE);
const auto *path = config_get_param(ConfigOption::DB_FILE);
if (param != nullptr && path != nullptr) {
@@ -42,10 +43,10 @@ CreateConfiguredDatabase(EventLoop &loop, DatabaseListener &listener,
return nullptr;
}
- struct config_param *allocated = nullptr;
+ ConfigBlock *allocated = nullptr;
if (param == nullptr && path != nullptr) {
- allocated = new config_param("database", path->line);
+ allocated = new ConfigBlock(path->line);
allocated->AddBlockParam("path", path->value.c_str(),
path->line);
param = allocated;
@@ -60,7 +61,7 @@ CreateConfiguredDatabase(EventLoop &loop, DatabaseListener &listener,
const auto db_file = AllocatedPath::Build(cache_dir, "mpd.db");
- allocated = new config_param("database");
+ allocated = new ConfigBlock();
allocated->AddBlockParam("path", db_file.c_str(), -1);
param = allocated;
}
diff --git a/src/db/DatabaseGlue.cxx b/src/db/DatabaseGlue.cxx
index 3ba1b8148..193b672e9 100644
--- a/src/db/DatabaseGlue.cxx
+++ b/src/db/DatabaseGlue.cxx
@@ -22,17 +22,17 @@
#include "Registry.hxx"
#include "DatabaseError.hxx"
#include "util/Error.hxx"
-#include "config/Param.hxx"
+#include "config/Block.hxx"
#include "DatabasePlugin.hxx"
#include <string.h>
Database *
DatabaseGlobalInit(EventLoop &loop, DatabaseListener &listener,
- const config_param &param, Error &error)
+ const ConfigBlock &block, Error &error)
{
const char *plugin_name =
- param.GetBlockValue("plugin", "simple");
+ block.GetBlockValue("plugin", "simple");
const DatabasePlugin *plugin = GetDatabasePluginByName(plugin_name);
if (plugin == nullptr) {
@@ -41,5 +41,5 @@ DatabaseGlobalInit(EventLoop &loop, DatabaseListener &listener,
return nullptr;
}
- return plugin->create(loop, listener, param, error);
+ return plugin->create(loop, listener, block, error);
}
diff --git a/src/db/DatabaseGlue.hxx b/src/db/DatabaseGlue.hxx
index c35dd1cbd..67ff4f537 100644
--- a/src/db/DatabaseGlue.hxx
+++ b/src/db/DatabaseGlue.hxx
@@ -22,7 +22,7 @@
#include "Compiler.h"
-struct config_param;
+struct ConfigBlock;
class EventLoop;
class DatabaseListener;
class Database;
@@ -35,6 +35,6 @@ class Error;
*/
Database *
DatabaseGlobalInit(EventLoop &loop, DatabaseListener &listener,
- const config_param &param, Error &error);
+ const ConfigBlock &block, Error &error);
#endif
diff --git a/src/db/DatabasePlugin.hxx b/src/db/DatabasePlugin.hxx
index 4497b8b91..116aa59d2 100644
--- a/src/db/DatabasePlugin.hxx
+++ b/src/db/DatabasePlugin.hxx
@@ -26,7 +26,7 @@
#ifndef MPD_DATABASE_PLUGIN_HXX
#define MPD_DATABASE_PLUGIN_HXX
-struct config_param;
+struct ConfigBlock;
class Error;
class EventLoop;
class DatabaseListener;
@@ -47,7 +47,7 @@ struct DatabasePlugin {
* Allocates and configures a database.
*/
Database *(*create)(EventLoop &loop, DatabaseListener &listener,
- const config_param &param,
+ const ConfigBlock &block,
Error &error);
constexpr bool RequireStorage() const {
diff --git a/src/db/plugins/ProxyDatabasePlugin.cxx b/src/db/plugins/ProxyDatabasePlugin.cxx
index 1a94000b2..67c651e83 100644
--- a/src/db/plugins/ProxyDatabasePlugin.cxx
+++ b/src/db/plugins/ProxyDatabasePlugin.cxx
@@ -30,7 +30,7 @@
#include "db/Stats.hxx"
#include "SongFilter.hxx"
#include "Compiler.h"
-#include "config/Param.hxx"
+#include "config/Block.hxx"
#include "tag/TagBuilder.hxx"
#include "tag/Tag.hxx"
#include "util/Error.hxx"
@@ -97,7 +97,7 @@ public:
listener(_listener) {}
static Database *Create(EventLoop &loop, DatabaseListener &listener,
- const config_param &param,
+ const ConfigBlock &block,
Error &error);
virtual bool Open(Error &error) override;
@@ -129,7 +129,7 @@ public:
}
private:
- bool Configure(const config_param &param, Error &error);
+ bool Configure(const ConfigBlock &block, Error &error);
bool Connect(Error &error);
bool CheckConnection(Error &error);
@@ -321,10 +321,10 @@ SendConstraints(mpd_connection *connection, const DatabaseSelection &selection)
Database *
ProxyDatabase::Create(EventLoop &loop, DatabaseListener &listener,
- const config_param &param, Error &error)
+ const ConfigBlock &block, Error &error)
{
ProxyDatabase *db = new ProxyDatabase(loop, listener);
- if (!db->Configure(param, error)) {
+ if (!db->Configure(block, error)) {
delete db;
db = nullptr;
}
@@ -333,11 +333,11 @@ ProxyDatabase::Create(EventLoop &loop, DatabaseListener &listener,
}
bool
-ProxyDatabase::Configure(const config_param &param, gcc_unused Error &error)
+ProxyDatabase::Configure(const ConfigBlock &block, gcc_unused Error &error)
{
- host = param.GetBlockValue("host", "");
- port = param.GetBlockValue("port", 0u);
- keepalive = param.GetBlockValue("keepalive", false);
+ host = block.GetBlockValue("host", "");
+ port = block.GetBlockValue("port", 0u);
+ keepalive = block.GetBlockValue("keepalive", false);
return true;
}
diff --git a/src/db/plugins/simple/SimpleDatabasePlugin.cxx b/src/db/plugins/simple/SimpleDatabasePlugin.cxx
index 18faf46df..da8d44fb0 100644
--- a/src/db/plugins/simple/SimpleDatabasePlugin.cxx
+++ b/src/db/plugins/simple/SimpleDatabasePlugin.cxx
@@ -34,7 +34,7 @@
#include "fs/io/TextFile.hxx"
#include "fs/io/BufferedOutputStream.hxx"
#include "fs/io/FileOutputStream.hxx"
-#include "config/Param.hxx"
+#include "config/Block.hxx"
#include "fs/FileSystem.hxx"
#include "util/CharUtil.hxx"
#include "util/Error.hxx"
@@ -76,10 +76,10 @@ inline SimpleDatabase::SimpleDatabase(AllocatedPath &&_path,
Database *
SimpleDatabase::Create(gcc_unused EventLoop &loop,
gcc_unused DatabaseListener &listener,
- const config_param &param, Error &error)
+ const ConfigBlock &block, Error &error)
{
SimpleDatabase *db = new SimpleDatabase();
- if (!db->Configure(param, error)) {
+ if (!db->Configure(block, error)) {
delete db;
db = nullptr;
}
@@ -88,9 +88,9 @@ SimpleDatabase::Create(gcc_unused EventLoop &loop,
}
bool
-SimpleDatabase::Configure(const config_param &param, Error &error)
+SimpleDatabase::Configure(const ConfigBlock &block, Error &error)
{
- path = param.GetBlockPath("path", error);
+ path = block.GetBlockPath("path", error);
if (path.IsNull()) {
if (!error.IsDefined())
error.Set(simple_db_domain,
@@ -100,12 +100,12 @@ SimpleDatabase::Configure(const config_param &param, Error &error)
path_utf8 = path.ToUTF8();
- cache_path = param.GetBlockPath("cache_directory", error);
+ cache_path = block.GetBlockPath("cache_directory", error);
if (path.IsNull() && error.IsDefined())
return false;
#ifdef ENABLE_ZLIB
- compress = param.GetBlockValue("compress", compress);
+ compress = block.GetBlockValue("compress", compress);
#endif
return true;
diff --git a/src/db/plugins/simple/SimpleDatabasePlugin.hxx b/src/db/plugins/simple/SimpleDatabasePlugin.hxx
index 2e2d39a86..fc720ecf8 100644
--- a/src/db/plugins/simple/SimpleDatabasePlugin.hxx
+++ b/src/db/plugins/simple/SimpleDatabasePlugin.hxx
@@ -28,7 +28,7 @@
#include <cassert>
-struct config_param;
+struct ConfigBlock;
struct Directory;
struct DatabasePlugin;
class EventLoop;
@@ -73,7 +73,7 @@ class SimpleDatabase : public Database {
public:
static Database *Create(EventLoop &loop, DatabaseListener &listener,
- const config_param &param,
+ const ConfigBlock &block,
Error &error);
gcc_pure
@@ -134,7 +134,7 @@ public:
}
private:
- bool Configure(const config_param &param, Error &error);
+ bool Configure(const ConfigBlock &block, Error &error);
gcc_pure
bool Check(Error &error) const;
diff --git a/src/db/plugins/upnp/UpnpDatabasePlugin.cxx b/src/db/plugins/upnp/UpnpDatabasePlugin.cxx
index 2f666acbe..9f0841780 100644
--- a/src/db/plugins/upnp/UpnpDatabasePlugin.cxx
+++ b/src/db/plugins/upnp/UpnpDatabasePlugin.cxx
@@ -33,7 +33,7 @@
#include "db/LightDirectory.hxx"
#include "db/LightSong.hxx"
#include "db/Stats.hxx"
-#include "config/Param.hxx"
+#include "config/Block.hxx"
#include "tag/TagBuilder.hxx"
#include "tag/TagTable.hxx"
#include "util/Error.hxx"
@@ -78,7 +78,7 @@ public:
UpnpDatabase():Database(upnp_db_plugin) {}
static Database *Create(EventLoop &loop, DatabaseListener &listener,
- const config_param &param,
+ const ConfigBlock &block,
Error &error);
virtual bool Open(Error &error) override;
@@ -106,7 +106,7 @@ public:
}
protected:
- bool Configure(const config_param &param, Error &error);
+ bool Configure(const ConfigBlock &block, Error &error);
private:
bool VisitServer(const ContentDirectoryService &server,
@@ -158,10 +158,10 @@ private:
Database *
UpnpDatabase::Create(gcc_unused EventLoop &loop,
gcc_unused DatabaseListener &listener,
- const config_param &param, Error &error)
+ const ConfigBlock &block, Error &error)
{
UpnpDatabase *db = new UpnpDatabase();
- if (!db->Configure(param, error)) {
+ if (!db->Configure(block, error)) {
delete db;
return nullptr;
}
@@ -173,7 +173,7 @@ UpnpDatabase::Create(gcc_unused EventLoop &loop,
}
inline bool
-UpnpDatabase::Configure(const config_param &, Error &)
+UpnpDatabase::Configure(const ConfigBlock &, Error &)
{
return true;
}
diff --git a/src/decoder/DecoderAPI.hxx b/src/decoder/DecoderAPI.hxx
index 12e464801..cb53f4ec5 100644
--- a/src/decoder/DecoderAPI.hxx
+++ b/src/decoder/DecoderAPI.hxx
@@ -36,7 +36,7 @@
#include "tag/Tag.hxx"
#include "AudioFormat.hxx"
#include "MixRampInfo.hxx"
-#include "config/Param.hxx"
+#include "config/Block.hxx"
#include "Chrono.hxx"
// IWYU pragma: end_exports
diff --git a/src/decoder/DecoderList.cxx b/src/decoder/DecoderList.cxx
index 56cc83eba..e153b1398 100644
--- a/src/decoder/DecoderList.cxx
+++ b/src/decoder/DecoderList.cxx
@@ -21,7 +21,7 @@
#include "DecoderList.hxx"
#include "DecoderPlugin.hxx"
#include "config/ConfigGlobal.hxx"
-#include "config/Param.hxx"
+#include "config/Block.hxx"
#include "plugins/AudiofileDecoderPlugin.hxx"
#include "plugins/PcmDecoderPlugin.hxx"
#include "plugins/DsdiffDecoderPlugin.hxx"
@@ -127,12 +127,12 @@ decoder_plugin_from_name(const char *name)
void decoder_plugin_init_all(void)
{
- struct config_param empty;
+ ConfigBlock empty;
for (unsigned i = 0; decoder_plugins[i] != nullptr; ++i) {
const DecoderPlugin &plugin = *decoder_plugins[i];
- const struct config_param *param =
- config_find_block(ConfigOption::DECODER, "plugin",
+ const auto *param =
+ config_find_block(ConfigBlockOption::DECODER, "plugin",
plugin.name);
if (param == nullptr)
diff --git a/src/decoder/DecoderPlugin.hxx b/src/decoder/DecoderPlugin.hxx
index 92364463e..ef275266c 100644
--- a/src/decoder/DecoderPlugin.hxx
+++ b/src/decoder/DecoderPlugin.hxx
@@ -22,7 +22,7 @@
#include "Compiler.h"
-struct config_param;
+struct ConfigBlock;
class InputStream;
struct tag_handler;
class Path;
@@ -44,7 +44,7 @@ struct DecoderPlugin {
* @return true if the plugin was initialized successfully,
* false if the plugin is not available
*/
- bool (*init)(const config_param &param);
+ bool (*init)(const ConfigBlock &block);
/**
* Deinitialize a decoder plugin which was initialized
@@ -112,9 +112,9 @@ struct DecoderPlugin {
* @return true if the plugin was initialized successfully, false if
* the plugin is not available
*/
- bool Init(const config_param &param) const {
+ bool Init(const ConfigBlock &block) const {
return init != nullptr
- ? init(param)
+ ? init(block)
: true;
}
diff --git a/src/decoder/plugins/AdPlugDecoderPlugin.cxx b/src/decoder/plugins/AdPlugDecoderPlugin.cxx
index 5c495f74f..dd3f2b7ff 100644
--- a/src/decoder/plugins/AdPlugDecoderPlugin.cxx
+++ b/src/decoder/plugins/AdPlugDecoderPlugin.cxx
@@ -38,14 +38,14 @@ static constexpr Domain adplug_domain("adplug");
static unsigned sample_rate;
static bool
-adplug_init(const config_param &param)
+adplug_init(const ConfigBlock &block)
{
FormatDebug(adplug_domain, "adplug %s",
CAdPlug::get_version().c_str());
Error error;
- sample_rate = param.GetBlockValue("sample_rate", 48000u);
+ sample_rate = block.GetBlockValue("sample_rate", 48000u);
if (!audio_check_sample_rate(sample_rate, error)) {
LogError(error);
return false;
diff --git a/src/decoder/plugins/AudiofileDecoderPlugin.cxx b/src/decoder/plugins/AudiofileDecoderPlugin.cxx
index 5e3db7073..7d59d9460 100644
--- a/src/decoder/plugins/AudiofileDecoderPlugin.cxx
+++ b/src/decoder/plugins/AudiofileDecoderPlugin.cxx
@@ -43,7 +43,7 @@ audiofile_error_func(long, const char *msg)
}
static bool
-audiofile_init(const config_param &)
+audiofile_init(const ConfigBlock &)
{
afSetErrorHandler(audiofile_error_func);
return true;
diff --git a/src/decoder/plugins/DsdiffDecoderPlugin.cxx b/src/decoder/plugins/DsdiffDecoderPlugin.cxx
index 4e7d32bfd..bd587e0ce 100644
--- a/src/decoder/plugins/DsdiffDecoderPlugin.cxx
+++ b/src/decoder/plugins/DsdiffDecoderPlugin.cxx
@@ -72,9 +72,9 @@ struct DsdiffMetaData {
static bool lsbitfirst;
static bool
-dsdiff_init(const config_param &param)
+dsdiff_init(const ConfigBlock &block)
{
- lsbitfirst = param.GetBlockValue("lsbitfirst", false);
+ lsbitfirst = block.GetBlockValue("lsbitfirst", false);
return true;
}
diff --git a/src/decoder/plugins/FfmpegDecoderPlugin.cxx b/src/decoder/plugins/FfmpegDecoderPlugin.cxx
index 772922865..faff70c66 100644
--- a/src/decoder/plugins/FfmpegDecoderPlugin.cxx
+++ b/src/decoder/plugins/FfmpegDecoderPlugin.cxx
@@ -73,7 +73,7 @@ FfmpegOpenInput(AVIOContext *pb,
}
static bool
-ffmpeg_init(gcc_unused const config_param &param)
+ffmpeg_init(gcc_unused const ConfigBlock &block)
{
FfmpegInit();
return true;
diff --git a/src/decoder/plugins/FlacDecoderPlugin.cxx b/src/decoder/plugins/FlacDecoderPlugin.cxx
index 5e674b35b..1455f7084 100644
--- a/src/decoder/plugins/FlacDecoderPlugin.cxx
+++ b/src/decoder/plugins/FlacDecoderPlugin.cxx
@@ -291,7 +291,7 @@ flac_decode(Decoder &decoder, InputStream &input_stream)
}
static bool
-oggflac_init(gcc_unused const config_param &param)
+oggflac_init(gcc_unused const ConfigBlock &block)
{
return !!FLAC_API_SUPPORTS_OGG_FLAC;
}
diff --git a/src/decoder/plugins/FluidsynthDecoderPlugin.cxx b/src/decoder/plugins/FluidsynthDecoderPlugin.cxx
index 7a3b16199..2b4967b95 100644
--- a/src/decoder/plugins/FluidsynthDecoderPlugin.cxx
+++ b/src/decoder/plugins/FluidsynthDecoderPlugin.cxx
@@ -73,17 +73,17 @@ fluidsynth_mpd_log_function(int level, char *message, gcc_unused void *data)
}
static bool
-fluidsynth_init(const config_param &param)
+fluidsynth_init(const ConfigBlock &block)
{
Error error;
- sample_rate = param.GetBlockValue("sample_rate", 48000u);
+ sample_rate = block.GetBlockValue("sample_rate", 48000u);
if (!audio_check_sample_rate(sample_rate, error)) {
LogError(error);
return false;
}
- soundfont_path = param.GetBlockValue("soundfont",
+ soundfont_path = block.GetBlockValue("soundfont",
"/usr/share/sounds/sf2/FluidR3_GM.sf2");
fluid_set_log_function(LAST_LOG_LEVEL,
diff --git a/src/decoder/plugins/MadDecoderPlugin.cxx b/src/decoder/plugins/MadDecoderPlugin.cxx
index 6e6feabc1..ea2c9ac6c 100644
--- a/src/decoder/plugins/MadDecoderPlugin.cxx
+++ b/src/decoder/plugins/MadDecoderPlugin.cxx
@@ -107,7 +107,7 @@ mad_fixed_to_24_buffer(int32_t *dest, const struct mad_synth *synth,
}
static bool
-mp3_plugin_init(gcc_unused const config_param &param)
+mp3_plugin_init(gcc_unused const ConfigBlock &block)
{
gapless_playback = config_get_bool(ConfigOption::GAPLESS_MP3_PLAYBACK,
DEFAULT_GAPLESS_MP3_PLAYBACK);
diff --git a/src/decoder/plugins/MikmodDecoderPlugin.cxx b/src/decoder/plugins/MikmodDecoderPlugin.cxx
index 95f619061..135bae15a 100644
--- a/src/decoder/plugins/MikmodDecoderPlugin.cxx
+++ b/src/decoder/plugins/MikmodDecoderPlugin.cxx
@@ -109,15 +109,15 @@ static bool mikmod_loop;
static unsigned mikmod_sample_rate;
static bool
-mikmod_decoder_init(const config_param &param)
+mikmod_decoder_init(const ConfigBlock &block)
{
static char params[] = "";
- mikmod_loop = param.GetBlockValue("loop", false);
- mikmod_sample_rate = param.GetBlockValue("sample_rate", 44100u);
+ mikmod_loop = block.GetBlockValue("loop", false);
+ mikmod_sample_rate = block.GetBlockValue("sample_rate", 44100u);
if (!audio_valid_sample_rate(mikmod_sample_rate))
FormatFatalError("Invalid sample rate in line %d: %u",
- param.line, mikmod_sample_rate);
+ block.line, mikmod_sample_rate);
md_device = 0;
md_reverb = 0;
diff --git a/src/decoder/plugins/ModplugDecoderPlugin.cxx b/src/decoder/plugins/ModplugDecoderPlugin.cxx
index fb65ded67..153392929 100644
--- a/src/decoder/plugins/ModplugDecoderPlugin.cxx
+++ b/src/decoder/plugins/ModplugDecoderPlugin.cxx
@@ -41,12 +41,12 @@ static constexpr offset_type MODPLUG_FILE_LIMIT = 100 * 1024 * 1024;
static int modplug_loop_count;
static bool
-modplug_decoder_init(const config_param &param)
+modplug_decoder_init(const ConfigBlock &block)
{
- modplug_loop_count = param.GetBlockValue("loop_count", 0);
+ modplug_loop_count = block.GetBlockValue("loop_count", 0);
if (modplug_loop_count < -1)
FormatFatalError("Invalid loop count in line %d: %i",
- param.line, modplug_loop_count);
+ block.line, modplug_loop_count);
return true;
}
diff --git a/src/decoder/plugins/Mpg123DecoderPlugin.cxx b/src/decoder/plugins/Mpg123DecoderPlugin.cxx
index 5d66eda5c..760b8b9c2 100644
--- a/src/decoder/plugins/Mpg123DecoderPlugin.cxx
+++ b/src/decoder/plugins/Mpg123DecoderPlugin.cxx
@@ -37,7 +37,7 @@
static constexpr Domain mpg123_domain("mpg123");
static bool
-mpd_mpg123_init(gcc_unused const config_param &param)
+mpd_mpg123_init(gcc_unused const ConfigBlock &block)
{
mpg123_init();
diff --git a/src/decoder/plugins/OpusDecoderPlugin.cxx b/src/decoder/plugins/OpusDecoderPlugin.cxx
index 345df1111..0d03566a7 100644
--- a/src/decoder/plugins/OpusDecoderPlugin.cxx
+++ b/src/decoder/plugins/OpusDecoderPlugin.cxx
@@ -61,7 +61,7 @@ IsOpusTags(const ogg_packet &packet)
}
static bool
-mpd_opus_init(gcc_unused const config_param &param)
+mpd_opus_init(gcc_unused const ConfigBlock &block)
{
LogDebug(opus_domain, opus_get_version_string());
diff --git a/src/decoder/plugins/SidplayDecoderPlugin.cxx b/src/decoder/plugins/SidplayDecoderPlugin.cxx
index 4bb31db34..0d17e98c4 100644
--- a/src/decoder/plugins/SidplayDecoderPlugin.cxx
+++ b/src/decoder/plugins/SidplayDecoderPlugin.cxx
@@ -64,22 +64,22 @@ sidplay_load_songlength_db(const Path path)
}
static bool
-sidplay_init(const config_param &param)
+sidplay_init(const ConfigBlock &block)
{
/* read the songlengths database file */
Error error;
- const auto database_path = param.GetBlockPath("songlength_database", error);
+ const auto database_path = block.GetBlockPath("songlength_database", error);
if (!database_path.IsNull())
songlength_database = sidplay_load_songlength_db(database_path);
else if (error.IsDefined())
FatalError(error);
- default_songlength = param.GetBlockValue("default_songlength", 0u);
+ default_songlength = block.GetBlockValue("default_songlength", 0u);
all_files_are_containers =
- param.GetBlockValue("all_files_are_containers", true);
+ block.GetBlockValue("all_files_are_containers", true);
- filter_setting = param.GetBlockValue("filter", true);
+ filter_setting = block.GetBlockValue("filter", true);
return true;
}
diff --git a/src/decoder/plugins/SndfileDecoderPlugin.cxx b/src/decoder/plugins/SndfileDecoderPlugin.cxx
index f84cb02aa..68ca20cc7 100644
--- a/src/decoder/plugins/SndfileDecoderPlugin.cxx
+++ b/src/decoder/plugins/SndfileDecoderPlugin.cxx
@@ -32,7 +32,7 @@
static constexpr Domain sndfile_domain("sndfile");
static bool
-sndfile_init(gcc_unused const config_param &param)
+sndfile_init(gcc_unused const ConfigBlock &block)
{
LogDebug(sndfile_domain, sf_version_string());
return true;
diff --git a/src/decoder/plugins/VorbisDecoderPlugin.cxx b/src/decoder/plugins/VorbisDecoderPlugin.cxx
index 7b2fae4d7..d569f747e 100644
--- a/src/decoder/plugins/VorbisDecoderPlugin.cxx
+++ b/src/decoder/plugins/VorbisDecoderPlugin.cxx
@@ -194,7 +194,7 @@ vorbis_interleave(float *dest, const float *const*src,
/* public */
static bool
-vorbis_init(gcc_unused const config_param &param)
+vorbis_init(gcc_unused const ConfigBlock &block)
{
#ifndef HAVE_TREMOR
LogDebug(vorbis_domain, vorbis_version_string());
diff --git a/src/decoder/plugins/WildmidiDecoderPlugin.cxx b/src/decoder/plugins/WildmidiDecoderPlugin.cxx
index 6b3307f44..64fa33b05 100644
--- a/src/decoder/plugins/WildmidiDecoderPlugin.cxx
+++ b/src/decoder/plugins/WildmidiDecoderPlugin.cxx
@@ -38,11 +38,11 @@ static constexpr Domain wildmidi_domain("wildmidi");
static constexpr unsigned WILDMIDI_SAMPLE_RATE = 48000;
static bool
-wildmidi_init(const config_param &param)
+wildmidi_init(const ConfigBlock &block)
{
Error error;
const AllocatedPath path =
- param.GetBlockPath("config_file",
+ block.GetBlockPath("config_file",
"/etc/timidity/timidity.cfg",
error);
if (path.IsNull())
diff --git a/src/encoder/EncoderAPI.hxx b/src/encoder/EncoderAPI.hxx
index a266667fd..def543c58 100644
--- a/src/encoder/EncoderAPI.hxx
+++ b/src/encoder/EncoderAPI.hxx
@@ -31,7 +31,7 @@
#include "EncoderPlugin.hxx"
#include "AudioFormat.hxx"
#include "tag/Tag.hxx"
-#include "config/Param.hxx"
+#include "config/Block.hxx"
// IWYU pragma: end_exports
diff --git a/src/encoder/EncoderPlugin.hxx b/src/encoder/EncoderPlugin.hxx
index 99a68dce6..f990bf105 100644
--- a/src/encoder/EncoderPlugin.hxx
+++ b/src/encoder/EncoderPlugin.hxx
@@ -24,14 +24,14 @@
struct Encoder;
struct AudioFormat;
-struct config_param;
+struct ConfigBlock;
struct Tag;
class Error;
struct EncoderPlugin {
const char *name;
- Encoder *(*init)(const config_param &param,
+ Encoder *(*init)(const ConfigBlock &block,
Error &error);
void (*finish)(Encoder *encoder);
@@ -69,10 +69,10 @@ struct EncoderPlugin {
* @return an encoder object on success, nullptr on failure
*/
static inline Encoder *
-encoder_init(const EncoderPlugin &plugin, const config_param &param,
+encoder_init(const EncoderPlugin &plugin, const ConfigBlock &block,
Error &error_r)
{
- return plugin.init(param, error_r);
+ return plugin.init(block, error_r);
}
#endif
diff --git a/src/encoder/plugins/FlacEncoderPlugin.cxx b/src/encoder/plugins/FlacEncoderPlugin.cxx
index c2df7cbf6..afeef3b84 100644
--- a/src/encoder/plugins/FlacEncoderPlugin.cxx
+++ b/src/encoder/plugins/FlacEncoderPlugin.cxx
@@ -56,21 +56,21 @@ struct flac_encoder {
static constexpr Domain flac_encoder_domain("vorbis_encoder");
static bool
-flac_encoder_configure(struct flac_encoder *encoder, const config_param &param,
+flac_encoder_configure(struct flac_encoder *encoder, const ConfigBlock &block,
gcc_unused Error &error)
{
- encoder->compression = param.GetBlockValue("compression", 5u);
+ encoder->compression = block.GetBlockValue("compression", 5u);
return true;
}
static Encoder *
-flac_encoder_init(const config_param &param, Error &error)
+flac_encoder_init(const ConfigBlock &block, Error &error)
{
flac_encoder *encoder = new flac_encoder();
- /* load configuration from "param" */
- if (!flac_encoder_configure(encoder, param, error)) {
+ /* load configuration from "block" */
+ if (!flac_encoder_configure(encoder, block, error)) {
/* configuration has failed, roll back and return error */
delete encoder;
return nullptr;
diff --git a/src/encoder/plugins/LameEncoderPlugin.cxx b/src/encoder/plugins/LameEncoderPlugin.cxx
index ddcd14b9d..7c6313109 100644
--- a/src/encoder/plugins/LameEncoderPlugin.cxx
+++ b/src/encoder/plugins/LameEncoderPlugin.cxx
@@ -47,18 +47,18 @@ struct LameEncoder final {
LameEncoder():encoder(lame_encoder_plugin) {}
- bool Configure(const config_param &param, Error &error);
+ bool Configure(const ConfigBlock &block, Error &error);
};
static constexpr Domain lame_encoder_domain("lame_encoder");
bool
-LameEncoder::Configure(const config_param &param, Error &error)
+LameEncoder::Configure(const ConfigBlock &block, Error &error)
{
const char *value;
char *endptr;
- value = param.GetBlockValue("quality");
+ value = block.GetBlockValue("quality");
if (value != nullptr) {
/* a quality was configured (VBR) */
@@ -72,7 +72,7 @@ LameEncoder::Configure(const config_param &param, Error &error)
return false;
}
- if (param.GetBlockValue("bitrate") != nullptr) {
+ if (block.GetBlockValue("bitrate") != nullptr) {
error.Set(config_domain,
"quality and bitrate are both defined");
return false;
@@ -80,7 +80,7 @@ LameEncoder::Configure(const config_param &param, Error &error)
} else {
/* a bit rate was configured */
- value = param.GetBlockValue("bitrate");
+ value = block.GetBlockValue("bitrate");
if (value == nullptr) {
error.Set(config_domain,
"neither bitrate nor quality defined");
@@ -101,12 +101,12 @@ LameEncoder::Configure(const config_param &param, Error &error)
}
static Encoder *
-lame_encoder_init(const config_param &param, Error &error)
+lame_encoder_init(const ConfigBlock &block, Error &error)
{
LameEncoder *encoder = new LameEncoder();
- /* load configuration from "param" */
- if (!encoder->Configure(param, error)) {
+ /* load configuration from "block" */
+ if (!encoder->Configure(block, error)) {
/* configuration has failed, roll back and return error */
delete encoder;
return nullptr;
diff --git a/src/encoder/plugins/NullEncoderPlugin.cxx b/src/encoder/plugins/NullEncoderPlugin.cxx
index eb2c4ef3f..99be7aec4 100644
--- a/src/encoder/plugins/NullEncoderPlugin.cxx
+++ b/src/encoder/plugins/NullEncoderPlugin.cxx
@@ -36,7 +36,7 @@ struct NullEncoder final {
};
static Encoder *
-null_encoder_init(gcc_unused const config_param &param,
+null_encoder_init(gcc_unused const ConfigBlock &block,
gcc_unused Error &error)
{
NullEncoder *encoder = new NullEncoder();
diff --git a/src/encoder/plugins/OpusEncoderPlugin.cxx b/src/encoder/plugins/OpusEncoderPlugin.cxx
index 6a691d48e..4fd40cd50 100644
--- a/src/encoder/plugins/OpusEncoderPlugin.cxx
+++ b/src/encoder/plugins/OpusEncoderPlugin.cxx
@@ -73,9 +73,9 @@ static constexpr Domain opus_encoder_domain("opus_encoder");
static bool
opus_encoder_configure(struct opus_encoder *encoder,
- const config_param &param, Error &error)
+ const ConfigBlock &block, Error &error)
{
- const char *value = param.GetBlockValue("bitrate", "auto");
+ const char *value = block.GetBlockValue("bitrate", "auto");
if (strcmp(value, "auto") == 0)
encoder->bitrate = OPUS_AUTO;
else if (strcmp(value, "max") == 0)
@@ -90,13 +90,13 @@ opus_encoder_configure(struct opus_encoder *encoder,
}
}
- encoder->complexity = param.GetBlockValue("complexity", 10u);
+ encoder->complexity = block.GetBlockValue("complexity", 10u);
if (encoder->complexity > 10) {
error.Format(config_domain, "Invalid complexity");
return false;
}
- value = param.GetBlockValue("signal", "auto");
+ value = block.GetBlockValue("signal", "auto");
if (strcmp(value, "auto") == 0)
encoder->signal = OPUS_AUTO;
else if (strcmp(value, "voice") == 0)
@@ -112,12 +112,12 @@ opus_encoder_configure(struct opus_encoder *encoder,
}
static Encoder *
-opus_encoder_init(const config_param &param, Error &error)
+opus_encoder_init(const ConfigBlock &block, Error &error)
{
opus_encoder *encoder = new opus_encoder();
- /* load configuration from "param" */
- if (!opus_encoder_configure(encoder, param, error)) {
+ /* load configuration from "block" */
+ if (!opus_encoder_configure(encoder, block, error)) {
/* configuration has failed, roll back and return error */
delete encoder;
return nullptr;
diff --git a/src/encoder/plugins/ShineEncoderPlugin.cxx b/src/encoder/plugins/ShineEncoderPlugin.cxx
index 72dc305e6..c397906d3 100644
--- a/src/encoder/plugins/ShineEncoderPlugin.cxx
+++ b/src/encoder/plugins/ShineEncoderPlugin.cxx
@@ -53,7 +53,7 @@ struct ShineEncoder {
ShineEncoder():encoder(shine_encoder_plugin){}
- bool Configure(const config_param &param, Error &error);
+ bool Configure(const ConfigBlock &block, Error &error);
bool Setup(Error &error);
@@ -63,22 +63,21 @@ struct ShineEncoder {
static constexpr Domain shine_encoder_domain("shine_encoder");
inline bool
-ShineEncoder::Configure(const config_param &param,
- gcc_unused Error &error)
+ShineEncoder::Configure(const ConfigBlock &block, gcc_unused Error &error)
{
shine_set_config_mpeg_defaults(&config.mpeg);
- config.mpeg.bitr = param.GetBlockValue("bitrate", 128);
+ config.mpeg.bitr = block.GetBlockValue("bitrate", 128);
return true;
}
static Encoder *
-shine_encoder_init(const config_param &param, Error &error)
+shine_encoder_init(const ConfigBlock &block, Error &error)
{
ShineEncoder *encoder = new ShineEncoder();
- /* load configuration from "param" */
- if (!encoder->Configure(param, error)) {
+ /* load configuration from "block" */
+ if (!encoder->Configure(block, error)) {
/* configuration has failed, roll back and return error */
delete encoder;
return nullptr;
diff --git a/src/encoder/plugins/TwolameEncoderPlugin.cxx b/src/encoder/plugins/TwolameEncoderPlugin.cxx
index 51a06a4a4..262fc6c33 100644
--- a/src/encoder/plugins/TwolameEncoderPlugin.cxx
+++ b/src/encoder/plugins/TwolameEncoderPlugin.cxx
@@ -53,18 +53,18 @@ struct TwolameEncoder final {
TwolameEncoder():encoder(twolame_encoder_plugin) {}
- bool Configure(const config_param &param, Error &error);
+ bool Configure(const ConfigBlock &block, Error &error);
};
static constexpr Domain twolame_encoder_domain("twolame_encoder");
bool
-TwolameEncoder::Configure(const config_param &param, Error &error)
+TwolameEncoder::Configure(const ConfigBlock &block, Error &error)
{
const char *value;
char *endptr;
- value = param.GetBlockValue("quality");
+ value = block.GetBlockValue("quality");
if (value != nullptr) {
/* a quality was configured (VBR) */
@@ -78,7 +78,7 @@ TwolameEncoder::Configure(const config_param &param, Error &error)
return false;
}
- if (param.GetBlockValue("bitrate") != nullptr) {
+ if (block.GetBlockValue("bitrate") != nullptr) {
error.Set(config_domain,
"quality and bitrate are both defined");
return false;
@@ -86,7 +86,7 @@ TwolameEncoder::Configure(const config_param &param, Error &error)
} else {
/* a bit rate was configured */
- value = param.GetBlockValue("bitrate");
+ value = block.GetBlockValue("bitrate");
if (value == nullptr) {
error.Set(config_domain,
"neither bitrate nor quality defined");
@@ -107,15 +107,15 @@ TwolameEncoder::Configure(const config_param &param, Error &error)
}
static Encoder *
-twolame_encoder_init(const config_param &param, Error &error_r)
+twolame_encoder_init(const ConfigBlock &block, Error &error_r)
{
FormatDebug(twolame_encoder_domain,
"libtwolame version %s", get_twolame_version());
TwolameEncoder *encoder = new TwolameEncoder();
- /* load configuration from "param" */
- if (!encoder->Configure(param, error_r)) {
+ /* load configuration from "block" */
+ if (!encoder->Configure(block, error_r)) {
/* configuration has failed, roll back and return error */
delete encoder;
return nullptr;
diff --git a/src/encoder/plugins/VorbisEncoderPlugin.cxx b/src/encoder/plugins/VorbisEncoderPlugin.cxx
index d84f33b84..11e057eaa 100644
--- a/src/encoder/plugins/VorbisEncoderPlugin.cxx
+++ b/src/encoder/plugins/VorbisEncoderPlugin.cxx
@@ -58,9 +58,9 @@ static constexpr Domain vorbis_encoder_domain("vorbis_encoder");
static bool
vorbis_encoder_configure(struct vorbis_encoder &encoder,
- const config_param &param, Error &error)
+ const ConfigBlock &block, Error &error)
{
- const char *value = param.GetBlockValue("quality");
+ const char *value = block.GetBlockValue("quality");
if (value != nullptr) {
/* a quality was configured (VBR) */
@@ -76,7 +76,7 @@ vorbis_encoder_configure(struct vorbis_encoder &encoder,
return false;
}
- if (param.GetBlockValue("bitrate") != nullptr) {
+ if (block.GetBlockValue("bitrate") != nullptr) {
error.Set(config_domain,
"quality and bitrate are both defined");
return false;
@@ -84,7 +84,7 @@ vorbis_encoder_configure(struct vorbis_encoder &encoder,
} else {
/* a bit rate was configured */
- value = param.GetBlockValue("bitrate");
+ value = block.GetBlockValue("bitrate");
if (value == nullptr) {
error.Set(config_domain,
"neither bitrate nor quality defined");
@@ -106,12 +106,12 @@ vorbis_encoder_configure(struct vorbis_encoder &encoder,
}
static Encoder *
-vorbis_encoder_init(const config_param &param, Error &error)
+vorbis_encoder_init(const ConfigBlock &block, Error &error)
{
vorbis_encoder *encoder = new vorbis_encoder();
- /* load configuration from "param" */
- if (!vorbis_encoder_configure(*encoder, param, error)) {
+ /* load configuration from "block" */
+ if (!vorbis_encoder_configure(*encoder, block, error)) {
/* configuration has failed, roll back and return error */
delete encoder;
return nullptr;
diff --git a/src/encoder/plugins/WaveEncoderPlugin.cxx b/src/encoder/plugins/WaveEncoderPlugin.cxx
index 92a6330f1..3493bed3a 100644
--- a/src/encoder/plugins/WaveEncoderPlugin.cxx
+++ b/src/encoder/plugins/WaveEncoderPlugin.cxx
@@ -79,7 +79,7 @@ fill_wave_header(struct wave_header *header, int channels, int bits,
}
static Encoder *
-wave_encoder_init(gcc_unused const config_param &param,
+wave_encoder_init(gcc_unused const ConfigBlock &block,
gcc_unused Error &error)
{
WaveEncoder *encoder = new WaveEncoder();
diff --git a/src/filter/FilterConfig.cxx b/src/filter/FilterConfig.cxx
index be2547751..c5f24362c 100644
--- a/src/filter/FilterConfig.cxx
+++ b/src/filter/FilterConfig.cxx
@@ -25,6 +25,7 @@
#include "config/ConfigOption.hxx"
#include "config/ConfigGlobal.hxx"
#include "config/ConfigError.hxx"
+#include "config/Block.hxx"
#include "util/Error.hxx"
#include <algorithm>
@@ -34,9 +35,8 @@
static bool
filter_chain_append_new(Filter &chain, const char *template_name, Error &error)
{
- const struct config_param *cfg =
- config_find_block(ConfigOption::AUDIO_FILTER, "name",
- template_name);
+ const auto *cfg = config_find_block(ConfigBlockOption::AUDIO_FILTER,
+ "name", template_name);
if (cfg == nullptr) {
error.Format(config_domain,
"filter template not found: %s",
diff --git a/src/filter/FilterPlugin.cxx b/src/filter/FilterPlugin.cxx
index 2d007e2db..93d1942a0 100644
--- a/src/filter/FilterPlugin.cxx
+++ b/src/filter/FilterPlugin.cxx
@@ -20,7 +20,7 @@
#include "config.h"
#include "FilterPlugin.hxx"
#include "FilterRegistry.hxx"
-#include "config/Param.hxx"
+#include "config/Block.hxx"
#include "config/ConfigError.hxx"
#include "util/Error.hxx"
@@ -28,20 +28,20 @@
Filter *
filter_new(const struct filter_plugin *plugin,
- const config_param &param, Error &error)
+ const ConfigBlock &block, Error &error)
{
assert(plugin != nullptr);
assert(!error.IsDefined());
- return plugin->init(param, error);
+ return plugin->init(block, error);
}
Filter *
-filter_configured_new(const config_param &param, Error &error)
+filter_configured_new(const ConfigBlock &block, Error &error)
{
assert(!error.IsDefined());
- const char *plugin_name = param.GetBlockValue("plugin");
+ const char *plugin_name = block.GetBlockValue("plugin");
if (plugin_name == nullptr) {
error.Set(config_domain, "No filter plugin specified");
return nullptr;
@@ -54,5 +54,5 @@ filter_configured_new(const config_param &param, Error &error)
return nullptr;
}
- return filter_new(plugin, param, error);
+ return filter_new(plugin, block, error);
}
diff --git a/src/filter/FilterPlugin.hxx b/src/filter/FilterPlugin.hxx
index 58a9c0c94..b60566c49 100644
--- a/src/filter/FilterPlugin.hxx
+++ b/src/filter/FilterPlugin.hxx
@@ -26,7 +26,7 @@
#ifndef MPD_FILTER_PLUGIN_HXX
#define MPD_FILTER_PLUGIN_HXX
-struct config_param;
+struct ConfigBlock;
class Filter;
class Error;
@@ -36,7 +36,7 @@ struct filter_plugin {
/**
* Allocates and configures a filter.
*/
- Filter *(*init)(const config_param &param, Error &error);
+ Filter *(*init)(const ConfigBlock &block, Error &error);
};
/**
@@ -50,7 +50,7 @@ struct filter_plugin {
*/
Filter *
filter_new(const struct filter_plugin *plugin,
- const config_param &param, Error &error);
+ const ConfigBlock &block, Error &error);
/**
* Creates a new filter, loads configuration and the plugin name from
@@ -62,6 +62,6 @@ filter_new(const struct filter_plugin *plugin,
* @return a new filter object, or nullptr on error
*/
Filter *
-filter_configured_new(const config_param &param, Error &error);
+filter_configured_new(const ConfigBlock &block, Error &error);
#endif
diff --git a/src/filter/plugins/AutoConvertFilterPlugin.cxx b/src/filter/plugins/AutoConvertFilterPlugin.cxx
index 1c0c99799..52918080e 100644
--- a/src/filter/plugins/AutoConvertFilterPlugin.cxx
+++ b/src/filter/plugins/AutoConvertFilterPlugin.cxx
@@ -24,7 +24,7 @@
#include "filter/FilterInternal.hxx"
#include "filter/FilterRegistry.hxx"
#include "AudioFormat.hxx"
-#include "config/Param.hxx"
+#include "config/Block.hxx"
#include "util/ConstBuffer.hxx"
#include <assert.h>
@@ -70,7 +70,7 @@ AutoConvertFilter::Open(AudioFormat &in_audio_format, Error &error)
if (in_audio_format != child_audio_format) {
/* yes - create a convert_filter */
- const config_param empty;
+ const ConfigBlock empty;
convert = filter_new(&convert_filter_plugin, empty, error);
if (convert == nullptr) {
filter->Close();
diff --git a/src/filter/plugins/ChainFilterPlugin.cxx b/src/filter/plugins/ChainFilterPlugin.cxx
index c387881d8..b965295f7 100644
--- a/src/filter/plugins/ChainFilterPlugin.cxx
+++ b/src/filter/plugins/ChainFilterPlugin.cxx
@@ -70,7 +70,7 @@ private:
static constexpr Domain chain_filter_domain("chain_filter");
static Filter *
-chain_filter_init(gcc_unused const config_param &param,
+chain_filter_init(gcc_unused const ConfigBlock &block,
gcc_unused Error &error)
{
return new ChainFilter();
diff --git a/src/filter/plugins/ConvertFilterPlugin.cxx b/src/filter/plugins/ConvertFilterPlugin.cxx
index eea5f4b94..18053abd0 100644
--- a/src/filter/plugins/ConvertFilterPlugin.cxx
+++ b/src/filter/plugins/ConvertFilterPlugin.cxx
@@ -59,7 +59,7 @@ public:
};
static Filter *
-convert_filter_init(gcc_unused const config_param &param,
+convert_filter_init(gcc_unused const ConfigBlock &block,
gcc_unused Error &error)
{
return new ConvertFilter();
diff --git a/src/filter/plugins/NormalizeFilterPlugin.cxx b/src/filter/plugins/NormalizeFilterPlugin.cxx
index 41df4b7fc..77e8c1535 100644
--- a/src/filter/plugins/NormalizeFilterPlugin.cxx
+++ b/src/filter/plugins/NormalizeFilterPlugin.cxx
@@ -42,7 +42,7 @@ public:
};
static Filter *
-normalize_filter_init(gcc_unused const config_param &param,
+normalize_filter_init(gcc_unused const ConfigBlock &block,
gcc_unused Error &error)
{
return new NormalizeFilter();
diff --git a/src/filter/plugins/NullFilterPlugin.cxx b/src/filter/plugins/NullFilterPlugin.cxx
index 19792d13c..0bd8170f0 100644
--- a/src/filter/plugins/NullFilterPlugin.cxx
+++ b/src/filter/plugins/NullFilterPlugin.cxx
@@ -48,7 +48,7 @@ public:
};
static Filter *
-null_filter_init(gcc_unused const config_param &param,
+null_filter_init(gcc_unused const ConfigBlock &block,
gcc_unused Error &error)
{
return new NullFilter();
diff --git a/src/filter/plugins/ReplayGainFilterPlugin.cxx b/src/filter/plugins/ReplayGainFilterPlugin.cxx
index 617d99b74..ca1119331 100644
--- a/src/filter/plugins/ReplayGainFilterPlugin.cxx
+++ b/src/filter/plugins/ReplayGainFilterPlugin.cxx
@@ -150,7 +150,7 @@ ReplayGainFilter::Update()
}
static Filter *
-replay_gain_filter_init(gcc_unused const config_param &param,
+replay_gain_filter_init(gcc_unused const ConfigBlock &block,
gcc_unused Error &error)
{
return new ReplayGainFilter();
diff --git a/src/filter/plugins/RouteFilterPlugin.cxx b/src/filter/plugins/RouteFilterPlugin.cxx
index f84dac8cb..11eb534c9 100644
--- a/src/filter/plugins/RouteFilterPlugin.cxx
+++ b/src/filter/plugins/RouteFilterPlugin.cxx
@@ -41,7 +41,7 @@
#include "config.h"
#include "config/ConfigError.hxx"
-#include "config/Param.hxx"
+#include "config/Block.hxx"
#include "AudioFormat.hxx"
#include "filter/FilterPlugin.hxx"
#include "filter/FilterInternal.hxx"
@@ -114,11 +114,11 @@ public:
* a>b, c>d, e>f, ...
* where a... are non-unique, non-negative integers
* and input channel a gets copied to output channel b, etc.
- * @param param the configuration block to read
+ * @param block the configuration block to read
* @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, Error &error);
+ bool Configure(const ConfigBlock &block, Error &error);
/* virtual methods from class Filter */
AudioFormat Open(AudioFormat &af, Error &error) override;
@@ -128,7 +128,7 @@ public:
};
bool
-RouteFilter::Configure(const config_param &param, Error &error) {
+RouteFilter::Configure(const ConfigBlock &block, Error &error) {
/* TODO:
* With a more clever way of marking "don't copy to output N",
@@ -142,7 +142,7 @@ RouteFilter::Configure(const config_param &param, Error &error) {
min_output_channels = 0;
// A cowardly default, just passthrough stereo
- const char *routes = param.GetBlockValue("routes", "0>0, 1>1");
+ const char *routes = block.GetBlockValue("routes", "0>0, 1>1");
while (true) {
routes = StripLeft(routes);
@@ -205,10 +205,10 @@ RouteFilter::Configure(const config_param &param, Error &error) {
}
static Filter *
-route_filter_init(const config_param &param, Error &error)
+route_filter_init(const ConfigBlock &block, Error &error)
{
RouteFilter *filter = new RouteFilter();
- if (!filter->Configure(param, error)) {
+ if (!filter->Configure(block, error)) {
delete filter;
return nullptr;
}
diff --git a/src/filter/plugins/VolumeFilterPlugin.cxx b/src/filter/plugins/VolumeFilterPlugin.cxx
index 36f517f96..b9c3c277e 100644
--- a/src/filter/plugins/VolumeFilterPlugin.cxx
+++ b/src/filter/plugins/VolumeFilterPlugin.cxx
@@ -53,7 +53,7 @@ public:
static constexpr Domain volume_domain("pcm_volume");
static Filter *
-volume_filter_init(gcc_unused const config_param &param,
+volume_filter_init(gcc_unused const ConfigBlock &block,
gcc_unused Error &error)
{
return new VolumeFilter();
diff --git a/src/input/Init.cxx b/src/input/Init.cxx
index 0debf6d43..4ed44f100 100644
--- a/src/input/Init.cxx
+++ b/src/input/Init.cxx
@@ -24,7 +24,7 @@
#include "util/Error.hxx"
#include "config/ConfigGlobal.hxx"
#include "config/ConfigOption.hxx"
-#include "config/Param.hxx"
+#include "config/Block.hxx"
#include "Log.hxx"
#include <assert.h>
@@ -33,7 +33,7 @@
bool
input_stream_global_init(Error &error)
{
- const config_param empty;
+ const ConfigBlock empty;
for (unsigned i = 0; input_plugins[i] != nullptr; ++i) {
const InputPlugin *plugin = input_plugins[i];
@@ -42,17 +42,17 @@ input_stream_global_init(Error &error)
assert(*plugin->name != 0);
assert(plugin->open != nullptr);
- const struct config_param *param =
- config_find_block(ConfigOption::INPUT, "plugin",
+ const auto *block =
+ config_find_block(ConfigBlockOption::INPUT, "plugin",
plugin->name);
- if (param == nullptr) {
- param = &empty;
- } else if (!param->GetBlockValue("enabled", true))
+ if (block == nullptr) {
+ block = &empty;
+ } else if (!block->GetBlockValue("enabled", true))
/* the plugin is disabled in mpd.conf */
continue;
InputPlugin::InitResult result = plugin->init != nullptr
- ? plugin->init(*param, error)
+ ? plugin->init(*block, error)
: InputPlugin::InitResult::SUCCESS;
switch (result) {
diff --git a/src/input/InputPlugin.hxx b/src/input/InputPlugin.hxx
index 17243c5c9..9e83c2a5f 100644
--- a/src/input/InputPlugin.hxx
+++ b/src/input/InputPlugin.hxx
@@ -34,7 +34,7 @@
#endif
#endif
-struct config_param;
+struct ConfigBlock;
class InputStream;
class Error;
struct Tag;
@@ -69,7 +69,7 @@ struct InputPlugin {
* @return true on success, false if the plugin should be
* disabled
*/
- InitResult (*init)(const config_param &param, Error &error);
+ InitResult (*init)(const ConfigBlock &block, Error &error);
/**
* Global deinitialization. Called once before MPD shuts
diff --git a/src/input/plugins/CdioParanoiaInputPlugin.cxx b/src/input/plugins/CdioParanoiaInputPlugin.cxx
index 026d43077..dda5cb83f 100644
--- a/src/input/plugins/CdioParanoiaInputPlugin.cxx
+++ b/src/input/plugins/CdioParanoiaInputPlugin.cxx
@@ -31,7 +31,7 @@
#include "system/ByteOrder.hxx"
#include "fs/AllocatedPath.hxx"
#include "Log.hxx"
-#include "config/Param.hxx"
+#include "config/Block.hxx"
#include "config/ConfigError.hxx"
#include <stdio.h>
@@ -106,9 +106,9 @@ static constexpr Domain cdio_domain("cdio");
static bool default_reverse_endian;
static InputPlugin::InitResult
-input_cdio_init(const config_param &param, Error &error)
+input_cdio_init(const ConfigBlock &block, Error &error)
{
- const char *value = param.GetBlockValue("default_byte_order");
+ const char *value = block.GetBlockValue("default_byte_order");
if (value != nullptr) {
if (strcmp(value, "little_endian") == 0)
default_reverse_endian = IsBigEndian();
diff --git a/src/input/plugins/CurlInputPlugin.cxx b/src/input/plugins/CurlInputPlugin.cxx
index bdfcaf647..fb5845b2b 100644
--- a/src/input/plugins/CurlInputPlugin.cxx
+++ b/src/input/plugins/CurlInputPlugin.cxx
@@ -23,7 +23,7 @@
#include "../IcyInputStream.hxx"
#include "../InputPlugin.hxx"
#include "config/ConfigGlobal.hxx"
-#include "config/Param.hxx"
+#include "config/Block.hxx"
#include "tag/Tag.hxx"
#include "tag/TagBuilder.hxx"
#include "event/SocketMonitor.hxx"
@@ -535,7 +535,7 @@ CurlMulti::OnTimeout()
*/
static InputPlugin::InitResult
-input_curl_init(const config_param &param, Error &error)
+input_curl_init(const ConfigBlock &block, Error &error)
{
CURLcode code = curl_global_init(CURL_GLOBAL_ALL);
if (code != CURLE_OK) {
@@ -557,10 +557,10 @@ input_curl_init(const config_param &param, Error &error)
http_200_aliases = curl_slist_append(http_200_aliases, "ICY 200 OK");
- proxy = param.GetBlockValue("proxy");
- proxy_port = param.GetBlockValue("proxy_port", 0u);
- proxy_user = param.GetBlockValue("proxy_user");
- proxy_password = param.GetBlockValue("proxy_password");
+ proxy = block.GetBlockValue("proxy");
+ proxy_port = block.GetBlockValue("proxy_port", 0u);
+ proxy_user = block.GetBlockValue("proxy_user");
+ proxy_password = block.GetBlockValue("proxy_password");
if (proxy == nullptr) {
/* deprecated proxy configuration */
@@ -571,8 +571,8 @@ input_curl_init(const config_param &param, Error &error)
"");
}
- verify_peer = param.GetBlockValue("verify_peer", true);
- verify_host = param.GetBlockValue("verify_host", true);
+ verify_peer = block.GetBlockValue("verify_peer", true);
+ verify_host = block.GetBlockValue("verify_host", true);
CURLM *multi = curl_multi_init();
if (multi == nullptr) {
diff --git a/src/input/plugins/FfmpegInputPlugin.cxx b/src/input/plugins/FfmpegInputPlugin.cxx
index 27260a5ea..444273d90 100644
--- a/src/input/plugins/FfmpegInputPlugin.cxx
+++ b/src/input/plugins/FfmpegInputPlugin.cxx
@@ -72,7 +72,7 @@ input_ffmpeg_supported(void)
}
static InputPlugin::InitResult
-input_ffmpeg_init(gcc_unused const config_param &param,
+input_ffmpeg_init(gcc_unused const ConfigBlock &block,
Error &error)
{
FfmpegInit();
diff --git a/src/input/plugins/NfsInputPlugin.cxx b/src/input/plugins/NfsInputPlugin.cxx
index 48b86567c..077362c18 100644
--- a/src/input/plugins/NfsInputPlugin.cxx
+++ b/src/input/plugins/NfsInputPlugin.cxx
@@ -221,7 +221,7 @@ NfsInputStream::OnNfsFileError(Error &&error)
*/
static InputPlugin::InitResult
-input_nfs_init(const config_param &, Error &)
+input_nfs_init(const ConfigBlock &, Error &)
{
nfs_init();
return InputPlugin::InitResult::SUCCESS;
diff --git a/src/input/plugins/SmbclientInputPlugin.cxx b/src/input/plugins/SmbclientInputPlugin.cxx
index 258d1e917..6aab556f2 100644
--- a/src/input/plugins/SmbclientInputPlugin.cxx
+++ b/src/input/plugins/SmbclientInputPlugin.cxx
@@ -66,14 +66,14 @@ public:
*/
static InputPlugin::InitResult
-input_smbclient_init(gcc_unused const config_param &param, Error &error)
+input_smbclient_init(gcc_unused const ConfigBlock &block, Error &error)
{
if (!SmbclientInit(error))
return InputPlugin::InitResult::UNAVAILABLE;
// TODO: create one global SMBCCTX here?
- // TODO: evaluate config_param, call smbc_setOption*()
+ // TODO: evaluate ConfigBlock, call smbc_setOption*()
return InputPlugin::InitResult::SUCCESS;
}
diff --git a/src/mixer/MixerControl.cxx b/src/mixer/MixerControl.cxx
index 2311fe7d9..9de7809ec 100644
--- a/src/mixer/MixerControl.cxx
+++ b/src/mixer/MixerControl.cxx
@@ -28,10 +28,10 @@ Mixer *
mixer_new(EventLoop &event_loop,
const MixerPlugin &plugin, AudioOutput &ao,
MixerListener &listener,
- const config_param &param,
+ const ConfigBlock &block,
Error &error)
{
- Mixer *mixer = plugin.init(event_loop, ao, listener, param, error);
+ Mixer *mixer = plugin.init(event_loop, ao, listener, block, error);
assert(mixer == nullptr || mixer->IsPlugin(plugin));
diff --git a/src/mixer/MixerControl.hxx b/src/mixer/MixerControl.hxx
index faa77f299..6401544dd 100644
--- a/src/mixer/MixerControl.hxx
+++ b/src/mixer/MixerControl.hxx
@@ -31,12 +31,12 @@ class EventLoop;
struct AudioOutput;
struct MixerPlugin;
class MixerListener;
-struct config_param;
+struct ConfigBlock;
Mixer *
mixer_new(EventLoop &event_loop, const MixerPlugin &plugin, AudioOutput &ao,
MixerListener &listener,
- const config_param &param,
+ const ConfigBlock &block,
Error &error);
void
diff --git a/src/mixer/MixerPlugin.hxx b/src/mixer/MixerPlugin.hxx
index 507da7dd1..a40b4bb95 100644
--- a/src/mixer/MixerPlugin.hxx
+++ b/src/mixer/MixerPlugin.hxx
@@ -27,7 +27,7 @@
#ifndef MPD_MIXER_PLUGIN_HXX
#define MPD_MIXER_PLUGIN_HXX
-struct config_param;
+struct ConfigBlock;
struct AudioOutput;
class Mixer;
class MixerListener;
@@ -46,7 +46,7 @@ struct MixerPlugin {
*/
Mixer *(*init)(EventLoop &event_loop, AudioOutput &ao,
MixerListener &listener,
- const config_param &param,
+ const ConfigBlock &block,
Error &error);
/**
diff --git a/src/mixer/plugins/AlsaMixerPlugin.cxx b/src/mixer/plugins/AlsaMixerPlugin.cxx
index 7fc43da44..2b89f24e1 100644
--- a/src/mixer/plugins/AlsaMixerPlugin.cxx
+++ b/src/mixer/plugins/AlsaMixerPlugin.cxx
@@ -82,7 +82,7 @@ public:
virtual ~AlsaMixer();
- void Configure(const config_param &param);
+ void Configure(const ConfigBlock &block);
bool Setup(Error &error);
/* virtual methods from class Mixer */
@@ -162,24 +162,24 @@ alsa_mixer_elem_callback(snd_mixer_elem_t *elem, unsigned mask)
*/
inline void
-AlsaMixer::Configure(const config_param &param)
+AlsaMixer::Configure(const ConfigBlock &block)
{
- device = param.GetBlockValue("mixer_device",
+ device = block.GetBlockValue("mixer_device",
VOLUME_MIXER_ALSA_DEFAULT);
- control = param.GetBlockValue("mixer_control",
+ control = block.GetBlockValue("mixer_control",
VOLUME_MIXER_ALSA_CONTROL_DEFAULT);
- index = param.GetBlockValue("mixer_index",
+ index = block.GetBlockValue("mixer_index",
VOLUME_MIXER_ALSA_INDEX_DEFAULT);
}
static Mixer *
alsa_mixer_init(EventLoop &event_loop, gcc_unused AudioOutput &ao,
MixerListener &listener,
- const config_param &param,
+ const ConfigBlock &block,
gcc_unused Error &error)
{
AlsaMixer *am = new AlsaMixer(event_loop, listener);
- am->Configure(param);
+ am->Configure(block);
return am;
}
diff --git a/src/mixer/plugins/NullMixerPlugin.cxx b/src/mixer/plugins/NullMixerPlugin.cxx
index a90bd03a5..d846a6be1 100644
--- a/src/mixer/plugins/NullMixerPlugin.cxx
+++ b/src/mixer/plugins/NullMixerPlugin.cxx
@@ -55,7 +55,7 @@ static Mixer *
null_mixer_init(gcc_unused EventLoop &event_loop,
gcc_unused AudioOutput &ao,
MixerListener &listener,
- gcc_unused const config_param &param,
+ gcc_unused const ConfigBlock &block,
gcc_unused Error &error)
{
return new NullMixer(listener);
diff --git a/src/mixer/plugins/OssMixerPlugin.cxx b/src/mixer/plugins/OssMixerPlugin.cxx
index 991ca7e9d..ae198492c 100644
--- a/src/mixer/plugins/OssMixerPlugin.cxx
+++ b/src/mixer/plugins/OssMixerPlugin.cxx
@@ -19,7 +19,7 @@
#include "config.h"
#include "mixer/MixerInternal.hxx"
-#include "config/Param.hxx"
+#include "config/Block.hxx"
#include "system/fd_util.h"
#include "util/ASCII.hxx"
#include "util/Error.hxx"
@@ -52,7 +52,7 @@ public:
OssMixer(MixerListener &_listener)
:Mixer(oss_mixer_plugin, _listener) {}
- bool Configure(const config_param &param, Error &error);
+ bool Configure(const ConfigBlock &block, Error &error);
/* virtual methods from class Mixer */
virtual bool Open(Error &error) override;
@@ -79,10 +79,10 @@ oss_find_mixer(const char *name)
}
inline bool
-OssMixer::Configure(const config_param &param, Error &error)
+OssMixer::Configure(const ConfigBlock &block, Error &error)
{
- device = param.GetBlockValue("mixer_device", VOLUME_MIXER_OSS_DEFAULT);
- control = param.GetBlockValue("mixer_control");
+ device = block.GetBlockValue("mixer_device", VOLUME_MIXER_OSS_DEFAULT);
+ control = block.GetBlockValue("mixer_control");
if (control != NULL) {
volume_control = oss_find_mixer(control);
@@ -100,12 +100,12 @@ OssMixer::Configure(const config_param &param, Error &error)
static Mixer *
oss_mixer_init(gcc_unused EventLoop &event_loop, gcc_unused AudioOutput &ao,
MixerListener &listener,
- const config_param &param,
+ const ConfigBlock &block,
Error &error)
{
OssMixer *om = new OssMixer(listener);
- if (!om->Configure(param, error)) {
+ if (!om->Configure(block, error)) {
delete om;
return nullptr;
}
diff --git a/src/mixer/plugins/PulseMixerPlugin.cxx b/src/mixer/plugins/PulseMixerPlugin.cxx
index 713bdf69e..f2b17a75a 100644
--- a/src/mixer/plugins/PulseMixerPlugin.cxx
+++ b/src/mixer/plugins/PulseMixerPlugin.cxx
@@ -163,7 +163,7 @@ pulse_mixer_on_change(PulseMixer &pm,
static Mixer *
pulse_mixer_init(gcc_unused EventLoop &event_loop, AudioOutput &ao,
MixerListener &listener,
- gcc_unused const config_param &param,
+ gcc_unused const ConfigBlock &block,
gcc_unused Error &error)
{
PulseOutput &po = (PulseOutput &)ao;
diff --git a/src/mixer/plugins/RoarMixerPlugin.cxx b/src/mixer/plugins/RoarMixerPlugin.cxx
index 8aefa235f..9123762f2 100644
--- a/src/mixer/plugins/RoarMixerPlugin.cxx
+++ b/src/mixer/plugins/RoarMixerPlugin.cxx
@@ -48,7 +48,7 @@ public:
static Mixer *
roar_mixer_init(gcc_unused EventLoop &event_loop, AudioOutput &ao,
MixerListener &listener,
- gcc_unused const config_param &param,
+ gcc_unused const ConfigBlock &block,
gcc_unused Error &error)
{
return new RoarMixer((RoarOutput &)ao, listener);
diff --git a/src/mixer/plugins/SoftwareMixerPlugin.cxx b/src/mixer/plugins/SoftwareMixerPlugin.cxx
index 7f66d2145..d35e7f469 100644
--- a/src/mixer/plugins/SoftwareMixerPlugin.cxx
+++ b/src/mixer/plugins/SoftwareMixerPlugin.cxx
@@ -25,7 +25,7 @@
#include "filter/FilterInternal.hxx"
#include "filter/plugins/VolumeFilterPlugin.hxx"
#include "pcm/Volume.hxx"
-#include "config/Param.hxx"
+#include "config/Block.hxx"
#include "util/Error.hxx"
#include <assert.h>
@@ -34,7 +34,7 @@
static Filter *
CreateVolumeFilter()
{
- return filter_new(&volume_filter_plugin, config_param(),
+ return filter_new(&volume_filter_plugin, ConfigBlock(),
IgnoreError());
}
@@ -90,7 +90,7 @@ static Mixer *
software_mixer_init(gcc_unused EventLoop &event_loop,
gcc_unused AudioOutput &ao,
MixerListener &listener,
- gcc_unused const config_param &param,
+ gcc_unused const ConfigBlock &block,
gcc_unused Error &error)
{
return new SoftwareMixer(listener);
diff --git a/src/mixer/plugins/WinmmMixerPlugin.cxx b/src/mixer/plugins/WinmmMixerPlugin.cxx
index a89ac93ce..51d8092f9 100644
--- a/src/mixer/plugins/WinmmMixerPlugin.cxx
+++ b/src/mixer/plugins/WinmmMixerPlugin.cxx
@@ -69,7 +69,7 @@ winmm_volume_encode(int volume)
static Mixer *
winmm_mixer_init(gcc_unused EventLoop &event_loop, AudioOutput &ao,
MixerListener &listener,
- gcc_unused const config_param &param,
+ gcc_unused const ConfigBlock &block,
gcc_unused Error &error)
{
return new WinmmMixer((WinmmOutput &)ao, listener);
diff --git a/src/neighbor/Glue.cxx b/src/neighbor/Glue.cxx
index 57383b1d5..4d5d7b4b0 100644
--- a/src/neighbor/Glue.cxx
+++ b/src/neighbor/Glue.cxx
@@ -24,8 +24,8 @@
#include "NeighborPlugin.hxx"
#include "Info.hxx"
#include "config/ConfigGlobal.hxx"
-#include "config/Param.hxx"
#include "config/ConfigError.hxx"
+#include "config/Block.hxx"
#include "util/Error.hxx"
NeighborGlue::Explorer::~Explorer()
@@ -37,9 +37,9 @@ NeighborGlue::~NeighborGlue() {}
static NeighborExplorer *
CreateNeighborExplorer(EventLoop &loop, NeighborListener &listener,
- const config_param &param, Error &error)
+ const ConfigBlock &block, Error &error)
{
- const char *plugin_name = param.GetBlockValue("plugin");
+ const char *plugin_name = block.GetBlockValue("plugin");
if (plugin_name == nullptr) {
error.Set(config_domain,
"Missing \"plugin\" configuration");
@@ -53,18 +53,18 @@ CreateNeighborExplorer(EventLoop &loop, NeighborListener &listener,
return nullptr;
}
- return plugin->create(loop, listener, param, error);
+ return plugin->create(loop, listener, block, error);
}
bool
NeighborGlue::Init(EventLoop &loop, NeighborListener &listener, Error &error)
{
- for (const auto *param = config_get_param(ConfigOption::NEIGHBORS);
- param != nullptr; param = param->next) {
+ for (const auto *block = config_get_block(ConfigBlockOption::NEIGHBORS);
+ block != nullptr; block = block->next) {
NeighborExplorer *explorer =
- CreateNeighborExplorer(loop, listener, *param, error);
+ CreateNeighborExplorer(loop, listener, *block, error);
if (explorer == nullptr) {
- error.FormatPrefix("Line %i: ", param->line);
+ error.FormatPrefix("Line %i: ", block->line);
return false;
}
diff --git a/src/neighbor/NeighborPlugin.hxx b/src/neighbor/NeighborPlugin.hxx
index 6ef2d88c6..116f47c50 100644
--- a/src/neighbor/NeighborPlugin.hxx
+++ b/src/neighbor/NeighborPlugin.hxx
@@ -20,7 +20,7 @@
#ifndef MPD_NEIGHBOR_PLUGIN_HXX
#define MPD_NEIGHBOR_PLUGIN_HXX
-struct config_param;
+struct ConfigBlock;
class Error;
class EventLoop;
class NeighborListener;
@@ -33,7 +33,7 @@ struct NeighborPlugin {
* Allocates and configures a #NeighborExplorer instance.
*/
NeighborExplorer *(*create)(EventLoop &loop, NeighborListener &listener,
- const config_param &param,
+ const ConfigBlock &block,
Error &error);
};
diff --git a/src/neighbor/plugins/SmbclientNeighborPlugin.cxx b/src/neighbor/plugins/SmbclientNeighborPlugin.cxx
index cf922b2db..d4c73f9a8 100644
--- a/src/neighbor/plugins/SmbclientNeighborPlugin.cxx
+++ b/src/neighbor/plugins/SmbclientNeighborPlugin.cxx
@@ -273,7 +273,7 @@ SmbclientNeighborExplorer::ThreadFunc(void *ctx)
static NeighborExplorer *
smbclient_neighbor_create(gcc_unused EventLoop &loop,
NeighborListener &listener,
- gcc_unused const config_param &param,
+ gcc_unused const ConfigBlock &block,
gcc_unused Error &error)
{
if (!SmbclientInit(error))
diff --git a/src/neighbor/plugins/UpnpNeighborPlugin.cxx b/src/neighbor/plugins/UpnpNeighborPlugin.cxx
index f04cd63df..28775df4c 100644
--- a/src/neighbor/plugins/UpnpNeighborPlugin.cxx
+++ b/src/neighbor/plugins/UpnpNeighborPlugin.cxx
@@ -127,7 +127,7 @@ UpnpNeighborExplorer::LostUPnP(const ContentDirectoryService &service)
static NeighborExplorer *
upnp_neighbor_create(gcc_unused EventLoop &loop,
NeighborListener &listener,
- gcc_unused const config_param &param,
+ gcc_unused const ConfigBlock &block,
gcc_unused Error &error)
{
return new UpnpNeighborExplorer(listener);
diff --git a/src/output/Init.cxx b/src/output/Init.cxx
index c4e4a1880..ae34bf846 100644
--- a/src/output/Init.cxx
+++ b/src/output/Init.cxx
@@ -35,6 +35,7 @@
#include "filter/plugins/ChainFilterPlugin.hxx"
#include "config/ConfigError.hxx"
#include "config/ConfigGlobal.hxx"
+#include "config/Block.hxx"
#include "util/Error.hxx"
#include "Log.hxx"
@@ -95,15 +96,15 @@ audio_output_detect(Error &error)
*/
gcc_pure
static MixerType
-audio_output_mixer_type(const config_param &param)
+audio_output_mixer_type(const ConfigBlock &block)
{
/* read the local "mixer_type" setting */
- const char *p = param.GetBlockValue("mixer_type");
+ const char *p = block.GetBlockValue("mixer_type");
if (p != nullptr)
return mixer_type_parse(p);
/* try the local "mixer_enabled" setting next (deprecated) */
- if (!param.GetBlockValue("mixer_enabled", true))
+ if (!block.GetBlockValue("mixer_enabled", true))
return MixerType::NONE;
/* fall back to the global "mixer_type" setting (also
@@ -114,7 +115,7 @@ audio_output_mixer_type(const config_param &param)
static Mixer *
audio_output_load_mixer(EventLoop &event_loop, AudioOutput &ao,
- const config_param &param,
+ const ConfigBlock &block,
const MixerPlugin *plugin,
Filter &filter_chain,
MixerListener &listener,
@@ -122,26 +123,26 @@ audio_output_load_mixer(EventLoop &event_loop, AudioOutput &ao,
{
Mixer *mixer;
- switch (audio_output_mixer_type(param)) {
+ switch (audio_output_mixer_type(block)) {
case MixerType::NONE:
case MixerType::UNKNOWN:
return nullptr;
case MixerType::NULL_:
return mixer_new(event_loop, null_mixer_plugin, ao, listener,
- param, error);
+ block, error);
case MixerType::HARDWARE:
if (plugin == nullptr)
return nullptr;
return mixer_new(event_loop, *plugin, ao, listener,
- param, error);
+ block, error);
case MixerType::SOFTWARE:
mixer = mixer_new(event_loop, software_mixer_plugin, ao,
listener,
- config_param(),
+ ConfigBlock(),
IgnoreError());
assert(mixer != nullptr);
@@ -155,17 +156,17 @@ audio_output_load_mixer(EventLoop &event_loop, AudioOutput &ao,
}
bool
-AudioOutput::Configure(const config_param &param, Error &error)
+AudioOutput::Configure(const ConfigBlock &block, Error &error)
{
- if (!param.IsNull()) {
- name = param.GetBlockValue(AUDIO_OUTPUT_NAME);
+ if (!block.IsNull()) {
+ name = block.GetBlockValue(AUDIO_OUTPUT_NAME);
if (name == nullptr) {
error.Set(config_domain,
"Missing \"name\" configuration");
return false;
}
- const char *p = param.GetBlockValue(AUDIO_OUTPUT_FORMAT);
+ const char *p = block.GetBlockValue(AUDIO_OUTPUT_FORMAT);
if (p != nullptr) {
bool success =
audio_format_parse(config_audio_format,
@@ -180,9 +181,9 @@ AudioOutput::Configure(const config_param &param, Error &error)
config_audio_format.Clear();
}
- tags = param.GetBlockValue("tags", true);
- always_on = param.GetBlockValue("always_on", false);
- enabled = param.GetBlockValue("enabled", true);
+ tags = block.GetBlockValue("tags", true);
+ always_on = block.GetBlockValue("always_on", false);
+ enabled = block.GetBlockValue("enabled", true);
/* set up the filter chain */
@@ -193,7 +194,7 @@ AudioOutput::Configure(const config_param &param, Error &error)
if (config_get_bool(ConfigOption::VOLUME_NORMALIZATION, false)) {
Filter *normalize_filter =
- filter_new(&normalize_filter_plugin, config_param(),
+ filter_new(&normalize_filter_plugin, ConfigBlock(),
IgnoreError());
assert(normalize_filter != nullptr);
@@ -203,7 +204,7 @@ AudioOutput::Configure(const config_param &param, Error &error)
Error filter_error;
filter_chain_parse(*filter,
- param.GetBlockValue(AUDIO_FILTERS, ""),
+ block.GetBlockValue(AUDIO_FILTERS, ""),
filter_error);
// It's not really fatal - Part of the filter chain has been set up already
@@ -221,24 +222,24 @@ AudioOutput::Configure(const config_param &param, Error &error)
static bool
audio_output_setup(EventLoop &event_loop, AudioOutput &ao,
MixerListener &mixer_listener,
- const config_param &param,
+ const ConfigBlock &block,
Error &error)
{
/* create the replay_gain filter */
const char *replay_gain_handler =
- param.GetBlockValue("replay_gain_handler", "software");
+ block.GetBlockValue("replay_gain_handler", "software");
if (strcmp(replay_gain_handler, "none") != 0) {
ao.replay_gain_filter = filter_new(&replay_gain_filter_plugin,
- param, IgnoreError());
+ block, IgnoreError());
assert(ao.replay_gain_filter != nullptr);
ao.replay_gain_serial = 0;
ao.other_replay_gain_filter = filter_new(&replay_gain_filter_plugin,
- param,
+ block,
IgnoreError());
assert(ao.other_replay_gain_filter != nullptr);
@@ -251,7 +252,7 @@ audio_output_setup(EventLoop &event_loop, AudioOutput &ao,
/* set up the mixer */
Error mixer_error;
- ao.mixer = audio_output_load_mixer(event_loop, ao, param,
+ ao.mixer = audio_output_load_mixer(event_loop, ao, block,
ao.plugin.mixer_plugin,
*ao.filter,
mixer_listener,
@@ -279,7 +280,7 @@ audio_output_setup(EventLoop &event_loop, AudioOutput &ao,
/* the "convert" filter must be the last one in the chain */
- ao.convert_filter = filter_new(&convert_filter_plugin, config_param(),
+ ao.convert_filter = filter_new(&convert_filter_plugin, ConfigBlock(),
IgnoreError());
assert(ao.convert_filter != nullptr);
@@ -289,17 +290,17 @@ audio_output_setup(EventLoop &event_loop, AudioOutput &ao,
}
AudioOutput *
-audio_output_new(EventLoop &event_loop, const config_param &param,
+audio_output_new(EventLoop &event_loop, const ConfigBlock &block,
MixerListener &mixer_listener,
PlayerControl &pc,
Error &error)
{
const AudioOutputPlugin *plugin;
- if (!param.IsNull()) {
+ if (!block.IsNull()) {
const char *p;
- p = param.GetBlockValue(AUDIO_OUTPUT_TYPE);
+ p = block.GetBlockValue(AUDIO_OUTPUT_TYPE);
if (p == nullptr) {
error.Set(config_domain,
"Missing \"type\" configuration");
@@ -325,12 +326,12 @@ audio_output_new(EventLoop &event_loop, const config_param &param,
plugin->name);
}
- AudioOutput *ao = ao_plugin_init(plugin, param, error);
+ AudioOutput *ao = ao_plugin_init(plugin, block, error);
if (ao == nullptr)
return nullptr;
if (!audio_output_setup(event_loop, *ao, mixer_listener,
- param, error)) {
+ block, error)) {
ao_plugin_finish(ao);
return nullptr;
}
diff --git a/src/output/Internal.hxx b/src/output/Internal.hxx
index c08a9272a..23b027c54 100644
--- a/src/output/Internal.hxx
+++ b/src/output/Internal.hxx
@@ -36,7 +36,7 @@ class EventLoop;
class Mixer;
class MixerListener;
struct MusicChunk;
-struct config_param;
+struct ConfigBlock;
struct PlayerControl;
struct AudioOutputPlugin;
@@ -272,7 +272,7 @@ struct AudioOutput {
AudioOutput(const AudioOutputPlugin &_plugin);
~AudioOutput();
- bool Configure(const config_param &param, Error &error);
+ bool Configure(const ConfigBlock &block, Error &error);
void StartThread();
void StopThread();
@@ -430,7 +430,7 @@ private:
extern struct notify audio_output_client_notify;
AudioOutput *
-audio_output_new(EventLoop &event_loop, const config_param &param,
+audio_output_new(EventLoop &event_loop, const ConfigBlock &block,
MixerListener &mixer_listener,
PlayerControl &pc,
Error &error);
diff --git a/src/output/MultipleOutputs.cxx b/src/output/MultipleOutputs.cxx
index 83a8b98c9..a2260f19c 100644
--- a/src/output/MultipleOutputs.cxx
+++ b/src/output/MultipleOutputs.cxx
@@ -27,7 +27,7 @@
#include "MusicChunk.hxx"
#include "system/FatalError.hxx"
#include "util/Error.hxx"
-#include "config/Param.hxx"
+#include "config/Block.hxx"
#include "config/ConfigGlobal.hxx"
#include "config/ConfigOption.hxx"
#include "notify.hxx"
@@ -53,16 +53,16 @@ MultipleOutputs::~MultipleOutputs()
static AudioOutput *
LoadOutput(EventLoop &event_loop, MixerListener &mixer_listener,
- PlayerControl &pc, const config_param &param)
+ PlayerControl &pc, const ConfigBlock &block)
{
Error error;
- AudioOutput *output = audio_output_new(event_loop, param,
+ AudioOutput *output = audio_output_new(event_loop, block,
mixer_listener,
pc, error);
if (output == nullptr) {
- if (param.line > 0)
+ if (block.line > 0)
FormatFatalError("line %i: %s",
- param.line,
+ block.line,
error.GetMessage());
else
FatalError(error);
@@ -74,7 +74,7 @@ LoadOutput(EventLoop &event_loop, MixerListener &mixer_listener,
void
MultipleOutputs::Configure(EventLoop &event_loop, PlayerControl &pc)
{
- for (const auto *param = config_get_param(ConfigOption::AUDIO_OUTPUT);
+ for (const auto *param = config_get_block(ConfigBlockOption::AUDIO_OUTPUT);
param != nullptr; param = param->next) {
auto output = LoadOutput(event_loop, mixer_listener,
pc, *param);
@@ -87,7 +87,7 @@ MultipleOutputs::Configure(EventLoop &event_loop, PlayerControl &pc)
if (outputs.empty()) {
/* auto-detect device */
- const config_param empty;
+ const ConfigBlock empty;
auto output = LoadOutput(event_loop, mixer_listener,
pc, empty);
outputs.push_back(output);
diff --git a/src/output/OutputAPI.hxx b/src/output/OutputAPI.hxx
index 92b3ffec9..af3f90344 100644
--- a/src/output/OutputAPI.hxx
+++ b/src/output/OutputAPI.hxx
@@ -26,7 +26,7 @@
#include "Internal.hxx"
#include "AudioFormat.hxx"
#include "tag/Tag.hxx"
-#include "config/Param.hxx"
+#include "config/Block.hxx"
// IWYU pragma: end_exports
diff --git a/src/output/OutputPlugin.cxx b/src/output/OutputPlugin.cxx
index 21fedd857..7d95ef345 100644
--- a/src/output/OutputPlugin.cxx
+++ b/src/output/OutputPlugin.cxx
@@ -23,13 +23,13 @@
AudioOutput *
ao_plugin_init(const AudioOutputPlugin *plugin,
- const config_param &param,
+ const ConfigBlock &block,
Error &error)
{
assert(plugin != nullptr);
assert(plugin->init != nullptr);
- return plugin->init(param, error);
+ return plugin->init(block, error);
}
void
diff --git a/src/output/OutputPlugin.hxx b/src/output/OutputPlugin.hxx
index 3c89d744c..63b774fd6 100644
--- a/src/output/OutputPlugin.hxx
+++ b/src/output/OutputPlugin.hxx
@@ -24,7 +24,7 @@
#include <stddef.h>
-struct config_param;
+struct ConfigBlock;
struct AudioFormat;
struct Tag;
struct AudioOutput;
@@ -55,8 +55,7 @@ struct AudioOutputPlugin {
* @return nullptr on error, or an opaque pointer to the plugin's
* data
*/
- AudioOutput *(*init)(const config_param &param,
- Error &error);
+ AudioOutput *(*init)(const ConfigBlock &block, Error &error);
/**
* Free resources allocated by this device.
@@ -162,7 +161,7 @@ ao_plugin_test_default_device(const AudioOutputPlugin *plugin)
gcc_malloc
AudioOutput *
ao_plugin_init(const AudioOutputPlugin *plugin,
- const config_param &param,
+ const ConfigBlock &block,
Error &error);
void
diff --git a/src/output/Wrapper.hxx b/src/output/Wrapper.hxx
index e6af29634..c043849bb 100644
--- a/src/output/Wrapper.hxx
+++ b/src/output/Wrapper.hxx
@@ -22,14 +22,16 @@
#include "util/Cast.hxx"
+struct ConfigBlock;
+
template<class T>
struct AudioOutputWrapper {
static T &Cast(AudioOutput &ao) {
return ContainerCast(ao, &T::base);
}
- static AudioOutput *Init(const config_param &param, Error &error) {
- T *t = T::Create(param, error);
+ static AudioOutput *Init(const ConfigBlock &block, Error &error) {
+ T *t = T::Create(block, error);
return t != nullptr
? &t->base
: nullptr;
diff --git a/src/output/plugins/AlsaOutputPlugin.cxx b/src/output/plugins/AlsaOutputPlugin.cxx
index 22e13d7dc..8a7bb9643 100644
--- a/src/output/plugins/AlsaOutputPlugin.cxx
+++ b/src/output/plugins/AlsaOutputPlugin.cxx
@@ -142,8 +142,8 @@ struct AlsaOutput {
return device.empty() ? default_device : device.c_str();
}
- bool Configure(const config_param &param, Error &error);
- static AlsaOutput *Create(const config_param &param, Error &error);
+ bool Configure(const ConfigBlock &block, Error &error);
+ static AlsaOutput *Create(const ConfigBlock &block, Error &error);
bool Enable(Error &error);
void Disable();
@@ -175,35 +175,35 @@ private:
static constexpr Domain alsa_output_domain("alsa_output");
inline bool
-AlsaOutput::Configure(const config_param &param, Error &error)
+AlsaOutput::Configure(const ConfigBlock &block, Error &error)
{
- if (!base.Configure(param, error))
+ if (!base.Configure(block, error))
return false;
- device = param.GetBlockValue("device", "");
+ device = block.GetBlockValue("device", "");
- use_mmap = param.GetBlockValue("use_mmap", false);
+ use_mmap = block.GetBlockValue("use_mmap", false);
- dop = param.GetBlockValue("dop", false) ||
+ dop = block.GetBlockValue("dop", false) ||
/* legacy name from MPD 0.18 and older: */
- param.GetBlockValue("dsd_usb", false);
+ block.GetBlockValue("dsd_usb", false);
- buffer_time = param.GetBlockValue("buffer_time",
+ buffer_time = block.GetBlockValue("buffer_time",
MPD_ALSA_BUFFER_TIME_US);
- period_time = param.GetBlockValue("period_time", 0u);
+ period_time = block.GetBlockValue("period_time", 0u);
#ifdef SND_PCM_NO_AUTO_RESAMPLE
- if (!param.GetBlockValue("auto_resample", true))
+ if (!block.GetBlockValue("auto_resample", true))
mode |= SND_PCM_NO_AUTO_RESAMPLE;
#endif
#ifdef SND_PCM_NO_AUTO_CHANNELS
- if (!param.GetBlockValue("auto_channels", true))
+ if (!block.GetBlockValue("auto_channels", true))
mode |= SND_PCM_NO_AUTO_CHANNELS;
#endif
#ifdef SND_PCM_NO_AUTO_FORMAT
- if (!param.GetBlockValue("auto_format", true))
+ if (!block.GetBlockValue("auto_format", true))
mode |= SND_PCM_NO_AUTO_FORMAT;
#endif
@@ -211,11 +211,11 @@ AlsaOutput::Configure(const config_param &param, Error &error)
}
inline AlsaOutput *
-AlsaOutput::Create(const config_param &param, Error &error)
+AlsaOutput::Create(const ConfigBlock &block, Error &error)
{
AlsaOutput *ad = new AlsaOutput();
- if (!ad->Configure(param, error)) {
+ if (!ad->Configure(block, error)) {
delete ad;
return nullptr;
}
diff --git a/src/output/plugins/AoOutputPlugin.cxx b/src/output/plugins/AoOutputPlugin.cxx
index 31edd371e..3c0cf74a4 100644
--- a/src/output/plugins/AoOutputPlugin.cxx
+++ b/src/output/plugins/AoOutputPlugin.cxx
@@ -46,11 +46,11 @@ struct AoOutput {
AoOutput()
:base(ao_output_plugin) {}
- bool Initialize(const config_param &param, Error &error) {
- return base.Configure(param, error);
+ bool Initialize(const ConfigBlock &block, Error &error) {
+ return base.Configure(block, error);
}
- bool Configure(const config_param &param, Error &error);
+ bool Configure(const ConfigBlock &block, Error &error);
};
static constexpr Domain ao_output_domain("ao_output");
@@ -90,20 +90,20 @@ ao_output_error(Error &error_r)
}
inline bool
-AoOutput::Configure(const config_param &param, Error &error)
+AoOutput::Configure(const ConfigBlock &block, Error &error)
{
const char *value;
options = nullptr;
- write_size = param.GetBlockValue("write_size", 1024u);
+ write_size = block.GetBlockValue("write_size", 1024u);
if (ao_output_ref == 0) {
ao_initialize();
}
ao_output_ref++;
- value = param.GetBlockValue("driver", "default");
+ value = block.GetBlockValue("driver", "default");
if (0 == strcmp(value, "default"))
driver = ao_default_driver_id();
else
@@ -123,9 +123,9 @@ AoOutput::Configure(const config_param &param, Error &error)
}
FormatDebug(ao_output_domain, "using ao driver \"%s\" for \"%s\"\n",
- ai->short_name, param.GetBlockValue("name", nullptr));
+ ai->short_name, block.GetBlockValue("name", nullptr));
- value = param.GetBlockValue("options", nullptr);
+ value = block.GetBlockValue("options", nullptr);
if (value != nullptr) {
for (const auto &i : SplitString(value, ';')) {
const DivideString ss(i.c_str(), '=', true);
@@ -145,16 +145,16 @@ AoOutput::Configure(const config_param &param, Error &error)
}
static AudioOutput *
-ao_output_init(const config_param &param, Error &error)
+ao_output_init(const ConfigBlock &block, Error &error)
{
AoOutput *ad = new AoOutput();
- if (!ad->Initialize(param, error)) {
+ if (!ad->Initialize(block, error)) {
delete ad;
return nullptr;
}
- if (!ad->Configure(param, error)) {
+ if (!ad->Configure(block, error)) {
delete ad;
return nullptr;
}
diff --git a/src/output/plugins/FifoOutputPlugin.cxx b/src/output/plugins/FifoOutputPlugin.cxx
index 40ae6a370..ddc63489c 100644
--- a/src/output/plugins/FifoOutputPlugin.cxx
+++ b/src/output/plugins/FifoOutputPlugin.cxx
@@ -51,8 +51,8 @@ struct FifoOutput {
path(AllocatedPath::Null()), input(-1), output(-1),
created(false) {}
- bool Initialize(const config_param &param, Error &error) {
- return base.Configure(param, error);
+ bool Initialize(const ConfigBlock &block, Error &error) {
+ return base.Configure(block, error);
}
bool Create(Error &error);
@@ -169,11 +169,11 @@ fifo_open(FifoOutput *fd, Error &error)
}
static AudioOutput *
-fifo_output_init(const config_param &param, Error &error)
+fifo_output_init(const ConfigBlock &block, Error &error)
{
FifoOutput *fd = new FifoOutput();
- fd->path = param.GetBlockPath("path", error);
+ fd->path = block.GetBlockPath("path", error);
if (fd->path.IsNull()) {
delete fd;
@@ -185,7 +185,7 @@ fifo_output_init(const config_param &param, Error &error)
fd->path_utf8 = fd->path.ToUTF8();
- if (!fd->Initialize(param, error)) {
+ if (!fd->Initialize(block, error)) {
delete fd;
return nullptr;
}
diff --git a/src/output/plugins/JackOutputPlugin.cxx b/src/output/plugins/JackOutputPlugin.cxx
index 5c136b81f..23843ab5e 100644
--- a/src/output/plugins/JackOutputPlugin.cxx
+++ b/src/output/plugins/JackOutputPlugin.cxx
@@ -83,7 +83,7 @@ struct JackOutput {
JackOutput()
:base(jack_output_plugin) {}
- bool Configure(const config_param &param, Error &error);
+ bool Configure(const ConfigBlock &block, Error &error);
bool Connect(Error &error);
@@ -376,14 +376,14 @@ parse_port_list(const char *source, std::string dest[], Error &error)
}
bool
-JackOutput::Configure(const config_param &param, Error &error)
+JackOutput::Configure(const ConfigBlock &block, Error &error)
{
- if (!base.Configure(param, error))
+ if (!base.Configure(block, error))
return false;
options = JackNullOption;
- name = param.GetBlockValue("client_name", nullptr);
+ name = block.GetBlockValue("client_name", nullptr);
if (name != nullptr)
options = jack_options_t(options | JackUseExactName);
else
@@ -391,30 +391,30 @@ JackOutput::Configure(const config_param &param, Error &error)
care about the JackUseExactName option */
name = "Music Player Daemon";
- server_name = param.GetBlockValue("server_name", nullptr);
+ server_name = block.GetBlockValue("server_name", nullptr);
if (server_name != nullptr)
options = jack_options_t(options | JackServerName);
- if (!param.GetBlockValue("autostart", false))
+ if (!block.GetBlockValue("autostart", false))
options = jack_options_t(options | JackNoStartServer);
/* configure the source ports */
- const char *value = param.GetBlockValue("source_ports", "left,right");
+ const char *value = block.GetBlockValue("source_ports", "left,right");
num_source_ports = parse_port_list(value, source_ports, error);
if (num_source_ports == 0)
return false;
/* configure the destination ports */
- value = param.GetBlockValue("destination_ports", nullptr);
+ value = block.GetBlockValue("destination_ports", nullptr);
if (value == nullptr) {
/* compatibility with MPD < 0.16 */
- value = param.GetBlockValue("ports", nullptr);
+ value = block.GetBlockValue("ports", nullptr);
if (value != nullptr)
FormatWarning(jack_output_domain,
"deprecated option 'ports' in line %d",
- param.line);
+ block.line);
}
if (value != nullptr) {
@@ -432,9 +432,9 @@ JackOutput::Configure(const config_param &param, Error &error)
"number of source ports (%u) mismatches the "
"number of destination ports (%u) in line %d",
num_source_ports, num_destination_ports,
- param.line);
+ block.line);
- ringbuffer_size = param.GetBlockValue("ringbuffer_size", 32768u);
+ ringbuffer_size = block.GetBlockValue("ringbuffer_size", 32768u);
return true;
}
@@ -463,11 +463,11 @@ JackOutput::Disable()
}
static AudioOutput *
-mpd_jack_init(const config_param &param, Error &error)
+mpd_jack_init(const ConfigBlock &block, Error &error)
{
JackOutput *jd = new JackOutput();
- if (!jd->Configure(param, error)) {
+ if (!jd->Configure(block, error)) {
delete jd;
return nullptr;
}
diff --git a/src/output/plugins/NullOutputPlugin.cxx b/src/output/plugins/NullOutputPlugin.cxx
index e3b462da2..e1731f0fe 100644
--- a/src/output/plugins/NullOutputPlugin.cxx
+++ b/src/output/plugins/NullOutputPlugin.cxx
@@ -36,11 +36,11 @@ public:
NullOutput()
:base(null_output_plugin) {}
- bool Initialize(const config_param &param, Error &error) {
- return base.Configure(param, error);
+ bool Initialize(const ConfigBlock &block, Error &error) {
+ return base.Configure(block, error);
}
- static NullOutput *Create(const config_param &param, Error &error);
+ static NullOutput *Create(const ConfigBlock &block, Error &error);
bool Open(AudioFormat &audio_format, gcc_unused Error &error) {
if (sync)
@@ -78,16 +78,16 @@ public:
};
inline NullOutput *
-NullOutput::Create(const config_param &param, Error &error)
+NullOutput::Create(const ConfigBlock &block, Error &error)
{
NullOutput *nd = new NullOutput();
- if (!nd->Initialize(param, error)) {
+ if (!nd->Initialize(block, error)) {
delete nd;
return nullptr;
}
- nd->sync = param.GetBlockValue("sync", true);
+ nd->sync = block.GetBlockValue("sync", true);
return nd;
}
diff --git a/src/output/plugins/OSXOutputPlugin.cxx b/src/output/plugins/OSXOutputPlugin.cxx
index 3274d5b45..16c042ba3 100644
--- a/src/output/plugins/OSXOutputPlugin.cxx
+++ b/src/output/plugins/OSXOutputPlugin.cxx
@@ -61,9 +61,9 @@ osx_output_test_default_device(void)
}
static void
-osx_output_configure(OSXOutput *oo, const config_param &param)
+osx_output_configure(OSXOutput *oo, const ConfigBlock &block)
{
- const char *device = param.GetBlockValue("device");
+ const char *device = block.GetBlockValue("device");
if (device == nullptr || 0 == strcmp(device, "default")) {
oo->component_subtype = kAudioUnitSubType_DefaultOutput;
@@ -81,15 +81,15 @@ osx_output_configure(OSXOutput *oo, const config_param &param)
}
static AudioOutput *
-osx_output_init(const config_param &param, Error &error)
+osx_output_init(const ConfigBlock &block, Error &error)
{
OSXOutput *oo = new OSXOutput();
- if (!oo->base.Configure(param, error)) {
+ if (!oo->base.Configure(block, error)) {
delete oo;
return nullptr;
}
- osx_output_configure(oo, param);
+ osx_output_configure(oo, block);
return &oo->base;
}
diff --git a/src/output/plugins/OpenALOutputPlugin.cxx b/src/output/plugins/OpenALOutputPlugin.cxx
index c28250eb0..eb55c6e9b 100644
--- a/src/output/plugins/OpenALOutputPlugin.cxx
+++ b/src/output/plugins/OpenALOutputPlugin.cxx
@@ -54,9 +54,9 @@ class OpenALOutput {
OpenALOutput()
:base(openal_output_plugin) {}
- bool Configure(const config_param &param, Error &error);
+ bool Configure(const ConfigBlock &block, Error &error);
- static OpenALOutput *Create(const config_param &param, Error &error);
+ static OpenALOutput *Create(const ConfigBlock &block, Error &error);
bool Open(AudioFormat &audio_format, Error &error);
@@ -150,12 +150,12 @@ OpenALOutput::SetupContext(Error &error)
}
inline bool
-OpenALOutput::Configure(const config_param &param, Error &error)
+OpenALOutput::Configure(const ConfigBlock &block, Error &error)
{
- if (!base.Configure(param, error))
+ if (!base.Configure(block, error))
return false;
- device_name = param.GetBlockValue("device");
+ device_name = block.GetBlockValue("device");
if (device_name == nullptr)
device_name = alcGetString(nullptr,
ALC_DEFAULT_DEVICE_SPECIFIER);
@@ -164,11 +164,11 @@ OpenALOutput::Configure(const config_param &param, Error &error)
}
inline OpenALOutput *
-OpenALOutput::Create(const config_param &param, Error &error)
+OpenALOutput::Create(const ConfigBlock &block, Error &error)
{
OpenALOutput *oo = new OpenALOutput();
- if (!oo->Configure(param, error)) {
+ if (!oo->Configure(block, error)) {
delete oo;
return nullptr;
}
diff --git a/src/output/plugins/OssOutputPlugin.cxx b/src/output/plugins/OssOutputPlugin.cxx
index 1b14e16c7..7f75f4e31 100644
--- a/src/output/plugins/OssOutputPlugin.cxx
+++ b/src/output/plugins/OssOutputPlugin.cxx
@@ -87,11 +87,11 @@ public:
:base(oss_output_plugin),
fd(-1), device(_device) {}
- bool Initialize(const config_param &param, Error &error_r) {
- return base.Configure(param, error_r);
+ bool Initialize(const ConfigBlock &block, Error &error_r) {
+ return base.Configure(block, error_r);
}
- static OssOutput *Create(const config_param &param, Error &error);
+ static OssOutput *Create(const ConfigBlock &block, Error &error);
#ifdef AFMT_S24_PACKED
bool Enable(gcc_unused Error &error) {
@@ -192,7 +192,7 @@ oss_open_default(Error &error)
int err[ARRAY_SIZE(default_devices)];
enum oss_stat ret[ARRAY_SIZE(default_devices)];
- const config_param empty;
+ const ConfigBlock empty;
for (int i = ARRAY_SIZE(default_devices); --i >= 0; ) {
ret[i] = oss_stat_device(default_devices[i], &err[i]);
if (ret[i] == OSS_STAT_NO_ERROR) {
@@ -236,12 +236,12 @@ oss_open_default(Error &error)
}
inline OssOutput *
-OssOutput::Create(const config_param &param, Error &error)
+OssOutput::Create(const ConfigBlock &block, Error &error)
{
- const char *device = param.GetBlockValue("device");
+ const char *device = block.GetBlockValue("device");
if (device != nullptr) {
OssOutput *od = new OssOutput();
- if (!od->Initialize(param, error)) {
+ if (!od->Initialize(block, error)) {
delete od;
return nullptr;
}
diff --git a/src/output/plugins/PipeOutputPlugin.cxx b/src/output/plugins/PipeOutputPlugin.cxx
index ea9300cf3..1e34ea98d 100644
--- a/src/output/plugins/PipeOutputPlugin.cxx
+++ b/src/output/plugins/PipeOutputPlugin.cxx
@@ -40,10 +40,10 @@ class PipeOutput {
PipeOutput()
:base(pipe_output_plugin) {}
- bool Configure(const config_param &param, Error &error);
+ bool Configure(const ConfigBlock &block, Error &error);
public:
- static PipeOutput *Create(const config_param &param, Error &error);
+ static PipeOutput *Create(const ConfigBlock &block, Error &error);
bool Open(AudioFormat &audio_format, Error &error);
@@ -58,12 +58,12 @@ public:
static constexpr Domain pipe_output_domain("pipe_output");
inline bool
-PipeOutput::Configure(const config_param &param, Error &error)
+PipeOutput::Configure(const ConfigBlock &block, Error &error)
{
- if (!base.Configure(param, error))
+ if (!base.Configure(block, error))
return false;
- cmd = param.GetBlockValue("command", "");
+ cmd = block.GetBlockValue("command", "");
if (cmd.empty()) {
error.Set(config_domain,
"No \"command\" parameter specified");
@@ -74,11 +74,11 @@ PipeOutput::Configure(const config_param &param, Error &error)
}
inline PipeOutput *
-PipeOutput::Create(const config_param &param, Error &error)
+PipeOutput::Create(const ConfigBlock &block, Error &error)
{
PipeOutput *po = new PipeOutput();
- if (!po->Configure(param, error)) {
+ if (!po->Configure(block, error)) {
delete po;
return nullptr;
}
diff --git a/src/output/plugins/PulseOutputPlugin.cxx b/src/output/plugins/PulseOutputPlugin.cxx
index 8ad885f82..8b5225584 100644
--- a/src/output/plugins/PulseOutputPlugin.cxx
+++ b/src/output/plugins/PulseOutputPlugin.cxx
@@ -98,8 +98,8 @@ public:
gcc_const
static bool TestDefaultDevice();
- bool Configure(const config_param &param, Error &error);
- static PulseOutput *Create(const config_param &param, Error &error);
+ bool Configure(const ConfigBlock &block, Error &error);
+ static PulseOutput *Create(const ConfigBlock &block, Error &error);
bool Enable(Error &error);
void Disable();
@@ -430,26 +430,26 @@ PulseOutput::SetupContext(Error &error)
}
inline bool
-PulseOutput::Configure(const config_param &param, Error &error)
+PulseOutput::Configure(const ConfigBlock &block, Error &error)
{
- if (!base.Configure(param, error))
+ if (!base.Configure(block, error))
return false;
- name = param.GetBlockValue("name", "mpd_pulse");
- server = param.GetBlockValue("server");
- sink = param.GetBlockValue("sink");
+ name = block.GetBlockValue("name", "mpd_pulse");
+ server = block.GetBlockValue("server");
+ sink = block.GetBlockValue("sink");
return true;
}
PulseOutput *
-PulseOutput::Create(const config_param &param, Error &error)
+PulseOutput::Create(const ConfigBlock &block, Error &error)
{
setenv("PULSE_PROP_media.role", "music", true);
setenv("PULSE_PROP_application.icon_name", "mpd", true);
auto *po = new PulseOutput();
- if (!po->Configure(param, error)) {
+ if (!po->Configure(block, error)) {
delete po;
return nullptr;
}
@@ -926,7 +926,7 @@ PulseOutput::Pause()
inline bool
PulseOutput::TestDefaultDevice()
{
- const config_param empty;
+ const ConfigBlock empty;
PulseOutput *po = PulseOutput::Create(empty, IgnoreError());
if (po == nullptr)
return false;
diff --git a/src/output/plugins/RecorderOutputPlugin.cxx b/src/output/plugins/RecorderOutputPlugin.cxx
index b0488080a..115ee534d 100644
--- a/src/output/plugins/RecorderOutputPlugin.cxx
+++ b/src/output/plugins/RecorderOutputPlugin.cxx
@@ -81,13 +81,13 @@ class RecorderOutput {
encoder->Dispose();
}
- bool Initialize(const config_param &param, Error &error_r) {
- return base.Configure(param, error_r);
+ bool Initialize(const ConfigBlock &block, Error &error_r) {
+ return base.Configure(block, error_r);
}
- static RecorderOutput *Create(const config_param &param, Error &error);
+ static RecorderOutput *Create(const ConfigBlock &block, Error &error);
- bool Configure(const config_param &param, Error &error);
+ bool Configure(const ConfigBlock &block, Error &error);
bool Open(AudioFormat &audio_format, Error &error);
void Close();
@@ -117,12 +117,12 @@ private:
};
inline bool
-RecorderOutput::Configure(const config_param &param, Error &error)
+RecorderOutput::Configure(const ConfigBlock &block, Error &error)
{
/* read configuration */
const char *encoder_name =
- param.GetBlockValue("encoder", "vorbis");
+ block.GetBlockValue("encoder", "vorbis");
const auto encoder_plugin = encoder_plugin_get(encoder_name);
if (encoder_plugin == nullptr) {
error.Format(config_domain,
@@ -130,11 +130,11 @@ RecorderOutput::Configure(const config_param &param, Error &error)
return false;
}
- path = param.GetBlockPath("path", error);
+ path = block.GetBlockPath("path", error);
if (error.IsDefined())
return false;
- const char *fmt = param.GetBlockValue("format_path", nullptr);
+ const char *fmt = block.GetBlockValue("format_path", nullptr);
if (fmt != nullptr)
format_path = fmt;
@@ -150,7 +150,7 @@ RecorderOutput::Configure(const config_param &param, Error &error)
/* initialize encoder */
- encoder = encoder_init(*encoder_plugin, param, error);
+ encoder = encoder_init(*encoder_plugin, block, error);
if (encoder == nullptr)
return false;
@@ -158,16 +158,16 @@ RecorderOutput::Configure(const config_param &param, Error &error)
}
RecorderOutput *
-RecorderOutput::Create(const config_param &param, Error &error)
+RecorderOutput::Create(const ConfigBlock &block, Error &error)
{
RecorderOutput *recorder = new RecorderOutput();
- if (!recorder->Initialize(param, error)) {
+ if (!recorder->Initialize(block, error)) {
delete recorder;
return nullptr;
}
- if (!recorder->Configure(param, error)) {
+ if (!recorder->Configure(block, error)) {
delete recorder;
return nullptr;
}
diff --git a/src/output/plugins/RoarOutputPlugin.cxx b/src/output/plugins/RoarOutputPlugin.cxx
index c0a429198..11b0f1671 100644
--- a/src/output/plugins/RoarOutputPlugin.cxx
+++ b/src/output/plugins/RoarOutputPlugin.cxx
@@ -60,11 +60,11 @@ public:
return &base;
}
- bool Initialize(const config_param &param, Error &error) {
- return base.Configure(param, error);
+ bool Initialize(const ConfigBlock &block, Error &error) {
+ return base.Configure(block, error);
}
- void Configure(const config_param &param);
+ void Configure(const ConfigBlock &block);
bool Open(AudioFormat &audio_format, Error &error);
void Close();
@@ -124,28 +124,28 @@ roar_output_set_volume(RoarOutput &roar, unsigned volume)
}
inline void
-RoarOutput::Configure(const config_param &param)
+RoarOutput::Configure(const ConfigBlock &block)
{
- host = param.GetBlockValue("server", "");
- name = param.GetBlockValue("name", "MPD");
+ host = block.GetBlockValue("server", "");
+ name = block.GetBlockValue("name", "MPD");
- const char *_role = param.GetBlockValue("role", "music");
+ const char *_role = block.GetBlockValue("role", "music");
role = _role != nullptr
? roar_str2role(_role)
: ROAR_ROLE_MUSIC;
}
static AudioOutput *
-roar_init(const config_param &param, Error &error)
+roar_init(const ConfigBlock &block, Error &error)
{
RoarOutput *self = new RoarOutput();
- if (!self->Initialize(param, error)) {
+ if (!self->Initialize(block, error)) {
delete self;
return nullptr;
}
- self->Configure(param);
+ self->Configure(block);
return *self;
}
diff --git a/src/output/plugins/ShoutOutputPlugin.cxx b/src/output/plugins/ShoutOutputPlugin.cxx
index 9157afd37..339c4e491 100644
--- a/src/output/plugins/ShoutOutputPlugin.cxx
+++ b/src/output/plugins/ShoutOutputPlugin.cxx
@@ -68,11 +68,11 @@ struct ShoutOutput final {
shout_free(shout_conn);
}
- bool Initialize(const config_param &param, Error &error) {
- return base.Configure(param, error);
+ bool Initialize(const ConfigBlock &block, Error &error) {
+ return base.Configure(block, error);
}
- bool Configure(const config_param &param, Error &error);
+ bool Configure(const ConfigBlock &block, Error &error);
};
static int shout_init_count;
@@ -92,18 +92,18 @@ shout_encoder_plugin_get(const char *name)
gcc_pure
static const char *
-require_block_string(const config_param &param, const char *name)
+require_block_string(const ConfigBlock &block, const char *name)
{
- const char *value = param.GetBlockValue(name);
+ const char *value = block.GetBlockValue(name);
if (value == nullptr)
FormatFatalError("no \"%s\" defined for shout device defined "
- "at line %d\n", name, param.line);
+ "at line %d\n", name, block.line);
return value;
}
inline bool
-ShoutOutput::Configure(const config_param &param, Error &error)
+ShoutOutput::Configure(const ConfigBlock &block, Error &error)
{
const AudioFormat audio_format = base.config_audio_format;
@@ -113,22 +113,22 @@ ShoutOutput::Configure(const config_param &param, Error &error)
return false;
}
- const char *host = require_block_string(param, "host");
- const char *mount = require_block_string(param, "mount");
- unsigned port = param.GetBlockValue("port", 0u);
+ const char *host = require_block_string(block, "host");
+ const char *mount = require_block_string(block, "mount");
+ unsigned port = block.GetBlockValue("port", 0u);
if (port == 0) {
error.Set(config_domain, "shout port must be configured");
return false;
}
- const char *passwd = require_block_string(param, "password");
- const char *name = require_block_string(param, "name");
+ const char *passwd = require_block_string(block, "password");
+ const char *name = require_block_string(block, "name");
- bool is_public = param.GetBlockValue("public", false);
+ bool is_public = block.GetBlockValue("public", false);
- const char *user = param.GetBlockValue("user", "source");
+ const char *user = block.GetBlockValue("user", "source");
- const char *value = param.GetBlockValue("quality");
+ const char *value = block.GetBlockValue("quality");
if (value != nullptr) {
char *test;
quality = strtod(value, &test);
@@ -141,14 +141,14 @@ ShoutOutput::Configure(const config_param &param, Error &error)
return false;
}
- if (param.GetBlockValue("bitrate") != nullptr) {
+ if (block.GetBlockValue("bitrate") != nullptr) {
error.Set(config_domain,
"quality and bitrate are "
"both defined");
return false;
}
} else {
- value = param.GetBlockValue("bitrate");
+ value = block.GetBlockValue("bitrate");
if (value == nullptr) {
error.Set(config_domain,
"neither bitrate nor quality defined");
@@ -165,7 +165,7 @@ ShoutOutput::Configure(const config_param &param, Error &error)
}
}
- const char *encoding = param.GetBlockValue("encoding", "ogg");
+ const char *encoding = block.GetBlockValue("encoding", "ogg");
const auto encoder_plugin = shout_encoder_plugin_get(encoding);
if (encoder_plugin == nullptr) {
error.Format(config_domain,
@@ -174,7 +174,7 @@ ShoutOutput::Configure(const config_param &param, Error &error)
return false;
}
- encoder = encoder_init(*encoder_plugin, param, error);
+ encoder = encoder_init(*encoder_plugin, block, error);
if (encoder == nullptr)
return false;
@@ -185,7 +185,7 @@ ShoutOutput::Configure(const config_param &param, Error &error)
shout_format = SHOUT_FORMAT_OGG;
unsigned protocol;
- value = param.GetBlockValue("protocol");
+ value = block.GetBlockValue("protocol");
if (value != nullptr) {
if (0 == strcmp(value, "shoutcast") &&
0 != strcmp(encoding, "mp3")) {
@@ -226,21 +226,21 @@ ShoutOutput::Configure(const config_param &param, Error &error)
}
/* optional paramters */
- timeout = param.GetBlockValue("timeout", DEFAULT_CONN_TIMEOUT);
+ timeout = block.GetBlockValue("timeout", DEFAULT_CONN_TIMEOUT);
- value = param.GetBlockValue("genre");
+ value = block.GetBlockValue("genre");
if (value != nullptr && shout_set_genre(shout_conn, value)) {
error.Set(shout_output_domain, shout_get_error(shout_conn));
return false;
}
- value = param.GetBlockValue("description");
+ value = block.GetBlockValue("description");
if (value != nullptr && shout_set_description(shout_conn, value)) {
error.Set(shout_output_domain, shout_get_error(shout_conn));
return false;
}
- value = param.GetBlockValue("url");
+ value = block.GetBlockValue("url");
if (value != nullptr && shout_set_url(shout_conn, value)) {
error.Set(shout_output_domain, shout_get_error(shout_conn));
return false;
@@ -272,15 +272,15 @@ ShoutOutput::Configure(const config_param &param, Error &error)
}
static AudioOutput *
-my_shout_init_driver(const config_param &param, Error &error)
+my_shout_init_driver(const ConfigBlock &block, Error &error)
{
ShoutOutput *sd = new ShoutOutput();
- if (!sd->Initialize(param, error)) {
+ if (!sd->Initialize(block, error)) {
delete sd;
return nullptr;
}
- if (!sd->Configure(param, error)) {
+ if (!sd->Configure(block, error)) {
delete sd;
return nullptr;
}
diff --git a/src/output/plugins/SolarisOutputPlugin.cxx b/src/output/plugins/SolarisOutputPlugin.cxx
index 15a8707fe..18c92d361 100644
--- a/src/output/plugins/SolarisOutputPlugin.cxx
+++ b/src/output/plugins/SolarisOutputPlugin.cxx
@@ -60,8 +60,8 @@ struct SolarisOutput {
SolarisOutput()
:base(solaris_output_plugin) {}
- bool Initialize(const config_param &param, Error &error_r) {
- return base.Configure(param, error_r);
+ bool Initialize(const ConfigBlock &block, Error &error_r) {
+ return base.Configure(block, error_r);
}
};
@@ -75,15 +75,15 @@ solaris_output_test_default_device(void)
}
static AudioOutput *
-solaris_output_init(const config_param &param, Error &error_r)
+solaris_output_init(const ConfigBlock &block, Error &error_r)
{
SolarisOutput *so = new SolarisOutput();
- if (!so->Initialize(param, error_r)) {
+ if (!so->Initialize(block, error_r)) {
delete so;
return nullptr;
}
- so->device = param.GetBlockValue("device", "/dev/audio");
+ so->device = block.GetBlockValue("device", "/dev/audio");
return &so->base;
}
diff --git a/src/output/plugins/WinmmOutputPlugin.cxx b/src/output/plugins/WinmmOutputPlugin.cxx
index 6b8f62844..95f359828 100644
--- a/src/output/plugins/WinmmOutputPlugin.cxx
+++ b/src/output/plugins/WinmmOutputPlugin.cxx
@@ -122,15 +122,15 @@ fail:
}
static AudioOutput *
-winmm_output_init(const config_param &param, Error &error)
+winmm_output_init(const ConfigBlock &block, Error &error)
{
WinmmOutput *wo = new WinmmOutput();
- if (!wo->base.Configure(param, error)) {
+ if (!wo->base.Configure(block, error)) {
delete wo;
return nullptr;
}
- const char *device = param.GetBlockValue("device");
+ const char *device = block.GetBlockValue("device");
if (!get_device_id(device, &wo->device_id, error)) {
delete wo;
return nullptr;
diff --git a/src/output/plugins/httpd/HttpdInternal.hxx b/src/output/plugins/httpd/HttpdInternal.hxx
index 6e659c703..d3ea49cd4 100644
--- a/src/output/plugins/httpd/HttpdInternal.hxx
+++ b/src/output/plugins/httpd/HttpdInternal.hxx
@@ -42,7 +42,7 @@
#include <queue>
#include <list>
-struct config_param;
+struct ConfigBlock;
class Error;
class EventLoop;
class ServerSocket;
@@ -162,16 +162,16 @@ public:
using DeferredMonitor::GetEventLoop;
- bool Init(const config_param &param, Error &error);
+ bool Init(const ConfigBlock &block, Error &error);
- bool Configure(const config_param &param, Error &error);
+ bool Configure(const ConfigBlock &block, Error &error);
- AudioOutput *InitAndConfigure(const config_param &param,
+ AudioOutput *InitAndConfigure(const ConfigBlock &block,
Error &error) {
- if (!Init(param, error))
+ if (!Init(block, error))
return nullptr;
- if (!Configure(param, error))
+ if (!Configure(block, error))
return nullptr;
return &base;
diff --git a/src/output/plugins/httpd/HttpdOutputPlugin.cxx b/src/output/plugins/httpd/HttpdOutputPlugin.cxx
index 19ee38cd2..a99f9b412 100644
--- a/src/output/plugins/httpd/HttpdOutputPlugin.cxx
+++ b/src/output/plugins/httpd/HttpdOutputPlugin.cxx
@@ -91,17 +91,17 @@ HttpdOutput::Unbind()
}
inline bool
-HttpdOutput::Configure(const config_param &param, Error &error)
+HttpdOutput::Configure(const ConfigBlock &block, Error &error)
{
/* read configuration */
- name = param.GetBlockValue("name", "Set name in config");
- genre = param.GetBlockValue("genre", "Set genre in config");
- website = param.GetBlockValue("website", "Set website in config");
+ name = block.GetBlockValue("name", "Set name in config");
+ genre = block.GetBlockValue("genre", "Set genre in config");
+ website = block.GetBlockValue("website", "Set website in config");
- unsigned port = param.GetBlockValue("port", 8000u);
+ unsigned port = block.GetBlockValue("port", 8000u);
const char *encoder_name =
- param.GetBlockValue("encoder", "vorbis");
+ block.GetBlockValue("encoder", "vorbis");
const auto encoder_plugin = encoder_plugin_get(encoder_name);
if (encoder_plugin == nullptr) {
error.Format(httpd_output_domain,
@@ -109,11 +109,11 @@ HttpdOutput::Configure(const config_param &param, Error &error)
return false;
}
- clients_max = param.GetBlockValue("max_clients", 0u);
+ clients_max = block.GetBlockValue("max_clients", 0u);
/* set up bind_to_address */
- const char *bind_to_address = param.GetBlockValue("bind_to_address");
+ const char *bind_to_address = block.GetBlockValue("bind_to_address");
bool success = bind_to_address != nullptr &&
strcmp(bind_to_address, "any") != 0
? AddHost(bind_to_address, port, error)
@@ -123,7 +123,7 @@ HttpdOutput::Configure(const config_param &param, Error &error)
/* initialize encoder */
- encoder = encoder_init(*encoder_plugin, param, error);
+ encoder = encoder_init(*encoder_plugin, block, error);
if (encoder == nullptr)
return false;
@@ -136,17 +136,17 @@ HttpdOutput::Configure(const config_param &param, Error &error)
}
inline bool
-HttpdOutput::Init(const config_param &param, Error &error)
+HttpdOutput::Init(const ConfigBlock &block, Error &error)
{
- return base.Configure(param, error);
+ return base.Configure(block, error);
}
static AudioOutput *
-httpd_output_init(const config_param &param, Error &error)
+httpd_output_init(const ConfigBlock &block, Error &error)
{
HttpdOutput *httpd = new HttpdOutput(io_thread_get());
- AudioOutput *result = httpd->InitAndConfigure(param, error);
+ AudioOutput *result = httpd->InitAndConfigure(block, error);
if (result == nullptr)
delete httpd;
diff --git a/src/output/plugins/sles/SlesOutputPlugin.cxx b/src/output/plugins/sles/SlesOutputPlugin.cxx
index 0c39714bb..94084e1b8 100644
--- a/src/output/plugins/sles/SlesOutputPlugin.cxx
+++ b/src/output/plugins/sles/SlesOutputPlugin.cxx
@@ -91,11 +91,11 @@ public:
return &base;
}
- bool Initialize(const config_param &param, Error &error) {
- return base.Configure(param, error);
+ bool Initialize(const ConfigBlock &block, Error &error) {
+ return base.Configure(block, error);
}
- bool Configure(const config_param &param, Error &error);
+ bool Configure(const ConfigBlock &block, Error &error);
bool Open(AudioFormat &audio_format, Error &error);
void Close();
@@ -129,7 +129,7 @@ private:
static constexpr Domain sles_domain("sles");
inline bool
-SlesOutput::Configure(const config_param &, Error &)
+SlesOutput::Configure(const ConfigBlock &, Error &)
{
return true;
}
@@ -445,12 +445,12 @@ sles_test_default_device()
}
static AudioOutput *
-sles_output_init(const config_param &param, Error &error)
+sles_output_init(const ConfigBlock &block, Error &error)
{
SlesOutput *sles = new SlesOutput();
- if (!sles->Initialize(param, error) ||
- !sles->Configure(param, error)) {
+ if (!sles->Initialize(block, error) ||
+ !sles->Configure(block, error)) {
delete sles;
return nullptr;
}
diff --git a/src/playlist/PlaylistPlugin.hxx b/src/playlist/PlaylistPlugin.hxx
index 72cf9ca40..adbf4b35d 100644
--- a/src/playlist/PlaylistPlugin.hxx
+++ b/src/playlist/PlaylistPlugin.hxx
@@ -20,7 +20,7 @@
#ifndef MPD_PLAYLIST_PLUGIN_HXX
#define MPD_PLAYLIST_PLUGIN_HXX
-struct config_param;
+struct ConfigBlock;
class InputStream;
struct Tag;
class Mutex;
@@ -38,7 +38,7 @@ struct playlist_plugin {
* @return true if the plugin was initialized successfully,
* false if the plugin is not available
*/
- bool (*init)(const config_param &param);
+ bool (*init)(const ConfigBlock &block);
/**
* Deinitialize a plugin which was initialized successfully.
@@ -75,10 +75,10 @@ struct playlist_plugin {
*/
static inline bool
playlist_plugin_init(const struct playlist_plugin *plugin,
- const config_param &param)
+ const ConfigBlock &block)
{
return plugin->init != nullptr
- ? plugin->init(param)
+ ? plugin->init(block)
: true;
}
diff --git a/src/playlist/PlaylistRegistry.cxx b/src/playlist/PlaylistRegistry.cxx
index a5a5319fc..d59ec1710 100644
--- a/src/playlist/PlaylistRegistry.cxx
+++ b/src/playlist/PlaylistRegistry.cxx
@@ -36,7 +36,7 @@
#include "util/Error.hxx"
#include "util/Macros.hxx"
#include "config/ConfigGlobal.hxx"
-#include "config/Param.hxx"
+#include "config/Block.hxx"
#include "Log.hxx"
#include <assert.h>
@@ -77,12 +77,12 @@ static bool playlist_plugins_enabled[n_playlist_plugins];
void
playlist_list_global_init(void)
{
- const config_param empty;
+ const ConfigBlock empty;
for (unsigned i = 0; playlist_plugins[i] != nullptr; ++i) {
const struct playlist_plugin *plugin = playlist_plugins[i];
const auto *param =
- config_find_block(ConfigOption::PLAYLIST_PLUGIN,
+ config_find_block(ConfigBlockOption::PLAYLIST_PLUGIN,
"name", plugin->name);
if (param == nullptr)
param = &empty;
diff --git a/src/playlist/plugins/SoundCloudPlaylistPlugin.cxx b/src/playlist/plugins/SoundCloudPlaylistPlugin.cxx
index 0c14f59dd..d6f25f48c 100644
--- a/src/playlist/plugins/SoundCloudPlaylistPlugin.cxx
+++ b/src/playlist/plugins/SoundCloudPlaylistPlugin.cxx
@@ -21,7 +21,7 @@
#include "SoundCloudPlaylistPlugin.hxx"
#include "../PlaylistPlugin.hxx"
#include "../MemorySongEnumerator.hxx"
-#include "config/Param.hxx"
+#include "config/Block.hxx"
#include "input/InputStream.hxx"
#include "tag/TagBuilder.hxx"
#include "util/StringUtil.hxx"
@@ -44,10 +44,10 @@ static struct {
static constexpr Domain soundcloud_domain("soundcloud");
static bool
-soundcloud_init(const config_param &param)
+soundcloud_init(const ConfigBlock &block)
{
// APIKEY for MPD application, registered under DarkFox' account.
- soundcloud_config.apikey = param.GetBlockValue("apikey", "a25e51780f7f86af0afa91f241d091f8");
+ soundcloud_config.apikey = block.GetBlockValue("apikey", "a25e51780f7f86af0afa91f241d091f8");
if (soundcloud_config.apikey.empty()) {
LogDebug(soundcloud_domain,
"disabling the soundcloud playlist plugin "