diff options
author | Max Kellermann <max@duempel.org> | 2014-03-02 00:17:32 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-03-02 00:17:32 +0100 |
commit | 2bf2f34b1211bfde95ef4ada77147a8b65830084 (patch) | |
tree | a6e639ccd3d07d445968f888e59bab580981ce89 /src/input/Init.cxx | |
parent | 7453c26ec4838760dec767b2f99afff9eb537d53 (diff) | |
download | mpd-2bf2f34b1211bfde95ef4ada77147a8b65830084.tar.gz mpd-2bf2f34b1211bfde95ef4ada77147a8b65830084.tar.xz mpd-2bf2f34b1211bfde95ef4ada77147a8b65830084.zip |
InputPlugin: allow init() to soft-fail
Add enum InputResult which is a tri-state. Input plugins may now fail
and just become unavailable.
Diffstat (limited to '')
-rw-r--r-- | src/input/Init.cxx | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/input/Init.cxx b/src/input/Init.cxx index 4b8eac320..5e64dcaed 100644 --- a/src/input/Init.cxx +++ b/src/input/Init.cxx @@ -25,6 +25,7 @@ #include "config/ConfigGlobal.hxx" #include "config/ConfigOption.hxx" #include "config/ConfigData.hxx" +#include "Log.hxx" #include <assert.h> #include <string.h> @@ -49,12 +50,29 @@ input_stream_global_init(Error &error) /* the plugin is disabled in mpd.conf */ continue; - if (plugin->init == nullptr || plugin->init(*param, error)) + InputPlugin::InitResult result = plugin->init != nullptr + ? plugin->init(*param, error) + : InputPlugin::InitResult::SUCCESS; + + switch (result) { + case InputPlugin::InitResult::SUCCESS: input_plugins_enabled[i] = true; - else { + break; + + case InputPlugin::InitResult::ERROR: error.FormatPrefix("Failed to initialize input plugin '%s': ", plugin->name); return false; + + case InputPlugin::InitResult::UNAVAILABLE: + if (error.IsDefined()) { + FormatError(error, + "Input plugin '%s' is unavailable: ", + plugin->name); + error.Clear(); + } + + break; } } |