Make sure plugins are activated at least once before they are cleaned up
[ardour.git] / libs / ardour / ardour / ladspa_plugin.h
index 63f8f600d34f1b8fe213ff31644c594897f9e247..e466e532155fb5c506da0658d2414a24e5f1743e 100644 (file)
@@ -32,6 +32,7 @@
 
 #include <jack/types.h>
 #include <ardour/ladspa.h>
+#include <ardour/plugin_state.h>
 #include <ardour/plugin.h>
 #include <ardour/ladspa_plugin.h>
 
@@ -58,31 +59,46 @@ class LadspaPlugin : public ARDOUR::Plugin
        const char * maker() const                       { return descriptor->Maker; }
        uint32_t parameter_count() const                 { return descriptor->PortCount; }
        float default_value (uint32_t port);
-       nframes_t latency() const;
+       nframes_t signal_latency() const;
        void set_parameter (uint32_t port, float val);
        float get_parameter (uint32_t port) const;
        int get_parameter_descriptor (uint32_t which, ParameterDescriptor&) const;
-       std::set<uint32_t> automatable() const;
+       std::set<Parameter> automatable() const;
        uint32_t nth_parameter (uint32_t port, bool& ok) const;
        void activate () { 
+               if (was_activated)
+                       return;
+
                if (descriptor->activate) {
                        descriptor->activate (handle);
                }
+
                was_activated = true;
        }
        void deactivate () {
-               if (descriptor->deactivate) 
+               if (!was_activated)
+                       return;
+
+               if (descriptor->deactivate) {
                        descriptor->deactivate (handle);
+               }
+
+               was_activated = false;
        }
        void cleanup () {
-               if (was_activated && descriptor->cleanup) {
+               activate();
+               deactivate();
+
+               if (descriptor->cleanup) {
                        descriptor->cleanup (handle);
                }
        }
        void set_block_size (nframes_t nframes) {}
        
-       int connect_and_run (vector<Sample*>& bufs, uint32_t maxbuf, int32_t& in, int32_t& out, nframes_t nframes, nframes_t offset);
-       string describe_parameter (uint32_t);
+       int connect_and_run (BufferSet& bufs, uint32_t& in, uint32_t& out, nframes_t nframes, nframes_t offset);
+       void store_state (ARDOUR::PluginState&);
+       void restore_state (ARDOUR::PluginState&);
+       string describe_parameter (Parameter);
        string state_node_name() const { return "ladspa"; }
        void print_parameter (uint32_t, char*, uint32_t len) const;
 
@@ -130,7 +146,7 @@ class LadspaPlugin : public ARDOUR::Plugin
        bool                     was_activated;
 
        void init (void *mod, uint32_t index, nframes_t rate);
-       void run (nframes_t nsamples);
+       void run_in_place (nframes_t nsamples);
        void latency_compute_run ();
 };