Remove unused per-port buffer offset
[ardour.git] / libs / ardour / io.cc
index 90db95ad5948b8265d597cc275af131743e9678d..7eb85477d705a122f814afabfe5dd6ac0af21103 100644 (file)
@@ -130,18 +130,6 @@ IO::disconnect_check (boost::shared_ptr<Port> a, boost::shared_ptr<Port> b)
        }
 }
 
-void
-IO::increment_port_buffer_offset (pframes_t offset)
-{
-       /* io_lock, not taken: function must be called from Session::process() calltree */
-
-       if (_direction == Output) {
-               for (PortSet::iterator i = _ports.begin(); i != _ports.end(); ++i) {
-                       i->increment_port_buffer_offset (offset);
-               }
-       }
-}
-
 void
 IO::silence (samplecnt_t nframes)
 {
@@ -498,11 +486,11 @@ IO::ensure_io (ChanCount count, bool clear, void* src)
 XMLNode&
 IO::get_state ()
 {
-       return state (true);
+       return state ();
 }
 
 XMLNode&
-IO::state (bool /*full_state*/)
+IO::state ()
 {
        XMLNode* node = new XMLNode (state_node_name);
        int n;
@@ -1219,14 +1207,12 @@ IO::apply_pretty_name ()
 samplecnt_t
 IO::latency () const
 {
-       samplecnt_t max_latency;
-       samplecnt_t latency;
-
-       max_latency = 0;
+       samplecnt_t max_latency = 0;
 
        /* io lock not taken - must be protected by other means */
 
        for (PortSet::const_iterator i = _ports.begin(); i != _ports.end(); ++i) {
+               samplecnt_t latency;
                if ((latency = i->private_latency_range (_direction == Output).max) > max_latency) {
                        DEBUG_TRACE (DEBUG::Latency, string_compose ("port %1 has %2 latency of %3 - use\n",
                                                                     name(),
@@ -1242,6 +1228,61 @@ IO::latency () const
        return max_latency;
 }
 
+samplecnt_t
+IO::public_latency () const
+{
+       samplecnt_t max_latency = 0;
+
+       /* io lock not taken - must be protected by other means */
+
+       for (PortSet::const_iterator i = _ports.begin(); i != _ports.end(); ++i) {
+               samplecnt_t latency;
+               if ((latency = i->public_latency_range (_direction == Output).max) > max_latency) {
+                       DEBUG_TRACE (DEBUG::Latency, string_compose ("port %1 has %2 latency of %3 - use\n",
+                                                                    name(),
+                                                                    ((_direction == Output) ? "PLAYBACK" : "CAPTURE"),
+                                                                    latency));
+                       max_latency = latency;
+               }
+       }
+
+       DEBUG_TRACE (DEBUG::Latency, string_compose ("%1: max %4 public latency from %2 ports = %3\n",
+                                                    name(), _ports.num_ports(), max_latency,
+                                                    ((_direction == Output) ? "PLAYBACK" : "CAPTURE")));
+       return max_latency;
+}
+
+samplecnt_t
+IO::connected_latency (bool for_playback) const
+{
+       /* io lock not taken - must be protected by other means */
+       samplecnt_t max_latency = 0;
+       bool connected = false;
+
+       /* if output is not connected to anything, use private latency */
+       for (PortSet::const_iterator i = _ports.begin(); i != _ports.end(); ++i) {
+               if (i->connected()) {
+                       connected = true;
+                       max_latency = 0;
+                       break;
+               }
+               samplecnt_t latency;
+               if ((latency = i->private_latency_range (for_playback).max) > max_latency) {
+                       max_latency = latency;
+               }
+       }
+       if (connected) {
+               for (PortSet::const_iterator i = _ports.begin(); i != _ports.end(); ++i) {
+                       LatencyRange lr;
+                       i->get_connected_latency_range (lr, for_playback);
+                       if (lr.max > max_latency) {
+                               max_latency = lr.max;
+                       }
+               }
+       }
+       return max_latency;
+}
+
 int
 IO::connect_ports_to_bundle (boost::shared_ptr<Bundle> c, bool exclusive, void* src) {
        return connect_ports_to_bundle(c, exclusive, false, src);
@@ -1600,25 +1641,6 @@ IO::connected_to (const string& str) const
        return false;
 }
 
-/** Call a processor's ::run() method, giving it our buffers
- *  Caller must hold process lock.
- */
-void
-IO::process_input (boost::shared_ptr<Processor> proc, samplepos_t start_sample, samplepos_t end_sample, double speed, pframes_t nframes)
-{
-       /* don't read the data into new buffers - just use the port buffers directly */
-
-       if (n_ports().n_total() == 0) {
-               /* We have no ports, so nothing to process */
-               return;
-       }
-
-       _buffers.get_backend_port_addresses (_ports, nframes);
-       if (proc) {
-               proc->run (_buffers, start_sample, end_sample, speed, nframes, true);
-       }
-}
-
 void
 IO::collect_input (BufferSet& bufs, pframes_t nframes, ChanCount offset)
 {