From 4949f9a0b3f64a7a37fb6f45aa1cc5ade8542d0a Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Thu, 5 Sep 2019 16:57:19 +0200 Subject: [PATCH] Reset write-source only when necessary When I/O port-counts do not change, plugin re-order happens in sync in the process-thread. ::configure_io() is only called to ensure that the current configuration is valid. In case that the ChanCount does not change, the method must be realtime-safe and not block. DiskWriter::reset_write_sources() is not realtime-safe and implicitly causes a session-save: Write-sources are destroyed and re-created. This includes a call to write_source->drop_references(), which triggers ARDOUR::Session::remove_source(), which saves the session. Furthermore adding/removing plugins will likewise call ::configure_io(). Previously any processor change on a track lead to saving the session! --- libs/ardour/disk_writer.cc | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/libs/ardour/disk_writer.cc b/libs/ardour/disk_writer.cc index d93f8680bf..d9bf2fac1e 100644 --- a/libs/ardour/disk_writer.cc +++ b/libs/ardour/disk_writer.cc @@ -1497,11 +1497,25 @@ DiskWriter::steal_write_source_name () bool DiskWriter::configure_io (ChanCount in, ChanCount out) { + bool changed = false; + { + boost::shared_ptr c = channels.reader(); + if (in.n_audio() != c->size()) { + changed = true; + } + if ((0 == in.n_midi ()) != (0 == _midi_buf)) { + changed = true; + } + } + + if (!DiskIOProcessor::configure_io (in, out)) { return false; } - reset_write_sources (false, true); + if (record_enabled() || changed) { + reset_write_sources (false, true); + } return true; }