Merge branch 'master' into saveas
[ardour.git] / libs / ardour / io.cc
index a9d37d4315cc9c6ad8930b416c965c9d1edc2913..69f7c9053ee4c6ffe6db10f10d32435709584eb6 100644 (file)
@@ -527,7 +527,7 @@ IO::state (bool /*full_state*/)
        string str;
        vector<string>::iterator ci;
        int n;
-       LocaleGuard lg (X_("POSIX"));
+       LocaleGuard lg (X_("C"));
        Glib::Threads::Mutex::Lock lm (io_lock);
 
        node->add_property("name", _name);
@@ -588,7 +588,7 @@ IO::set_state (const XMLNode& node, int version)
 
        const XMLProperty* prop;
        XMLNodeConstIterator iter;
-       LocaleGuard lg (X_("POSIX"));
+       LocaleGuard lg (X_("C"));
 
        /* force use of non-localized representation of decimal point,
           since we use it a lot in XML files and so forth.
@@ -644,7 +644,7 @@ IO::set_state_2X (const XMLNode& node, int version, bool in)
 {
        const XMLProperty* prop;
        XMLNodeConstIterator iter;
-       LocaleGuard lg (X_("POSIX"));
+       LocaleGuard lg (X_("C"));
 
        /* force use of non-localized representation of decimal point,
           since we use it a lot in XML files and so forth.
@@ -854,6 +854,7 @@ IO::get_port_counts (const XMLNode& node, int version, ChanCount& n, boost::shar
        for (iter = node.children().begin(); iter != node.children().end(); ++iter) {
 
                if ((*iter)->name() == X_("Bundle")) {
+                       prop = (*iter)->property ("name");
                        if ((c = find_possible_bundle (prop->value())) != 0) {
                                n = ChanCount::max (n, c->nchannels());
                                return 0;
@@ -1039,7 +1040,8 @@ IO::make_connections_2X (const XMLNode& node, int /*version*/, bool in)
                                        if (p != string::npos) {
                                                ports[x].replace (p, 4, "/audio_out");
                                        }
-                                       nth(i)->connect (ports[x]);
+                                       if (NULL != nth(i).get())
+                                               nth(i)->connect (ports[x]);
                                }
                        }
 
@@ -1081,7 +1083,8 @@ IO::make_connections_2X (const XMLNode& node, int /*version*/, bool in)
                                        if (p != string::npos) {
                                                ports[x].replace (p, 3, "/audio_in");
                                        }
-                                       nth(i)->connect (ports[x]);
+                                       if (NULL != nth(i).get())
+                                               nth(i)->connect (ports[x]);
                                }
                        }
 
@@ -1097,7 +1100,6 @@ int
 IO::set_ports (const string& str)
 {
        vector<string> ports;
-       int i;
        int n;
        uint32_t nports;
 
@@ -1114,14 +1116,10 @@ IO::set_ports (const string& str)
                }
        }
 
-       string::size_type start, end, ostart;
-
-       ostart = 0;
-       start = 0;
-       end = 0;
-       i = 0;
-
-       while ((start = str.find_first_of ('{', ostart)) != string::npos) {
+       string::size_type start  = 0;
+       string::size_type end    = 0;
+       string::size_type ostart = 0;
+       for (int i = 0; (start = str.find_first_of ('{', ostart)) != string::npos; ++i) {
                start += 1;
 
                if ((end = str.find_first_of ('}', start)) == string::npos) {
@@ -1142,7 +1140,6 @@ IO::set_ports (const string& str)
                }
 
                ostart = end+1;
-               i++;
        }
 
        return 0;
@@ -1179,7 +1176,6 @@ IO::parse_gain_string (const string& str, vector<string>& ports)
 {
        string::size_type pos, opos;
 
-       pos = 0;
        opos = 0;
        ports.clear ();
 
@@ -1344,7 +1340,7 @@ IO::bundle_changed (Bundle::Change /*c*/)
 string
 IO::build_legal_port_name (DataType type)
 {
-       const int name_size = jack_port_name_size();
+       const int name_size = AudioEngine::instance()->port_name_size();
        int limit;
        string suffix;
 
@@ -1378,7 +1374,7 @@ IO::build_legal_port_name (DataType type)
 
        // allow up to 4 digits for the output port number, plus the slash, suffix and extra space
 
-       limit = name_size - _session.engine().client_name().length() - (suffix.length() + 5);
+       limit = name_size - AudioEngine::instance()->my_name().length() - (suffix.length() + 5);
 
        std::vector<char> buf1(name_size+1);
        std::vector<char> buf2(name_size+1);
@@ -1411,10 +1407,10 @@ IO::find_port_hole (const char* base)
         */
 
        for (n = 1; n < 9999; ++n) {
-               std::vector<char> buf(jack_port_name_size());
+               std::vector<char> buf (AudioEngine::instance()->port_name_size());
                PortSet::iterator i = _ports.begin();
 
-               snprintf (&buf[0], jack_port_name_size(), _("%s %u"), base, n);
+               snprintf (&buf[0], buf.size()+1, _("%s %u"), base, n);
 
                for ( ; i != _ports.end(); ++i) {
                        if (string(i->name()) == string(&buf[0])) {
@@ -1611,8 +1607,10 @@ IO::connected_to (boost::shared_ptr<const IO> other) const
 
        for (i = 0; i < no; ++i) {
                for (j = 0; j < ni; ++j) {
-                       if (nth(i)->connected_to (other->nth(j)->name())) {
-                               return true;
+                       if ((NULL != nth(i).get()) && (NULL != other->nth(j).get())) {
+                               if (nth(i)->connected_to (other->nth(j)->name())) {
+                                       return true;
+                               }
                        }
                }
        }
@@ -1645,7 +1643,7 @@ IO::process_input (boost::shared_ptr<Processor> proc, framepos_t start_frame, fr
                return;
        }
 
-       _buffers.get_jack_port_addresses (_ports, nframes);
+       _buffers.get_backend_port_addresses (_ports, nframes);
        if (proc) {
                proc->run (_buffers, start_frame, end_frame, nframes, true);
        }