update internal-send port-count when target port-count changes
[ardour.git] / libs / ardour / internal_send.cc
index 8136985e1f678273536c2d8e51b4a71fa5a791b3..dac1839a5ea07a89bfc2a0907a75be81281c800e 100644 (file)
@@ -95,11 +95,21 @@ InternalSend::use_target (boost::shared_ptr<Route> sendto)
         target_connections.drop_connections ();
 
         _send_to->DropReferences.connect_same_thread (target_connections, boost::bind (&InternalSend::send_to_going_away, this));
-        _send_to->PropertyChanged.connect_same_thread (target_connections, boost::bind (&InternalSend::send_to_property_changed, this, _1));;
+        _send_to->PropertyChanged.connect_same_thread (target_connections, boost::bind (&InternalSend::send_to_property_changed, this, _1));
+        _send_to->io_changed.connect_same_thread (target_connections, boost::bind (&InternalSend::target_io_changed, this));
 
         return 0;
 }
 
+void
+InternalSend::target_io_changed ()
+{
+       assert (_send_to);
+       mixbufs.ensure_buffers (_send_to->internal_return()->input_streams(), _session.get_block_size());
+       mixbufs.set_count (_send_to->internal_return()->input_streams());
+       reset_panner();
+}
+
 void
 InternalSend::send_to_going_away ()
 {
@@ -128,7 +138,19 @@ InternalSend::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame
                        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);
+                       /* 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.