From a4d9d09af5853f769e1143c2353806bfb7d89f58 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 16 Aug 2010 19:58:34 +0000 Subject: 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 --- libs/ardour/port_insert.cc | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'libs/ardour/port_insert.cc') 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 { -- cgit v1.2.3