From c4acccac14ed269be0be5336d7bf390a4ae818b5 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 28 Oct 2016 22:41:07 +0200 Subject: [PATCH] output/Init: add constructor overload which calls Configure() --- src/output/Init.cxx | 9 +++++++++ src/output/Internal.hxx | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/src/output/Init.cxx b/src/output/Init.cxx index 447ff5279..683999e6d 100644 --- a/src/output/Init.cxx +++ b/src/output/Init.cxx @@ -58,6 +58,15 @@ AudioOutput::AudioOutput(const AudioOutputPlugin &_plugin) assert(plugin.play != nullptr); } +AudioOutput::AudioOutput(const AudioOutputPlugin &_plugin, + const ConfigBlock &block) + :AudioOutput(_plugin) +{ + Error error; + if (!Configure(block, error)) + throw std::runtime_error(error.GetMessage()); +} + static const AudioOutputPlugin * audio_output_detect(Error &error) { diff --git a/src/output/Internal.hxx b/src/output/Internal.hxx index da6a1bc5c..053a7db0c 100644 --- a/src/output/Internal.hxx +++ b/src/output/Internal.hxx @@ -283,6 +283,13 @@ struct AudioOutput { bool current_chunk_finished; AudioOutput(const AudioOutputPlugin &_plugin); + + /** + * Throws #std::runtime_error on error. + */ + AudioOutput(const AudioOutputPlugin &_plugin, + const ConfigBlock &block); + ~AudioOutput(); bool Configure(const ConfigBlock &block, Error &error);