Update backend API: read-only MIDI input buffers
[ardour.git] / libs / backends / jack / jack_portengine.cc
index 257feb2bf2c3f749306eb6c210019dc92b01b4f3..dfa2bdad113313a27bd5ad3f5b9ff79583f52d73 100644 (file)
@@ -27,7 +27,7 @@
 
 #include "ardour/port_manager.h"
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 using namespace ARDOUR;
 using namespace PBD;
@@ -41,7 +41,7 @@ static uint32_t
 ardour_port_flags_to_jack_flags (PortFlags flags)
 {
        uint32_t jack_flags = 0;
-       
+
        if (flags & IsInput) {
                jack_flags |= JackPortIsInput;
        }
@@ -135,12 +135,31 @@ JACKAudioBackend::get_port_property (PortHandle port, const std::string& key, st
        jack_uuid_t uuid = jack_port_uuid((jack_port_t*) port);
        rv = jack_get_property(uuid, key.c_str(), &cvalue, &ctype);
 
-       if (0 == rv) {
+       if (0 == rv && cvalue) {
                value = cvalue;
-               type = ctype;
-               jack_free(cvalue);
-               jack_free(ctype);
+               if (ctype) {
+                       type = ctype;
+               }
+       } else {
+               rv = -1;
        }
+
+       jack_free(cvalue);
+       jack_free(ctype);
+       return rv;
+#else
+       return -1;
+#endif
+}
+
+int
+JACKAudioBackend::set_port_property (PortHandle port, const std::string& key, const std::string& value, const std::string& type)
+{
+#ifdef HAVE_JACK_METADATA // really everyone ought to have this by now.
+       int rv = -1;
+       jack_client_t* client = _jack_connection->jack();
+       jack_uuid_t uuid = jack_port_uuid((jack_port_t*) port);
+       return jack_set_property(client, uuid, key.c_str(), value.c_str(), type.c_str());
        return rv;
 #else
        return -1;
@@ -242,7 +261,7 @@ JACKAudioBackend::physically_connected (PortHandle p, bool process_callback_safe
        jack_port_t* port = (jack_port_t*) p;
 
        const char** ports;
-       
+
        if (process_callback_safe) {
                ports = jack_port_get_connections ((jack_port_t*)port);
        } else {
@@ -328,7 +347,7 @@ JACKAudioBackend::get_ports (const string& port_name_pattern, DataType type, Por
        }
 
        jack_free (ports);
-       
+
        return s.size();
 }
 
@@ -442,7 +461,7 @@ int
 JACKAudioBackend::connect (const std::string& src, const std::string& dst)
 {
        GET_PRIVATE_JACK_POINTER_RET (_priv_jack, -1);
-       
+
        int r = jack_connect (_priv_jack, src.c_str(), dst.c_str());
        return r;
 }
@@ -469,7 +488,7 @@ JACKAudioBackend::disconnect_all (PortHandle port)
 }
 
 int
-JACKAudioBackend::midi_event_get (pframes_t& timestamp, size_t& size, uint8_t** buf, void* port_buffer, uint32_t event_index)
+JACKAudioBackend::midi_event_get (pframes_t& timestamp, size_t& size, uint8_t const** buf, void* port_buffer, uint32_t event_index)
 {
        jack_midi_event_t ev;
        int ret;
@@ -505,7 +524,7 @@ void
 JACKAudioBackend::set_latency_range (PortHandle port, bool for_playback, LatencyRange r)
 {
        jack_latency_range_t range;
-       
+
        range.min = r.min;
        range.max = r.max;
 
@@ -517,7 +536,7 @@ JACKAudioBackend::get_latency_range (PortHandle port, bool for_playback)
 {
        jack_latency_range_t range;
        LatencyRange ret;
-       
+
        jack_port_get_latency_range ((jack_port_t*) port, for_playback ? JackPlaybackLatency : JackCaptureLatency, &range);
 
        ret.min = range.min;