OutputInit: allow "init" to throw exception

This commit is contained in:
Max Kellermann 2016-10-28 21:11:52 +02:00
parent a249a630c0
commit 0c464b24ad
3 changed files with 15 additions and 1 deletions

View File

@ -454,6 +454,9 @@ private:
*/
extern struct notify audio_output_client_notify;
/**
* Throws #std::runtime_error on error.
*/
AudioOutput *
audio_output_new(EventLoop &event_loop, const ConfigBlock &block,
MixerListener &mixer_listener,

View File

@ -32,6 +32,8 @@
#include "config/ConfigOption.hxx"
#include "notify.hxx"
#include <stdexcept>
#include <assert.h>
#include <string.h>
@ -51,7 +53,7 @@ MultipleOutputs::~MultipleOutputs()
static AudioOutput *
LoadOutput(EventLoop &event_loop, MixerListener &mixer_listener,
PlayerControl &pc, const ConfigBlock &block)
{
try {
Error error;
AudioOutput *output = audio_output_new(event_loop, block,
mixer_listener,
@ -66,6 +68,13 @@ LoadOutput(EventLoop &event_loop, MixerListener &mixer_listener,
}
return output;
} catch (const std::runtime_error &e) {
if (block.line > 0)
FormatFatalError("line %i: %s",
block.line,
e.what());
else
FatalError(e.what());
}
void

View File

@ -50,6 +50,8 @@ struct AudioOutputPlugin {
* Configure and initialize the device, but do not open it
* yet.
*
* Throws #std::runtime_error on error.
*
* @param param the configuration section, or nullptr if there is
* no configuration
* @return nullptr on error, or an opaque pointer to the plugin's