fix gcc4.4 compile warning
[ardour.git] / libs / midi++2 / jack_midiport.cc
index 35e9ade1a3f1cb59b94987079782f4938bdca34e..ba675082a4d496392241ddd7b58433a6a512b889 100644 (file)
@@ -145,8 +145,14 @@ JACK_MidiPort::write(byte * msg, size_t msglen, timestamp_t timestamp)
                }
 
                if (vec.len[0]) {
+                        if (!vec.buf[0]->owns_buffer()) {
+                                vec.buf[0]->set_buffer (0, 0, true);
+                        }
                        vec.buf[0]->set (msg, msglen, timestamp);
                } else {
+                        if (!vec.buf[1]->owns_buffer()) {
+                                vec.buf[1]->set_buffer (0, 0, true);
+                        }
                        vec.buf[1]->set (msg, msglen, timestamp);
                }
 
@@ -293,7 +299,7 @@ JACK_MidiPort::get_state () const
        XMLNode& root (Port::get_state ());
 
        if (_jack_output_port) {
-
+               
                const char** jc = jack_port_get_connections (_jack_output_port);
                string connection_string;
                if (jc) {
@@ -305,10 +311,14 @@ JACK_MidiPort::get_state () const
                        }
                        free (jc);
                }
-
+               
                if (!connection_string.empty()) {
                        root.add_property ("outbound", connection_string);
                }
+       } else {
+               if (!_outbound_connections.empty()) {
+                       root.add_property ("outbound", _outbound_connections);
+               }
        }
 
        if (_jack_input_port) {
@@ -328,6 +338,10 @@ JACK_MidiPort::get_state () const
                if (!connection_string.empty()) {
                        root.add_property ("inbound", connection_string);
                }
+       } else {
+               if (!_inbound_connections.empty()) {
+                       root.add_property ("inbound", _inbound_connections);
+               }
        }
 
        return root;
@@ -339,11 +353,11 @@ JACK_MidiPort::set_state (const XMLNode& node)
        Port::set_state (node);
        const XMLProperty* prop;
 
-       if ((prop = node.property ("outbound")) != 0 && _jack_output_port) {
+       if ((prop = node.property ("inbound")) != 0 && _jack_input_port) {
                _inbound_connections = prop->value ();
        }
 
-       if ((prop = node.property ("inbound")) != 0 && _jack_input_port) {
+       if ((prop = node.property ("outbound")) != 0 && _jack_output_port) {
                _outbound_connections = prop->value();
        }
 }
@@ -356,7 +370,7 @@ JACK_MidiPort::make_connections ()
                split (_inbound_connections, ports, ',');
                for (vector<string>::iterator x = ports.begin(); x != ports.end(); ++x) {
                        if (_jack_client) {
-                               jack_connect (_jack_client, jack_port_name (_jack_output_port), (*x).c_str());
+                               jack_connect (_jack_client, (*x).c_str(), jack_port_name (_jack_input_port));
                                /* ignore failures */
                        }
                }
@@ -367,7 +381,7 @@ JACK_MidiPort::make_connections ()
                split (_outbound_connections, ports, ',');
                for (vector<string>::iterator x = ports.begin(); x != ports.end(); ++x) {
                        if (_jack_client) {
-                               jack_connect (_jack_client, (*x).c_str(), jack_port_name (_jack_input_port));
+                               jack_connect (_jack_client, jack_port_name (_jack_output_port), (*x).c_str());
                                /* ignore failures */
                        }
                }