don't bother to re-seek/locate/refill buffers when disk IO processor config changes...
[ardour.git] / libs / ardour / disk_io.cc
index 587ba19ed05a79c1cfaba85ba02ec9ff9aa85b27..64c645bdc35110e3a5eb01322cd0f9831f1ae7c8 100644 (file)
@@ -136,10 +136,8 @@ DiskIOProcessor::can_support_io_configuration (const ChanCount& in, ChanCount& o
                return false;
        }
 
-       if (in != out) {
-               /* currently no way to deliver different channels that we receive */
-               return false;
-       }
+       /* currently no way to deliver different channels that we receive */
+       out = in;
 
        return true;
 }
@@ -153,20 +151,26 @@ DiskIOProcessor::configure_io (ChanCount in, ChanCount out)
        boost::shared_ptr<ChannelList> c = writer.get_copy();
 
        uint32_t n_audio = in.n_audio();
+       bool changed = false;
 
        if (n_audio > c->size()) {
                add_channel_to (c, n_audio - c->size());
+               changed = true;
        } else if (n_audio < c->size()) {
                remove_channel_from (c, c->size() - n_audio);
+               changed = true;
        }
 
        if (in.n_midi() > 0 && !_midi_buf) {
                const size_t size = _session.butler()->midi_diskstream_buffer_size();
                _midi_buf = new MidiRingBuffer<framepos_t>(size);
                midi_interpolation.add_channel_to (0,0);
+               changed = true;
        }
 
-       seek (_session.transport_frame());
+       if (changed) {
+               seek (_session.transport_frame());
+       }
 
        return Processor::configure_io (in, out);
 }
@@ -332,6 +336,7 @@ DiskIOProcessor::use_playlist (DataType dt, boost::shared_ptr<Playlist> playlist
         DEBUG_TRACE (DEBUG::DiskIO, string_compose ("%1: set to use playlist %2 (%3)\n", name(), playlist->name(), dt.to_string()));
 
         if (playlist == _playlists[dt]) {
+               DEBUG_TRACE (DEBUG::DiskIO, string_compose ("%1: already using that playlist\n", name()));
                return 0;
         }
 
@@ -349,7 +354,7 @@ DiskIOProcessor::use_playlist (DataType dt, boost::shared_ptr<Playlist> playlist
         playlist->DropReferences.connect_same_thread (playlist_connections, boost::bind (&DiskIOProcessor::playlist_deleted, this, boost::weak_ptr<Playlist>(playlist)));
         playlist->RangesMoved.connect_same_thread (playlist_connections, boost::bind (&DiskIOProcessor::playlist_ranges_moved, this, _1, _2));
 
-       DEBUG_TRACE (DEBUG::DiskIO, string_compose ("%1 now use playlist %1 (%2)\n", name(), playlist->name(), playlist->id()));
+       DEBUG_TRACE (DEBUG::DiskIO, string_compose ("%1 now using playlist %1 (%2)\n", name(), playlist->name(), playlist->id()));
 
        PlaylistChanged (dt); /* EMIT SIGNAL */
        _session.set_dirty ();
@@ -388,10 +393,20 @@ DiskIOProcessor::ChannelInfo::~ChannelInfo ()
        capture_transition_buf = 0;
 }
 
+void
+DiskIOProcessor::drop_route ()
+{
+       _route.reset ();
+}
+
 void
 DiskIOProcessor::set_route (boost::shared_ptr<Route> r)
 {
        _route = r;
+
+       if (_route) {
+               _route->DropReferences.connect_same_thread (*this, boost::bind (&DiskIOProcessor::drop_route, this));
+       }
 }
 
 /** Get the start, end, and length of a location "atomically".