aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2020-09-02 21:30:31 +0200
committerHarald Eilertsen <haraldei@anduin.net>2020-09-02 21:39:00 +0200
commit529eff1742ef8e62bc8ccb402fcaa21eba7e2ff7 (patch)
treeecacf6f58410c4576b46acc5927f4cefd314ab18
parent1e195c5cd709d24a157c34352491e9124a0463df (diff)
downloadairwindows-lv2-port-529eff1742ef8e62bc8ccb402fcaa21eba7e2ff7.tar.gz
airwindows-lv2-port-529eff1742ef8e62bc8ccb402fcaa21eba7e2ff7.tar.bz2
airwindows-lv2-port-529eff1742ef8e62bc8ccb402fcaa21eba7e2ff7.zip
LV2: add support for (de)activate in plugin wrapper.
The `activate` callback is called _before_ any audio processing begins. This is a good place to initialize the plugin to a known good state. The `deactivate` callback is called _after_ all audio processing is finished. If any cleanup is needed, this is a good place to do so.
-rw-r--r--plugins/LV2/include/lv2plugin.h5
-rw-r--r--plugins/LV2/include/lv2wrapper.h6
2 files changed, 10 insertions, 1 deletions
diff --git a/plugins/LV2/include/lv2plugin.h b/plugins/LV2/include/lv2plugin.h
index 46464a3..77b3996 100644
--- a/plugins/LV2/include/lv2plugin.h
+++ b/plugins/LV2/include/lv2plugin.h
@@ -12,6 +12,8 @@ public:
: rate(frame_rate)
{}
+ virtual ~LV2Plugin() {}
+
void connect_port(uint32_t port, void * data)
{
if (port < nparams) {
@@ -33,6 +35,9 @@ public:
return rate;
}
+ virtual void activate() {}
+ virtual void deactivate() {}
+
const float * params[nparams];
const float * in[ninputs];
float * out[noutputs];
diff --git a/plugins/LV2/include/lv2wrapper.h b/plugins/LV2/include/lv2wrapper.h
index 26531cb..e92c690 100644
--- a/plugins/LV2/include/lv2wrapper.h
+++ b/plugins/LV2/include/lv2wrapper.h
@@ -42,6 +42,8 @@ private:
static void activate(LV2_Handle instance)
{
+ auto accel = static_cast<Plugin *>(instance);
+ accel->activate();
}
static void run(LV2_Handle instance, uint32_t num_samples)
@@ -50,8 +52,10 @@ private:
accel->run(num_samples);
}
- static void deactivate(LV2_Handle)
+ static void deactivate(LV2_Handle instance)
{
+ auto accel = static_cast<Plugin *>(instance);
+ accel->deactivate();
}
static void destroy(LV2_Handle instance)