From 96dcffcb222bc920cef9bfbaffb0548138352d65 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 21 Oct 2011 04:51:04 +0000 Subject: More robust plugin I/O mapping. This does not change the actual mapping logic, but makes the application of the mapping much more robust. If there is no valid mapping for a given port, that port is connected to silence (instead of crashing messily and/or via a failed assertion). Also tolerate mappings that nonsensically map to a buffer that is not present (this particularly happens for MIDI ports in some cases) as a temporary fix. The mapping logic needs work and/or our concept of just how much MIDI we support in a route needs simplification... git-svn-id: svn://localhost/ardour2/branches/3.0@10262 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/ladspa_plugin.cc | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'libs/ardour/ladspa_plugin.cc') diff --git a/libs/ardour/ladspa_plugin.cc b/libs/ardour/ladspa_plugin.cc index ef1a6b6682..b9400dd8d8 100644 --- a/libs/ardour/ladspa_plugin.cc +++ b/libs/ardour/ladspa_plugin.cc @@ -548,16 +548,24 @@ LadspaPlugin::connect_and_run (BufferSet& bufs, 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)); } } } -- cgit v1.2.3