+ assert (_output);
+
+ PortSet& ports (_output->ports());
+ gain_t tgain;
+
+ if (_output->n_ports ().get (_output->default_type()) == 0) {
+ goto out;
+ }
+
+ if (!_active && !_pending_active) {
+ _output->silence (nframes);
+ goto out;
+ }
+
+ /* this setup is not just for our purposes, but for anything that comes after us in the
+ processing pathway that wants to use this->output_buffers() for some reason.
+ */
+
+ output_buffers().get_jack_port_addresses (ports, nframes);
+
+ // this Delivery processor is not a derived type, and thus we assume
+ // we really can modify the buffers passed in (it is almost certainly
+ // the main output stage of a Route). Contrast with Send::run()
+ // which cannot do this.
+
+ tgain = target_gain ();
+
+ if (tgain != _current_gain) {
+ /* target gain has changed */
+
+ Amp::apply_gain (bufs, nframes, _current_gain, tgain);
+ _current_gain = tgain;
+
+ } else if (tgain == 0.0) {
+
+ /* we were quiet last time, and we're still supposed to be quiet.
+ Silence the outputs, and make sure the buffers are quiet too,
+ */
+
+ _output->silence (nframes);
+ if (result_required) {
+ bufs.set_count (output_buffers().count ());
+ Amp::apply_simple_gain (bufs, nframes, 0.0);
+ }
+ goto out;
+
+ } else if (tgain != 1.0) {
+
+ /* target gain has not changed, but is not unity */
+ Amp::apply_simple_gain (bufs, nframes, tgain);
+ }
+
+ if (_panshell && !_panshell->bypassed() && _panshell->panner()) {
+
+ // Use the panner to distribute audio to output port buffers
+
+ _panshell->run (bufs, output_buffers(), start_frame, end_frame, nframes);
+
+ // MIDI 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, 0);
+ }
+
+ } else {
+
+ // Do a 1:1 copy of data to output ports
+
+ if (bufs.count().n_audio() > 0 && ports.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, 0);
+ }