Make sure plugins are activated at least once before they are cleaned up
[ardour.git] / libs / ardour / ardour / ladspa_plugin.h
index 27e8bc5e842a7352b6ea17d57d296a741aaaa0f3..e466e532155fb5c506da0658d2414a24e5f1743e 100644 (file)
@@ -15,7 +15,6 @@
     along with this program; if not, write to the Free Software
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
-    $Id$
 */
 
 #ifndef __ardour_ladspa_plugin_h__
@@ -60,24 +59,37 @@ 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);
                }
        }
@@ -86,7 +98,7 @@ class LadspaPlugin : public ARDOUR::Plugin
        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 (uint32_t);
+       string describe_parameter (Parameter);
        string state_node_name() const { return "ladspa"; }
        void print_parameter (uint32_t, char*, uint32_t len) const;
 
@@ -134,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 ();
 };