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
This commit is contained in:
Robin Gareus 2012-08-28 15:42:40 +00:00
parent 198efb82bc
commit 322f1c7d0d
2 changed files with 8 additions and 8 deletions

View File

@ -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 ();

View File

@ -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