editor toggle button fix from lincoln; refresh location display when loop range chang...
[ardour.git] / libs / ardour / io_processor.cc
index 7e0d4a771cb04a739040e09d7f2cf6b700d65f25..87d679bbacd231f9e8a2daa9a3379fe8a4ea543e 100644 (file)
@@ -74,8 +74,17 @@ IOProcessor::IOProcessor (Session& s, boost::shared_ptr<IO> in, boost::shared_pt
        , _input (in)
        , _output (out)
 {
-       _own_input = false;
-       _own_output = false;
+       if (in) {
+               _own_input = false;
+       } else {
+               _own_input = true;
+       }
+
+       if (out) {
+               _own_output = false;
+       } else {
+               _own_output = true;
+       }
 }
 
 IOProcessor::~IOProcessor ()
@@ -107,10 +116,12 @@ IOProcessor::state (bool full_state)
        XMLNode& node (Processor::state (full_state));
        
        if (_own_input) {
-               XMLNode& i (_input->state (full_state));
-               // i.name() = X_("output");
-               node.add_child_nocopy (i);
                node.add_property ("own-input", "yes");
+               if (_input) {
+                       XMLNode& i (_input->state (full_state));
+                       // i.name() = X_("output");
+                       node.add_child_nocopy (i);
+               }
        } else {
                node.add_property ("own-input", "no");
                if (_input) {
@@ -119,10 +130,12 @@ IOProcessor::state (bool full_state)
        }
        
        if (_own_output) {
-               XMLNode& o (_output->state (full_state));
-               // o.name() = X_("output");
-               node.add_child_nocopy (o);
                node.add_property ("own-output", "yes");
+               if (_output) {
+                       XMLNode& o (_output->state (full_state));
+                       // o.name() = X_("output");
+                       node.add_child_nocopy (o);
+               }
        } else {
                node.add_property ("own-output", "no");
                if (_output) {
@@ -149,8 +162,6 @@ IOProcessor::set_state (const XMLNode& node)
                _own_output = (prop->value() == "yes");
        }
 
-       cerr << _name << " own input = " << _own_input << " output = " << _own_output << endl;
-       
        /* don't attempt to set state for a proxied IO that we don't own */
 
        XMLNodeList nlist = node.children();
@@ -173,9 +184,9 @@ IOProcessor::set_state (const XMLNode& node)
                        }
                        
                } else {
-                       error << _("XML node describing an IOProcessor is missing an IO node") << endmsg;
-                       return -1;
+                       /* no input */
                }
+
        }
        
        if (_own_output) {
@@ -193,7 +204,9 @@ IOProcessor::set_state (const XMLNode& node)
                        if ((prop = node.property ("name")) == 0) {
                                set_name (_output->name());
                        }
-               } 
+               } else {
+                       /* no output */
+               }
        }
 
        return 0;
@@ -246,3 +259,9 @@ IOProcessor::set_name (const std::string& name)
 
        return ret;
 }
+
+bool
+IOProcessor::feeds (boost::shared_ptr<Route> other) const
+{
+       return _output && _output->connected_to (other->input());
+}