From 322f1c7d0de3825e673cee1819adf22d8302cd19 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 28 Aug 2012 15:42:40 +0000 Subject: [PATCH] LV2: amend previous commit, respect replicated plugin instances When a plugin is replicated (eg. mono plugin on a stereo-track), configure_io() is only called for the first instance. The 2nd instance will not have dedicated buffers but re-use copies of the first instance. Should the 2nd instance use a LV2 worker-thread or local communication ports they can not be shared with the first instance. -> this patch allocates Atom-buffers for each instance. PS. this still needs more work; there is only one UI instance for all plugin instances. messages from the UI should go to all instances. git-svn-id: svn://localhost/ardour2/branches/3.0@13148 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/ardour/lv2_plugin.h | 2 +- libs/ardour/lv2_plugin.cc | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/libs/ardour/ardour/lv2_plugin.h b/libs/ardour/ardour/lv2_plugin.h index 622ab305bd..6b51cb3eae 100644 --- a/libs/ardour/ardour/lv2_plugin.h +++ b/libs/ardour/ardour/lv2_plugin.h @@ -89,7 +89,6 @@ class LV2Plugin : public ARDOUR::Plugin, public ARDOUR::Workee void cleanup (); int set_block_size (pframes_t /*nframes*/) { return 0; } - bool configure_io (ChanCount in, ChanCount out); int connect_and_run (BufferSet& bufs, ChanMapping in, ChanMapping out, @@ -242,6 +241,7 @@ class LV2Plugin : public ARDOUR::Plugin, public ARDOUR::Workee const char* path); void init (const void* c_plugin, framecnt_t rate); + void allocate_atom_event_buffers (); void run (pframes_t nsamples); void latency_compute_run (); diff --git a/libs/ardour/lv2_plugin.cc b/libs/ardour/lv2_plugin.cc index 1bacc70307..14d4b6355c 100644 --- a/libs/ardour/lv2_plugin.cc +++ b/libs/ardour/lv2_plugin.cc @@ -541,6 +541,7 @@ LV2Plugin::init(const void* c_plugin, framecnt_t rate) } } + allocate_atom_event_buffers(); latency_compute_run(); } @@ -1393,8 +1394,8 @@ LV2Plugin::cleanup() _impl->instance = NULL; } -bool -LV2Plugin::configure_io (ChanCount in, ChanCount out) { +void +LV2Plugin::allocate_atom_event_buffers () { /* reserve local scratch buffers for ATOM event-queues */ const LilvPlugin* p = _impl->plugin; @@ -1430,7 +1431,7 @@ LV2Plugin::configure_io (ChanCount in, ChanCount out) { const int total_atom_buffers = (count_atom_in + count_atom_out); if (_atom_ev_buffers || total_atom_buffers == 0) { - return true; + return; } DEBUG_TRACE(DEBUG::LV2, string_compose("allocate %1 atom_ev_buffers\n", total_atom_buffers)); @@ -1440,7 +1441,7 @@ LV2Plugin::configure_io (ChanCount in, ChanCount out) { LV2Plugin::_chunk_type, LV2Plugin::_sequence_type); } _atom_ev_buffers[total_atom_buffers] = 0; - return true; + return; } int @@ -1511,16 +1512,15 @@ LV2Plugin::connect_and_run(BufferSet& bufs, buf = lv2_evbuf_get_buffer(_ev_buffers[port_index]); } } else if (flags & (PORT_ATOM)) { + assert(_atom_ev_buffers && _atom_ev_buffers[atom_port_index]); if (flags & PORT_INPUT) { lv2_evbuf_reset(_atom_ev_buffers[atom_port_index], true); _ev_buffers[port_index] = _atom_ev_buffers[atom_port_index++]; - buf = lv2_evbuf_get_buffer(_ev_buffers[port_index]); } else { lv2_evbuf_reset(_atom_ev_buffers[atom_port_index], false); _ev_buffers[port_index] = _atom_ev_buffers[atom_port_index++]; - buf = lv2_evbuf_get_buffer(_ev_buffers[port_index]); } - assert(_ev_buffers[port_index]); + buf = lv2_evbuf_get_buffer(_ev_buffers[port_index]); assert(buf); } else { continue; // Control port, leave buffer alone