From db24dda7a2d732c2b87dd4c6ef6d5d21a4dcac5a Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 20 Nov 2011 16:36:04 +0000 Subject: [PATCH] Fill extra channels if monitor sends have more outputs than inputs (#4468). git-svn-id: svn://localhost/ardour2/branches/3.0@10708 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/internal_send.cc | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/libs/ardour/internal_send.cc b/libs/ardour/internal_send.cc index cfed48e223..4ddd064704 100644 --- a/libs/ardour/internal_send.cc +++ b/libs/ardour/internal_send.cc @@ -119,8 +119,26 @@ InternalSend::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame } else { if (role() == Listen) { /* We're going to the monitor bus, so discard MIDI data */ - assert (mixbufs.available().get (DataType::AUDIO) >= bufs.count().get (DataType::AUDIO)); - mixbufs.read_from (bufs, nframes, DataType::AUDIO); + + uint32_t const bufs_audio = bufs.count().get (DataType::AUDIO); + uint32_t const mixbufs_audio = mixbufs.count().get (DataType::AUDIO); + + 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; + for (uint32_t i = 0; i < mixbufs_audio; ++i) { + mixbufs.get_audio(i).read_from (bufs.get_audio(j), nframes); + ++j; + + if (j == bufs_audio) { + j = 0; + } + } + } else { assert (mixbufs.available() >= bufs.count()); mixbufs.read_from (bufs, nframes);