aboutsummaryrefslogtreecommitdiffstats
path: root/src/InputInit.cxx
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/InputInit.cxx33
1 files changed, 13 insertions, 20 deletions
diff --git a/src/InputInit.cxx b/src/InputInit.cxx
index f6e40a6f9..01ed57d5a 100644
--- a/src/InputInit.cxx
+++ b/src/InputInit.cxx
@@ -21,16 +21,14 @@
#include "InputInit.hxx"
#include "InputRegistry.hxx"
#include "InputPlugin.hxx"
+#include "util/Error.hxx"
+#include "util/Domain.hxx"
#include "conf.h"
#include <assert.h>
#include <string.h>
-static inline GQuark
-input_quark(void)
-{
- return g_quark_from_static_string("input");
-}
+extern constexpr Domain input_domain("input");
/**
* Find the "input" configuration block for the specified plugin.
@@ -39,16 +37,16 @@ input_quark(void)
* @return the configuration block, or NULL if none was configured
*/
static const struct config_param *
-input_plugin_config(const char *plugin_name, GError **error_r)
+input_plugin_config(const char *plugin_name, Error &error)
{
const struct config_param *param = NULL;
while ((param = config_get_next_param(CONF_INPUT, param)) != NULL) {
const char *name = param->GetBlockValue("plugin");
if (name == NULL) {
- g_set_error(error_r, input_quark(), 0,
- "input configuration without 'plugin' name in line %d",
- param->line);
+ error.Format(input_domain,
+ "input configuration without 'plugin' name in line %d",
+ param->line);
return NULL;
}
@@ -60,12 +58,10 @@ input_plugin_config(const char *plugin_name, GError **error_r)
}
bool
-input_stream_global_init(GError **error_r)
+input_stream_global_init(Error &error)
{
const config_param empty;
- GError *error = NULL;
-
for (unsigned i = 0; input_plugins[i] != NULL; ++i) {
const struct input_plugin *plugin = input_plugins[i];
@@ -74,24 +70,21 @@ input_stream_global_init(GError **error_r)
assert(plugin->open != NULL);
const struct config_param *param =
- input_plugin_config(plugin->name, &error);
+ input_plugin_config(plugin->name, error);
if (param == nullptr) {
- if (error != nullptr) {
- g_propagate_error(error_r, error);
+ if (error.IsDefined())
return false;
- }
param = &empty;
} else if (!param->GetBlockValue("enabled", true))
/* the plugin is disabled in mpd.conf */
continue;
- if (plugin->init == NULL || plugin->init(*param, &error))
+ if (plugin->init == NULL || plugin->init(*param, error))
input_plugins_enabled[i] = true;
else {
- g_propagate_prefixed_error(error_r, error,
- "Failed to initialize input plugin '%s': ",
- plugin->name);
+ error.FormatPrefix("Failed to initialize input plugin '%s': ",
+ plugin->name);
return false;
}
}