Make sure activate() and deactivate() are never run multiple times in a
authorSampo Savolainen <v2@iki.fi>
Tue, 25 Sep 2007 17:56:39 +0000 (17:56 +0000)
committerSampo Savolainen <v2@iki.fi>
Tue, 25 Sep 2007 17:56:39 +0000 (17:56 +0000)
row. Make cleanup work nicely

git-svn-id: svn://localhost/ardour2/trunk@2485 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/ardour/ladspa_plugin.h

index 4c8d9ff74172cd13fe7f1f18ae24b333395a0ca1..336538432104eb3a60b043bd2e596d314d311980 100644 (file)
@@ -66,17 +66,29 @@ class LadspaPlugin : public ARDOUR::Plugin
        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) {
+               deactivate();
+
+               if (descriptor->cleanup) {
                        descriptor->cleanup (handle);
                }
        }