Mercurial > hg > piper-cpp
diff bits/PreservingPluginHandleMapper.h @ 60:8a4bcb3dc3a6
Replace exceptions throughout the JSON-handling and adapter code with string-arg error handling. No longer need exception handling enabled in Emscripten (with its consequent runtime overhead - though we still need to check whether this error handling regime is actually faster).
author | Chris Cannam <c.cannam@qmul.ac.uk> |
---|---|
date | Tue, 20 Sep 2016 16:35:47 +0100 |
parents | 7aec704705c7 |
children |
line wrap: on
line diff
--- a/bits/PreservingPluginHandleMapper.h Mon Sep 19 15:52:38 2016 +0100 +++ b/bits/PreservingPluginHandleMapper.h Tue Sep 20 16:35:47 2016 +0100 @@ -54,30 +54,34 @@ m_plugin(0), m_omapper(std::make_shared<PreservingPluginOutputIdMapper>()) { } - virtual Handle pluginToHandle(Vamp::Plugin *p) const { + virtual Handle pluginToHandle(Vamp::Plugin *p) const noexcept { + if (!p) return INVALID_HANDLE; if (p == m_plugin) return m_handle; else { std::cerr << "PreservingPluginHandleMapper: p = " << p << " differs from saved m_plugin " << m_plugin << " (not returning saved handle " << m_handle << ")" << std::endl; - throw NotFound(); + return INVALID_HANDLE; } } - virtual Vamp::Plugin *handleToPlugin(Handle h) const { + virtual Vamp::Plugin *handleToPlugin(Handle h) const noexcept { + if (h == INVALID_HANDLE) return nullptr; m_handle = h; m_plugin = reinterpret_cast<Vamp::Plugin *>(h); return m_plugin; } virtual const std::shared_ptr<PluginOutputIdMapper> pluginToOutputIdMapper - (Vamp::Plugin *) const { + (Vamp::Plugin *p) const noexcept { + if (!p) return {}; return m_omapper; } virtual const std::shared_ptr<PluginOutputIdMapper> handleToOutputIdMapper - (Handle h) const { + (Handle h) const noexcept { + if (h == INVALID_HANDLE) return {}; return m_omapper; }