diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2020-07-19 16:57:20 +0200 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2020-07-19 16:57:20 +0200 |
commit | 83254f1690123dc66991ce50c9db23c7cadba711 (patch) | |
tree | a8c53ba99c47672a61c67146932125320f4fc5a6 /plugins/LV2/include | |
parent | 225608fe4a2370a08e80db0b72f70a56fbcf5060 (diff) | |
download | airwindows-lv2-port-83254f1690123dc66991ce50c9db23c7cadba711.tar.gz airwindows-lv2-port-83254f1690123dc66991ce50c9db23c7cadba711.tar.bz2 airwindows-lv2-port-83254f1690123dc66991ce50c9db23c7cadba711.zip |
LV2: Refactor common LV2Wrapper.
Move the common wrapper code into a template class that can be
instantiated from each plugin.
Diffstat (limited to 'plugins/LV2/include')
-rw-r--r-- | plugins/LV2/include/lv2wrapper.h | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/plugins/LV2/include/lv2wrapper.h b/plugins/LV2/include/lv2wrapper.h new file mode 100644 index 0000000..26531cb --- /dev/null +++ b/plugins/LV2/include/lv2wrapper.h @@ -0,0 +1,75 @@ +#include "lv2/core/lv2.h" + +LV2_Descriptor descriptor; + +template<typename Plugin> +class LV2Wrapper +{ +public: + LV2Wrapper() + { + LV2_Descriptor d = { + Plugin::URI, + LV2Wrapper::instantiate, + LV2Wrapper::connect_port, + LV2Wrapper::activate, + LV2Wrapper::run, + LV2Wrapper::deactivate, + LV2Wrapper::destroy, + LV2Wrapper::extension_data + }; + descriptor = d; + } + +private: + static LV2_Handle instantiate( + const LV2_Descriptor * d, + double rate, + const char * path, + const LV2_Feature * const * features) + { + return new Plugin{rate}; + } + + static void connect_port( + LV2_Handle instance, + uint32_t port, + void * data) + { + auto accel = static_cast<Plugin *>(instance); + accel->connect_port(port, data); + } + + static void activate(LV2_Handle instance) + { + } + + static void run(LV2_Handle instance, uint32_t num_samples) + { + auto accel = static_cast<Plugin *>(instance); + accel->run(num_samples); + } + + static void deactivate(LV2_Handle) + { + } + + static void destroy(LV2_Handle instance) + { + delete static_cast<Plugin *>(instance); + } + + static const void * extension_data(const char * uri) + { + return nullptr; + } +}; + +LV2_SYMBOL_EXPORT +const LV2_Descriptor * lv2_descriptor(uint32_t idx) +{ + if (idx == 0) + return &descriptor; + + return nullptr; +} |