+ if (_panshell && !_panshell->bypassed() && role() != Listen) {
+ if (mixbufs.count ().n_audio () > 0) {
+ _panshell->run (bufs, mixbufs, start_sample, end_sample, nframes);
+ }
+
+ /* non-audio data will not have been copied by the panner, do it now
+ * if there are more buffers available than send buffers, ignore them,
+ * if there are less, copy the last as IO::copy_to_output does. */
+
+ for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) {
+ if (*t != DataType::AUDIO) {
+ BufferSet::iterator o = mixbufs.begin(*t);
+ BufferSet::iterator i = bufs.begin(*t);
+
+ while (i != bufs.end(*t) && o != mixbufs.end(*t)) {
+ o->read_from (*i, nframes);
+ ++i;
+ ++o;
+ }
+ while (o != mixbufs.end(*t)) {
+ o->silence(nframes, 0);
+ ++o;
+ }
+ }
+ }
+ } else {
+ if (role() == Listen) {
+ /* We're going to the monitor bus, so discard MIDI data */
+
+ uint32_t const bufs_audio = bufs.count().get (DataType::AUDIO);
+ uint32_t const mixbufs_audio = mixbufs.count().get (DataType::AUDIO);
+
+ /* monitor-section has same number of channels as master-bus (on creation).
+ *
+ * There is no clear answer what should happen when trying to PFL or AFL
+ * a track that has more channels (bufs_audio from source-track is
+ * larger than mixbufs).
+ *
+ * There are two options:
+ * 1: discard additional channels (current)
+ * OR
+ * 2: require the monitor-section to have at least as many channels
+ * as the largest count of any route
+ */
+ //assert (mixbufs.available().get (DataType::AUDIO) >= bufs_audio);
+
+ /* Copy bufs into mixbufs, going round bufs more than once if necessary
+ to ensure that every mixbuf gets some data.
+ */
+
+ uint32_t j = 0;
+ uint32_t i = 0;
+ for (i = 0; i < mixbufs_audio && j < bufs_audio; ++i) {
+ mixbufs.get_audio(i).read_from (bufs.get_audio(j), nframes);
+ ++j;
+
+ if (j == bufs_audio) {
+ j = 0;
+ }
+ }
+ /* in case or MIDI track with 0 audio channels */
+ for (; i < mixbufs_audio; ++i) {
+ mixbufs.get_audio(i).silence (nframes);
+ }
+
+ } else {
+ assert (mixbufs.available() >= bufs.count());
+ mixbufs.read_from (bufs, nframes);
+ }
+ }