Various tweaks to the bundle manager.
[ardour.git] / libs / ardour / port_insert.cc
index 8ff26337715fb0a43f84b509c17e538260c03563..3b02bf41daa6672e1c9ef91720a03763efc8f491 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2000,2007 Paul Davis 
+    Copyright (C) 2000,2007 Paul Davis
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -53,7 +53,7 @@ PortInsert::PortInsert (Session& s, boost::shared_ptr<MuteMaster> mm, const XMLN
        , _out (new Delivery (s, _output, mm, _name, Delivery::Insert))
 
 {
-       if (set_state (node)) {
+       if (set_state (node, Stateful::loading_state_version)) {
                throw failed_constructor();
        }
 
@@ -66,20 +66,23 @@ PortInsert::~PortInsert ()
 }
 
 void
-PortInsert::run_in_place (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nframes_t nframes)
+PortInsert::run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nframes_t nframes)
 {
        if (_output->n_ports().n_total() == 0) {
                return;
        }
 
-       if (!active()) {
+       if (!_active && !_pending_active) {
                /* deliver silence */
                silence (nframes);
-               return;
+               goto out;
        }
 
-       _out->run_in_place (bufs, start_frame, end_frame, nframes);
+       _out->run (bufs, start_frame, end_frame, nframes);
        _input->collect_input (bufs, nframes, ChanCount::ZERO);
+
+  out:
+       _active = _pending_active;
 }
 
 XMLNode&
@@ -101,7 +104,7 @@ PortInsert::state (bool full)
 }
 
 int
-PortInsert::set_state(const XMLNode& node)
+PortInsert::set_state (const XMLNode& node, int version)
 {
        XMLNodeList nlist = node.children();
        XMLNodeIterator niter;
@@ -112,7 +115,7 @@ PortInsert::set_state(const XMLNode& node)
                error << _("XML node describing port insert is missing the `type' field") << endmsg;
                return -1;
        }
-       
+
        if (prop->value() != "port") {
                error << _("non-port insert XML used for port plugin insert") << endmsg;
                return -1;
@@ -134,13 +137,13 @@ PortInsert::set_state(const XMLNode& node)
                        break;
                }
        }
-       
-       Processor::set_state (*insert_node);
+
+       Processor::set_state (*insert_node, version);
 
        return 0;
 }
 
-ARDOUR::nframes_t 
+ARDOUR::nframes_t
 PortInsert::signal_latency() const
 {
        /* because we deliver and collect within the same cycle,