From fbc8504f9eb74d5e96799fa816015b147f689328 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 13 Sep 2016 13:40:02 -0500 Subject: [PATCH] Delivery::run() now offsets data delivered to MIDI ports by the global port offset if the output is then re-used, MIDI data is readjusted to not use the global port offset --- libs/ardour/delivery.cc | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/libs/ardour/delivery.cc b/libs/ardour/delivery.cc index 9f5051704f..bc49c9be69 100644 --- a/libs/ardour/delivery.cc +++ b/libs/ardour/delivery.cc @@ -307,23 +307,41 @@ Delivery::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, do } else { - // Do a 1:1 copy of data to output ports + /* Do a 1:1 copy of data to output ports + + Audio is handled separately because we use 0 for the offset, + since the port offset is only used for timestamped events + (i.e. MIDI). + */ - // audio is handled separately because we use 0 for the offset - // XXX how does this interact with Port::increment_global_port_buffer_offset ? if (bufs.count().n_audio() > 0) { _output->copy_to_outputs (bufs, DataType::AUDIO, nframes, 0); } for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) { if (*t != DataType::AUDIO && bufs.count().get(*t) > 0) { - _output->copy_to_outputs (bufs, *t, nframes, ports.port(0)->port_offset()); + _output->copy_to_outputs (bufs, *t, nframes, Port::port_offset()); } } } if (result_required) { - bufs.read_from (output_buffers (), nframes); + + /* "bufs" are internal, meaning they should never reflect + split-cycle offsets. So shift events back in time from where + they were for the external buffers associated with Ports. + */ + + BufferSet& outs (output_buffers()); + + for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) { + + uint32_t n = 0; + + for (BufferSet::iterator b = bufs.begin (*t); b != bufs.end (*t); ++b) { + b->read_from (outs.get (*t, n++), nframes, (*t == DataType::AUDIO ? 0 : -Port::port_offset())); + } + } } out: