remove all remaining vestiges of per-track varispeed from libardour
[ardour.git] / libs / ardour / io.cc
index 46c5d7b8c5f434a56a32603525ac56b59be78403..5d1f39f968c3ef87009d686c996be83f7a1a0d56 100644 (file)
@@ -135,11 +135,11 @@ 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);
-                }
-        }
+       if (_direction == Output) {
+               for (PortSet::iterator i = _ports.begin(); i != _ports.end(); ++i) {
+                       i->increment_port_buffer_offset (offset);
+               }
+       }
 }
 
 void
@@ -148,54 +148,12 @@ IO::silence (framecnt_t nframes)
        /* io_lock, not taken: function must be called from Session::process() calltree */
 
        for (PortSet::iterator i = _ports.begin(); i != _ports.end(); ++i) {
-               i->get_buffer(nframes).silence (nframes);
-       }
-}
-
-/** Set _bundles_connected to those bundles that are connected such that every
- *  port on every bundle channel x is connected to port x in _ports.
- */
-void
-IO::check_bundles_connected ()
-{
-       std::vector<UserBundleInfo*> new_list;
-
-       for (std::vector<UserBundleInfo*>::iterator i = _bundles_connected.begin(); i != _bundles_connected.end(); ++i) {
-
-               uint32_t const N = (*i)->bundle->nchannels().n_total();
-
-               if (_ports.num_ports() < N) {
-                       continue;
-               }
-
-               bool ok = true;
-
-               for (uint32_t j = 0; j < N; ++j) {
-                       /* Every port on bundle channel j must be connected to our input j */
-                       Bundle::PortList const pl = (*i)->bundle->channel_ports (j);
-                       for (uint32_t k = 0; k < pl.size(); ++k) {
-                               if (_ports.port(j)->connected_to (pl[k]) == false) {
-                                       ok = false;
-                                       break;
-                               }
-                       }
-
-                       if (ok == false) {
-                               break;
-                       }
-               }
-
-               if (ok) {
-                       new_list.push_back (*i);
-               } else {
-                       delete *i;
+               if (i->port_handle ()) {
+                       i->get_buffer(nframes).silence (nframes);
                }
        }
-
-       _bundles_connected = new_list;
 }
 
-
 int
 IO::disconnect (boost::shared_ptr<Port> our_port, string other_port, void* src)
 {
@@ -203,26 +161,24 @@ IO::disconnect (boost::shared_ptr<Port> our_port, string other_port, void* src)
                return 0;
        }
 
-        {
-                Glib::Threads::Mutex::Lock lm (io_lock);
-
-                /* check that our_port is really one of ours */
+       {
+               Glib::Threads::Mutex::Lock lm (io_lock);
 
-                if ( ! _ports.contains(our_port)) {
-                        return -1;
-                }
+               /* check that our_port is really one of ours */
 
-                /* disconnect it from the source */
+               if ( ! _ports.contains(our_port)) {
+                       return -1;
+               }
 
-                if (our_port->disconnect (other_port)) {
-                        error << string_compose(_("IO: cannot disconnect port %1 from %2"), our_port->name(), other_port) << endmsg;
-                        return -1;
-                }
+               /* disconnect it from the source */
 
-                check_bundles_connected ();
-        }
+               if (our_port->disconnect (other_port)) {
+                       error << string_compose(_("IO: cannot disconnect port %1 from %2"), our_port->name(), other_port) << endmsg;
+                       return -1;
+               }
+       }
 
-        changed (IOChange (IOChange::ConnectionsChanged), src); /* EMIT SIGNAL */
+       changed (IOChange (IOChange::ConnectionsChanged), src); /* EMIT SIGNAL */
 
        _session.set_dirty ();
 
@@ -286,7 +242,6 @@ IO::remove_port (boost::shared_ptr<Port> port, void* src)
                                }
 
                                _session.engine().unregister_port (port);
-                               check_bundles_connected ();
                        }
                }
 
@@ -393,8 +348,6 @@ IO::disconnect (void* src)
                for (PortSet::iterator i = _ports.begin(); i != _ports.end(); ++i) {
                        i->disconnect_all ();
                }
-
-               check_bundles_connected ();
        }
 
        changed (IOChange (IOChange::ConnectionsChanged), src); /* EMIT SIGNAL */
@@ -480,7 +433,6 @@ IO::ensure_ports_locked (ChanCount count, bool clear, bool& changed)
        }
 
        if (changed) {
-               check_bundles_connected ();
                PortCountChanged (n_ports()); /* EMIT SIGNAL */
                _session.set_dirty ();
        }
@@ -565,12 +517,6 @@ IO::state (bool /*full_state*/)
                node->set_property("pretty-name", _pretty_name_prefix);
        }
 
-       for (std::vector<UserBundleInfo*>::iterator i = _bundles_connected.begin(); i != _bundles_connected.end(); ++i) {
-               XMLNode* n = new XMLNode ("Bundle");
-               n->set_property ("name", (*i)->bundle->name ());
-               node->add_child_nocopy (*n);
-       }
-
        for (PortSet::iterator i = _ports.begin(); i != _ports.end(); ++i) {
 
                vector<string> connections;
@@ -728,10 +674,10 @@ IO::connecting_became_legal ()
 
        connection_legal_c.disconnect ();
 
-    // it's not required for TracksLive, as long as TracksLive's session does all the connections when it's being loaded
-    if (!Profile->get_trx() ) {
-        ret = make_connections (*pending_state_node, pending_state_node_version, pending_state_node_in);
-    }
+       // it's not required for TracksLive, as long as TracksLive's session does all the connections when it's being loaded
+       if (!Profile->get_trx() ) {
+               ret = make_connections (*pending_state_node, pending_state_node_version, pending_state_node_in);
+       }
 
        delete pending_state_node;
        pending_state_node = 0;
@@ -980,7 +926,7 @@ IO::make_connections (const XMLNode& node, int version, bool in)
                                        }
 
                                        if (prop) {
-                                                connect (p, prop->value(), this);
+                                               connect (p, prop->value(), this);
                                        }
                                }
                        }
@@ -1282,22 +1228,28 @@ IO::latency () const
 
        for (PortSet::const_iterator i = _ports.begin(); i != _ports.end(); ++i) {
                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(),
-                                                                     ((_direction == Output) ? "PLAYBACK" : "CAPTURE"),
-                                                                     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 latency from %2 ports = %3\n",
-                                                     name(), _ports.num_ports(), max_latency,
-                                                     ((_direction == Output) ? "PLAYBACK" : "CAPTURE")));
+       DEBUG_TRACE (DEBUG::Latency, string_compose ("%1: max %4 latency from %2 ports = %3\n",
+                                                    name(), _ports.num_ports(), max_latency,
+                                                    ((_direction == Output) ? "PLAYBACK" : "CAPTURE")));
        return max_latency;
 }
 
 int
-IO::connect_ports_to_bundle (boost::shared_ptr<Bundle> c, bool exclusive, void* src)
+IO::connect_ports_to_bundle (boost::shared_ptr<Bundle> c, bool exclusive, void* src) {
+       return connect_ports_to_bundle(c, exclusive, false, src);
+}
+
+int
+IO::connect_ports_to_bundle (boost::shared_ptr<Bundle> c, bool exclusive,
+                             bool allow_partial, void* src)
 {
        BLOCK_PROCESS_CALLBACK ();
 
@@ -1310,24 +1262,8 @@ IO::connect_ports_to_bundle (boost::shared_ptr<Bundle> c, bool exclusive, void*
                        }
                }
 
-               c->connect (_bundle, _session.engine());
-
-               /* If this is a UserBundle, make a note of what we've done */
-
-               boost::shared_ptr<UserBundle> ub = boost::dynamic_pointer_cast<UserBundle> (c);
-               if (ub) {
+               c->connect (_bundle, _session.engine(), allow_partial);
 
-                       /* See if we already know about this one */
-                       std::vector<UserBundleInfo*>::iterator i = _bundles_connected.begin();
-                       while (i != _bundles_connected.end() && (*i)->bundle != ub) {
-                               ++i;
-                       }
-
-                       if (i == _bundles_connected.end()) {
-                               /* We don't, so make a note */
-                               _bundles_connected.push_back (new UserBundleInfo (this, ub));
-                       }
-               }
        }
 
        changed (IOChange (IOChange::ConnectionsChanged), src); /* EMIT SIGNAL */
@@ -1346,19 +1282,6 @@ IO::disconnect_ports_from_bundle (boost::shared_ptr<Bundle> c, void* src)
 
                /* If this is a UserBundle, make a note of what we've done */
 
-               boost::shared_ptr<UserBundle> ub = boost::dynamic_pointer_cast<UserBundle> (c);
-               if (ub) {
-
-                       std::vector<UserBundleInfo*>::iterator i = _bundles_connected.begin();
-                       while (i != _bundles_connected.end() && (*i)->bundle != ub) {
-                               ++i;
-                       }
-
-                       if (i != _bundles_connected.end()) {
-                               delete *i;
-                               _bundles_connected.erase (i);
-                       }
-               }
        }
 
        changed (IOChange (IOChange::ConnectionsChanged), src); /* EMIT SIGNAL */
@@ -1495,11 +1418,10 @@ IO::midi(uint32_t n) const
 /**
  *  Setup a bundle that describe our inputs or outputs. Also creates the bundle if necessary.
  */
-
 void
 IO::setup_bundle ()
 {
-        char buf[32];
+       char buf[32];
 
        if (!_bundle) {
                _bundle.reset (new Bundle (_direction == Input));
@@ -1514,7 +1436,7 @@ IO::setup_bundle ()
        } else {
                snprintf(buf, sizeof (buf), _("%s out"), _name.val().c_str());
        }
-        _bundle->set_name (buf);
+       _bundle->set_name (buf);
 
        int c = 0;
        for (DataType::iterator i = DataType::begin(); i != DataType::end(); ++i) {
@@ -1537,11 +1459,6 @@ IO::bundles_connected ()
 {
        BundleList bundles;
 
-       /* User bundles */
-       for (std::vector<UserBundleInfo*>::iterator i = _bundles_connected.begin(); i != _bundles_connected.end(); ++i) {
-               bundles.push_back ((*i)->bundle);
-       }
-
        /* Session bundles */
        boost::shared_ptr<ARDOUR::BundleList> b = _session.bundles ();
        for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
@@ -1634,22 +1551,22 @@ IO::set_name_in_state (XMLNode& node, const string& new_name)
 bool
 IO::connected () const
 {
-        /* do we have any connections at all? */
+       /* do we have any connections at all? */
 
-        for (PortSet::const_iterator p = _ports.begin(); p != _ports.end(); ++p) {
-                if (p->connected()) {
-                        return true;
-                }
-        }
+       for (PortSet::const_iterator p = _ports.begin(); p != _ports.end(); ++p) {
+               if (p->connected()) {
+                       return true;
+               }
+       }
 
-        return false;
+       return false;
 }
 
 bool
 IO::connected_to (boost::shared_ptr<const IO> other) const
 {
        if (!other) {
-                return connected ();
+               return connected ();
        }
 
        assert (_direction != other->direction());
@@ -1777,12 +1694,12 @@ bool
 IO::physically_connected () const
 {
        for (PortSet::const_iterator i = _ports.begin(); i != _ports.end(); ++i) {
-                if (i->physically_connected()) {
-                        return true;
-                }
-        }
+               if (i->physically_connected()) {
+                       return true;
+               }
+       }
 
-        return false;
+       return false;
 }
 
 bool