Mercurial > hg > piper-cpp
diff vamp-client/qt/AutoPlugin.h @ 170:590b1a1fd955
More work on error and exception handling
author | Chris Cannam <cannam@all-day-breakfast.com> |
---|---|
date | Tue, 31 Jan 2017 14:53:24 +0000 |
parents | 6ccb195d6de6 |
children | 52322dde68ea |
line wrap: on
line diff
--- a/vamp-client/qt/AutoPlugin.h Tue Jan 31 11:26:07 2017 +0000 +++ b/vamp-client/qt/AutoPlugin.h Tue Jan 31 14:53:24 2017 +0000 @@ -38,12 +38,21 @@ #include "ProcessQtTransport.h" #include "../CapnpRRClient.h" +#include "../Exceptions.h" #include <cstdint> namespace piper_vamp { namespace client { +/** + * This "plugin" make the Piper client abstraction behave like a local + * Vamp plugin, with its own server that lasts only for the lifetime + * of this plugin and serves only it. + * + * Note that any method may throw ServerCrashed, RequestTimedOut or + * ProtocolError exceptions. + */ class AutoPlugin : public Vamp::Plugin { public: @@ -129,7 +138,14 @@ virtual bool initialise(size_t inputChannels, size_t stepSize, size_t blockSize) { - return getPlugin()->initialise(inputChannels, stepSize, blockSize); + try { + return getPlugin()->initialise(inputChannels, stepSize, blockSize); + } catch (const ServiceError &e) { + // Sadly, the Vamp API has taught hosts to try to divine + // initialisation problems from a bool return value alone + log(std::string("AutoPlugin: initialise failed: ") + e.what()); + return false; + } } virtual void reset() {