summaryrefslogtreecommitdiff
path: root/libs/ardour/port_insert.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2010-08-16 19:58:34 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2010-08-16 19:58:34 +0000
commita4d9d09af5853f769e1143c2353806bfb7d89f58 (patch)
tree05dc35268557395124f130ec8b6d8e32c6e49b7b /libs/ardour/port_insert.cc
parent0b2f156c5850fb1c60aae25df4b9767bd7f92b89 (diff)
forward port 2.X changes up to and including rev 6714
git-svn-id: svn://localhost/ardour2/branches/3.0@7635 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/port_insert.cc')
-rw-r--r--libs/ardour/port_insert.cc33
1 files changed, 33 insertions, 0 deletions
diff --git a/libs/ardour/port_insert.cc b/libs/ardour/port_insert.cc
index 7a484e2e67..087d2577ad 100644
--- a/libs/ardour/port_insert.cc
+++ b/libs/ardour/port_insert.cc
@@ -83,6 +83,23 @@ PortInsert::set_measured_latency (nframes_t n)
_measured_latency = n;
}
+nframes_t
+PortInsert::latency() const
+{
+ /* because we deliver and collect within the same cycle,
+ all I/O is necessarily delayed by at least frames_per_cycle().
+
+ if the return port for insert has its own latency, we
+ need to take that into account too.
+ */
+
+ if (_measured_latency == 0) {
+ return _session.engine().frames_per_cycle() + _input->latency();
+ } else {
+ return _measured_latency;
+ }
+}
+
void
PortInsert::run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nframes_t nframes, bool)
{
@@ -149,6 +166,10 @@ PortInsert::state (bool full)
node.add_property ("type", "port");
snprintf (buf, sizeof (buf), "%" PRIu32, bitslot);
node.add_property ("bitslot", buf);
+ snprintf (buf, sizeof (buf), "%u", _measured_latency);
+ node.add_property("latency", buf);
+ snprintf (buf, sizeof (buf), "%u", _session.get_block_size());
+ node.add_property("block_size", buf);
return node;
}
@@ -183,6 +204,18 @@ PortInsert::set_state (const XMLNode& node, int version)
return -1;
}
+ uint32_t blocksize = 0;
+ if ((prop = node.property ("block_size")) != 0) {
+ sscanf (prop->value().c_str(), "%u", &blocksize);
+ }
+
+ //if the jack period is the same as when the value was saved, we can recall our latency..
+ if ( (_session.get_block_size() == blocksize) && (prop = node.property ("latency")) != 0) {
+ uint32_t latency = 0;
+ sscanf (prop->value().c_str(), "%u", &latency);
+ _measured_latency = latency;
+ }
+
if ((prop = node.property ("bitslot")) == 0) {
bitslot = _session.next_insert_id();
} else {