output/Init: migrate Configure() from class Error to C++ exceptions

This commit is contained in:
Max Kellermann 2016-11-09 12:06:54 +01:00
parent bbe7a37359
commit cf2b814629
2 changed files with 6 additions and 15 deletions

View File

@ -58,9 +58,7 @@ AudioOutput::AudioOutput(const AudioOutputPlugin &_plugin,
assert(plugin.close != nullptr); assert(plugin.close != nullptr);
assert(plugin.play != nullptr); assert(plugin.play != nullptr);
Error error; Configure(block);
if (!Configure(block, error))
throw std::runtime_error(error.GetMessage());
} }
static const AudioOutputPlugin * static const AudioOutputPlugin *
@ -155,16 +153,13 @@ audio_output_load_mixer(EventLoop &event_loop, AudioOutput &ao,
gcc_unreachable(); gcc_unreachable();
} }
bool void
AudioOutput::Configure(const ConfigBlock &block, Error &error) AudioOutput::Configure(const ConfigBlock &block)
{ {
if (!block.IsNull()) { if (!block.IsNull()) {
name = block.GetBlockValue(AUDIO_OUTPUT_NAME); name = block.GetBlockValue(AUDIO_OUTPUT_NAME);
if (name == nullptr) { if (name == nullptr)
error.Set(config_domain, throw std::runtime_error("Missing \"name\" configuration");
"Missing \"name\" configuration");
return false;
}
const char *p = block.GetBlockValue(AUDIO_OUTPUT_FORMAT); const char *p = block.GetBlockValue(AUDIO_OUTPUT_FORMAT);
if (p != nullptr) if (p != nullptr)
@ -208,10 +203,6 @@ AudioOutput::Configure(const ConfigBlock &block, Error &error)
"Failed to initialize filter chain for '%s'", "Failed to initialize filter chain for '%s'",
name); name);
} }
/* done */
return true;
} }
static bool static bool

View File

@ -291,7 +291,7 @@ struct AudioOutput {
~AudioOutput(); ~AudioOutput();
private: private:
bool Configure(const ConfigBlock &block, Error &error); void Configure(const ConfigBlock &block);
public: public:
void StartThread(); void StartThread();