Fix comment.
[ardour.git] / libs / ardour / ladspa_plugin.cc
index 1ea158d7cdeecd91f08c991be3e9a975e011fb81..b9400dd8d8d63431982f83a2d5d6f0b75b9a5de2 100644 (file)
@@ -283,7 +283,7 @@ LadspaPlugin::set_parameter (uint32_t which, float val)
        if (which < _descriptor->PortCount) {
                _shadow_data[which] = (LADSPA_Data) val;
 
-#if 0          
+#if 0
                if (which < parameter_count() && controls[which]) {
                        controls[which]->Changed ();
                }
@@ -544,20 +544,28 @@ LadspaPlugin::connect_and_run (BufferSet& bufs,
                pframes_t nframes, framecnt_t offset)
 {
        Plugin::connect_and_run (bufs, in_map, out_map, nframes, offset);
-       
+
        cycles_t now;
        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));
+
        uint32_t audio_in_index  = 0;
        uint32_t audio_out_index = 0;
+       bool valid;
        for (uint32_t port_index = 0; port_index < parameter_count(); ++port_index) {
                if (LADSPA_IS_PORT_AUDIO(port_descriptor(port_index))) {
                        if (LADSPA_IS_PORT_INPUT(port_descriptor(port_index))) {
-                               const uint32_t buf_index = in_map.get(DataType::AUDIO, audio_in_index++);
-                               connect_port(port_index, bufs.get_audio(buf_index).data(offset));
+                               const uint32_t buf_index = in_map.get(DataType::AUDIO, audio_in_index++, &valid);
+                               connect_port(port_index,
+                                            valid ? bufs.get_audio(buf_index).data(offset)
+                                                  : silent_bufs.get_audio(0).data(offset));
                        } else if (LADSPA_IS_PORT_OUTPUT(port_descriptor(port_index))) {
-                               const uint32_t buf_index = out_map.get(DataType::AUDIO, audio_out_index++);
-                               connect_port(port_index, bufs.get_audio(buf_index).data(offset));
+                               const uint32_t buf_index = out_map.get(DataType::AUDIO, audio_out_index++, &valid);
+                               connect_port(port_index,
+                                            valid ? bufs.get_audio(buf_index).data(offset)
+                                                  : scratch_bufs.get_audio(0).data(offset));
                        }
                }
        }
@@ -605,6 +613,28 @@ LadspaPlugin::print_parameter (uint32_t param, char *buf, uint32_t len) const
        }
 }
 
+boost::shared_ptr<Plugin::ScalePoints>
+LadspaPlugin::get_scale_points(uint32_t port_index) const
+{
+       const uint32_t id     = atol(unique_id().c_str());
+       lrdf_defaults* points = lrdf_get_scale_values(id, port_index);
+
+       boost::shared_ptr<Plugin::ScalePoints> ret;
+       if (!points) {
+               return ret;
+       }
+
+       ret = boost::shared_ptr<Plugin::ScalePoints>(new ScalePoints());
+
+       for (uint32_t i = 0; i < points->count; ++i) {
+               ret->insert(make_pair(points->items[i].label,
+                                     points->items[i].value));
+       }
+
+       lrdf_free_setting_values(points);
+       return ret;
+}
+
 void
 LadspaPlugin::run_in_place (pframes_t nframes)
 {
@@ -615,7 +645,7 @@ LadspaPlugin::run_in_place (pframes_t nframes)
        }
 
        assert (_was_activated);
-       
+
        _descriptor->run (_handle, nframes);
 }
 
@@ -739,14 +769,14 @@ LadspaPlugin::load_preset (PresetRecord r)
 
 /* XXX: should be in liblrdf */
 static void
-lrdf_remove_preset (const char *source, const char *setting_uri)
+lrdf_remove_preset (const char* /*source*/, const char *setting_uri)
 {
        lrdf_statement p;
        lrdf_statement *q;
        lrdf_statement *i;
        char setting_uri_copy[64];
        char buf[64];
-       
+
        strncpy(setting_uri_copy, setting_uri, sizeof(setting_uri_copy));
 
        p.subject = setting_uri_copy;
@@ -789,7 +819,7 @@ LadspaPlugin::do_remove_preset (string name)
        if (!p) {
                return;
        }
-       
+
        string const source = preset_source (envvar);
        lrdf_remove_preset (source.c_str(), p->uri.c_str ());
 
@@ -803,7 +833,7 @@ LadspaPlugin::preset_envvar () const
        if ((envvar = getenv ("HOME")) == 0) {
                return "";
        }
-       
+
        return envvar;
 }
 
@@ -848,7 +878,7 @@ LadspaPlugin::do_save_preset (string name)
                        input_parameter_pids.push_back (i);
                }
        }
-       
+
        std::string unique (unique_id());
 
        if (!isdigit (unique[0])) {