- for (Plugins::iterator i = _plugins.begin(); i != _plugins.end(); ++i) {
- (*i)->connect_and_run(bufs, in_map, out_map, nframes, offset);
- for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) {
- in_map.offset_to(*t, natural_input_streams().get(*t));
- out_map.offset_to(*t, natural_output_streams().get(*t));
+ if (_no_inplace) {
+ BufferSet& inplace_bufs = _session.get_noinplace_buffers();
+
+ uint32_t pc = 0;
+ for (Plugins::iterator i = _plugins.begin(); i != _plugins.end(); ++i, ++pc) {
+
+ ARDOUR::ChanMapping in_map (natural_input_streams());
+ ARDOUR::ChanMapping out_map;
+ ARDOUR::ChanCount mapped;
+ ARDOUR::ChanCount backmap;
+
+ // map inputs sequentially
+ for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) {
+ for (uint32_t in = 0; in < natural_input_streams().get (*t); ++in) {
+ bool valid;
+ uint32_t in_idx = _in_map[pc].get (*t, in, &valid);
+ uint32_t m = mapped.get (*t);
+ if (valid) {
+ inplace_bufs.get (*t, m).read_from (bufs.get (*t, in_idx), nframes, offset, offset);
+ } else {
+ inplace_bufs.get (*t, m).silence (nframes, offset);
+ }
+ mapped.set (*t, m + 1);
+ }
+ }
+
+ backmap = mapped;
+
+ // map outputs
+ for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) {
+ for (uint32_t out = 0; out < natural_output_streams().get (*t); ++out) {
+ uint32_t m = mapped.get (*t);
+ inplace_bufs.get (*t, m).silence (nframes, offset);
+ out_map.set (*t, out, m);
+ mapped.set (*t, m + 1);
+ }
+ }
+
+ if ((*i)->connect_and_run(inplace_bufs, in_map, out_map, nframes, offset)) {
+ deactivate ();
+ }
+
+ // clear output buffers
+ bufs.silence (nframes, offset);
+
+ // copy back outputs
+ for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) {
+ for (uint32_t out = 0; out < natural_output_streams().get (*t); ++out) {
+ uint32_t m = backmap.get (*t);
+ bool valid;
+ uint32_t out_idx = _out_map[pc].get (*t, out, &valid);
+ if (valid) {
+ bufs.get (*t, out_idx).read_from (inplace_bufs.get (*t, m), nframes, offset, offset);
+ }
+ backmap.set (*t, m + 1);
+ }
+ }
+ }
+
+ } else {
+ uint32_t pc = 0;
+ for (Plugins::iterator i = _plugins.begin(); i != _plugins.end(); ++i, ++pc) {
+ if ((*i)->connect_and_run(bufs, _in_map[pc], _out_map[pc], nframes, offset)) {
+ deactivate ();
+ }