enough with umpteen "i18n.h" files. Consolidate on pbd/i18n.h
[ardour.git] / libs / ardour / io_processor.cc
index 12ab63483c33ffb8fb103cb7b7f18a291caefeea..61bb97f0ad82a392721a4c6100dc562a697a6af6 100644 (file)
 
 */
 
-#include <fstream>
-#include <algorithm>
+#include <list>
 #include <string>
-#include <cerrno>
-#include <unistd.h>
-#include <sstream>
-
 
 #include "pbd/xml++.h"
 #include "pbd/enumwriter.h"
 
-#include "ardour/io_processor.h"
-#include "ardour/session.h"
-#include "ardour/utils.h"
-#include "ardour/send.h"
-#include "ardour/port_insert.h"
-#include "ardour/plugin_insert.h"
+#include "ardour/chan_count.h"
+#include "ardour/data_type.h"
 #include "ardour/io.h"
+#include "ardour/io_processor.h"
+#include "ardour/processor.h"
 #include "ardour/route.h"
+#include "ardour/session_object.h"
+#include "ardour/types.h"
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 using namespace std;
 using namespace ARDOUR;
 using namespace PBD;
 
+namespace ARDOUR { class Session; }
+
 /* create an IOProcessor that proxies to a new IO object */
 
 IOProcessor::IOProcessor (Session& s, bool with_input, bool with_output,
-                         const string& proc_name, const string io_name, DataType dtype)
+                         const string& proc_name, const string io_name, DataType dtype, bool sendish)
        : Processor(s, proc_name)
 {
        /* these are true in this constructor whether we actually create the associated
@@ -57,11 +54,11 @@ IOProcessor::IOProcessor (Session& s, bool with_input, bool with_output,
        _own_output = true;
 
        if (with_input) {
-               _input.reset (new IO(s, io_name.empty() ? proc_name : io_name, IO::Input, dtype));
+               _input.reset (new IO(s, io_name.empty() ? proc_name : io_name, IO::Input, dtype, sendish));
        }
 
        if (with_output) {
-               _output.reset (new IO(s, io_name.empty() ? proc_name : io_name, IO::Output, dtype));
+               _output.reset (new IO(s, io_name.empty() ? proc_name : io_name, IO::Output, dtype, sendish));
        }
 }
 
@@ -150,11 +147,12 @@ IOProcessor::set_state (const XMLNode& node, int version)
                return set_state_2X (node, version);
        }
 
-       const XMLProperty *prop;
+       XMLProperty const * prop;
        const XMLNode *io_node = 0;
 
        Processor::set_state(node, version);
 
+
        if ((prop = node.property ("own-input")) != 0) {
                _own_input = string_is_affirmative (prop->value());
        }
@@ -169,10 +167,10 @@ IOProcessor::set_state (const XMLNode& node, int version)
        XMLNodeIterator niter;
        const string instr = enum_2_string (IO::Input);
        const string outstr = enum_2_string (IO::Output);
-       
-       if (_own_input) {
+
+       if (_own_input && _input) {
                for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
-                       const XMLProperty* prop;
+                       XMLProperty const * prop;
                        if ((prop = (*niter)->property ("name")) != 0) {
                                if (_name == prop->value()) {
                                        if ((prop = (*niter)->property ("direction")) != 0) {
@@ -184,25 +182,25 @@ IOProcessor::set_state (const XMLNode& node, int version)
                                }
                        }
                }
-               
+
                if (io_node) {
                        _input->set_state(*io_node, version);
-                       
+
                        // legacy sessions: use IO name
                        if ((prop = node.property ("name")) == 0) {
                                set_name (_input->name());
                        }
-                       
+
                } else {
                        /* no input, which is OK */
                }
-               
+
        }
-       
-       if (_own_output) {
+
+       if (_own_output && _output) {
                for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
                        if ((*niter)->name() == "IO") {
-                               const XMLProperty* prop;
+                               XMLProperty const * prop;
                                if ((prop = (*niter)->property ("name")) != 0) {
                                        if (_name == prop->value()) {
                                                if ((prop = (*niter)->property ("direction")) != 0) {
@@ -215,10 +213,10 @@ IOProcessor::set_state (const XMLNode& node, int version)
                                }
                        }
                }
-               
+
                if (io_node) {
                        _output->set_state(*io_node, version);
-                       
+
                        // legacy sessions: use IO name
                        if ((prop = node.property ("name")) == 0) {
                                set_name (_output->name());
@@ -242,7 +240,7 @@ IOProcessor::set_state_2X (const XMLNode& node, int version)
 }
 
 void
-IOProcessor::silence (framecnt_t nframes)
+IOProcessor::silence (framecnt_t nframes, framepos_t /* start_frame */)
 {
        if (_own_output && _output) {
                _output->silence (nframes);
@@ -302,3 +300,21 @@ IOProcessor::disconnect ()
                _output->disconnect (this);
        }
 }
+
+/** Set up the XML description of a send so that we will not
+ *  reset its name or bitslot during ::set_state()
+ *  @param state XML send state.
+ *  @param session Session.
+ */
+void
+IOProcessor::prepare_for_reset (XMLNode &state, const std::string& name)
+{
+       state.add_property ("ignore-bitslot", "1");
+       state.add_property ("ignore-name", "1");
+
+       XMLNode* io_node = state.child (IO::state_node_name.c_str());
+
+       if (io_node) {
+               IO::prepare_for_reset (*io_node, name);
+       }
+}