fix minor problem with recent cherry-picking from cairocanvas
[ardour.git] / libs / ardour / ladspa_plugin.cc
index 3a25eab384b758292ddc16e9c444db69a4fda277..bc3a83799bd45356424107c5b1d13509b530c7dc 100644 (file)
 #include "pbd/compose.h"
 #include "pbd/error.h"
 #include "pbd/xml++.h"
+#include "pbd/stacktrace.h"
 
-#include "midi++/manager.h"
-
-#include "ardour/ardour.h"
 #include "ardour/session.h"
-#include "ardour/audioengine.h"
 #include "ardour/ladspa_plugin.h"
 #include "ardour/buffer_set.h"
 #include "ardour/audio_buffer.h"
@@ -115,7 +112,9 @@ LadspaPlugin::init (void *mod, uint32_t index, framecnt_t rate)
        port_cnt = parameter_count();
 
        _control_data = new LADSPA_Data[port_cnt];
+       memset (_control_data, 0, sizeof (LADSPA_Data) * port_cnt);
        _shadow_data = new LADSPA_Data[port_cnt];
+       memset (_shadow_data, 0, sizeof (LADSPA_Data) * port_cnt);
 
        for (i = 0; i < port_cnt; ++i) {
                if (LADSPA_IS_PORT_CONTROL(port_descriptor (i))) {
@@ -281,6 +280,11 @@ void
 LadspaPlugin::set_parameter (uint32_t which, float val)
 {
        if (which < _descriptor->PortCount) {
+
+               if (get_parameter (which) == val) {
+                       return;
+               }
+
                _shadow_data[which] = (LADSPA_Data) val;
 
 #if 0
@@ -290,8 +294,8 @@ LadspaPlugin::set_parameter (uint32_t which, float val)
 #endif
 
        } else {
-               warning << string_compose (_("illegal parameter number used with plugin \"%1\". This may"
-                                            "indicate a change in the plugin design, and presets may be"
+               warning << string_compose (_("illegal parameter number used with plugin \"%1\". This may "
+                                            "indicate a change in the plugin design, and presets may be "
                                             "invalid"), name())
                        << endmsg;
        }
@@ -357,6 +361,7 @@ LadspaPlugin::set_state (const XMLNode& node, int version)
                return set_state_2X (node, version);
        }
 
+#ifndef NO_PLUGIN_STATE
        XMLNodeList nodes;
        XMLProperty *prop;
        XMLNodeConstIterator iter;
@@ -364,6 +369,7 @@ LadspaPlugin::set_state (const XMLNode& node, int version)
        const char *port;
        const char *data;
        uint32_t port_id;
+#endif
        LocaleGuard lg (X_("POSIX"));
 
        if (node.name() != state_node_name()) {
@@ -371,6 +377,8 @@ LadspaPlugin::set_state (const XMLNode& node, int version)
                return -1;
        }
 
+#ifndef NO_PLUGIN_STATE
+
        nodes = node.children ("Port");
 
        for (iter = nodes.begin(); iter != nodes.end(); ++iter) {
@@ -393,6 +401,7 @@ LadspaPlugin::set_state (const XMLNode& node, int version)
                sscanf (port, "%" PRIu32, &port_id);
                set_parameter (port_id, atof(data));
        }
+#endif
 
        latency_compute_run ();
 
@@ -402,6 +411,7 @@ LadspaPlugin::set_state (const XMLNode& node, int version)
 int
 LadspaPlugin::set_state_2X (const XMLNode& node, int /* version */)
 {
+#ifndef NO_PLUGIN_STATE
        XMLNodeList nodes;
        XMLProperty *prop;
        XMLNodeConstIterator iter;
@@ -409,6 +419,7 @@ LadspaPlugin::set_state_2X (const XMLNode& node, int /* version */)
        const char *port;
        const char *data;
        uint32_t port_id;
+#endif
        LocaleGuard lg (X_("POSIX"));
 
        if (node.name() != state_node_name()) {
@@ -416,6 +427,7 @@ LadspaPlugin::set_state_2X (const XMLNode& node, int /* version */)
                return -1;
        }
 
+#ifndef NO_PLUGIN_STATE
        nodes = node.children ("port");
 
        for(iter = nodes.begin(); iter != nodes.end(); ++iter){
@@ -440,6 +452,7 @@ LadspaPlugin::set_state_2X (const XMLNode& node, int /* version */)
        }
 
        latency_compute_run ();
+#endif
 
        return 0;
 }
@@ -549,7 +562,7 @@ LadspaPlugin::connect_and_run (BufferSet& bufs,
        cycles_t then = get_cycles ();
 
        BufferSet& silent_bufs  = _session.get_silent_buffers(ChanCount(DataType::AUDIO, 1));
-       BufferSet& scratch_bufs = _session.get_silent_buffers(ChanCount(DataType::AUDIO, 1));
+       BufferSet& scratch_bufs = _session.get_scratch_buffers(ChanCount(DataType::AUDIO, 1));
 
        uint32_t audio_in_index  = 0;
        uint32_t audio_out_index = 0;