Make Delivery::run more Datatype-agnostic
authorJulien "_FrnchFrgg_" RIVAUD <frnchfrgg@free.fr>
Fri, 8 Jul 2016 23:07:16 +0000 (01:07 +0200)
committerJulien "_FrnchFrgg_" RIVAUD <frnchfrgg@free.fr>
Fri, 8 Jul 2016 23:21:27 +0000 (01:21 +0200)
Note that checking the number of output ports is not needed because
IO::copy_to_outputs() will stop if there are less ports of the right
type than buffers (or even none).

libs/ardour/delivery.cc

index 565a6740fd193e8b862f9a9990b70a9cc4f26971..89719e42595eb76a6e1779c4c8ecbc21f9bf5bfd 100644 (file)
@@ -297,22 +297,28 @@ Delivery::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, do
 
                _panshell->run (bufs, output_buffers(), start_frame, end_frame, nframes);
 
-               // MIDI data will not have been delivered by the panner
+               // non-audio data will not have been delivered by the panner
 
-               if (bufs.count().n_midi() > 0 && ports.count().n_midi () > 0) {
-                       _output->copy_to_outputs (bufs, DataType::MIDI, nframes, ports.port(0)->port_offset());
+               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());
+                       }
                }
 
        } else {
 
                // Do a 1:1 copy of data to output ports
 
-               if (bufs.count().n_audio() > 0 && ports.count().n_audio () > 0) {
+               // 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);
                }
 
-               if (bufs.count().n_midi() > 0 && ports.count().n_midi () > 0) {
-                       _output->copy_to_outputs (bufs, DataType::MIDI, nframes, ports.port(0)->port_offset());
+               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());
+                       }
                }
        }