X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fbackends%2Fjack%2Fjack_portengine.cc;h=dfa2bdad113313a27bd5ad3f5b9ff79583f52d73;hb=2b7c585dbae9c989d35e2884060aad4b0270f90e;hp=1fe77fbb70fd4a000aad17f65116d3a5e54c2026;hpb=6fc1f270137a06115a79c6089004174c5cab5ed7;p=ardour.git diff --git a/libs/backends/jack/jack_portengine.cc b/libs/backends/jack/jack_portengine.cc index 1fe77fbb70..dfa2bdad11 100644 --- a/libs/backends/jack/jack_portengine.cc +++ b/libs/backends/jack/jack_portengine.cc @@ -24,11 +24,10 @@ #include "jack_audiobackend.h" #include "jack_connection.h" -#include "jack/midiport.h" #include "ardour/port_manager.h" -#include "i18n.h" +#include "pbd/i18n.h" using namespace ARDOUR; using namespace PBD; @@ -42,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; } @@ -107,7 +106,16 @@ JACKAudioBackend::when_connected_to_jack () int JACKAudioBackend::set_port_name (PortHandle port, const std::string& name) { +#if HAVE_JACK_PORT_RENAME + jack_client_t* client = _jack_connection->jack(); + if (client) { + return jack_port_rename (client, (jack_port_t*) port, name.c_str()); + } else { + return -1; + } +#else return jack_port_set_name ((jack_port_t*) port, name.c_str()); +#endif } string @@ -116,6 +124,48 @@ JACKAudioBackend::get_port_name (PortHandle port) const return jack_port_name ((jack_port_t*) port); } +int +JACKAudioBackend::get_port_property (PortHandle port, const std::string& key, std::string& value, std::string& type) const +{ +#ifdef HAVE_JACK_METADATA // really everyone ought to have this by now. + int rv = -1; + char *cvalue = NULL; + char *ctype = NULL; + + jack_uuid_t uuid = jack_port_uuid((jack_port_t*) port); + rv = jack_get_property(uuid, key.c_str(), &cvalue, &ctype); + + if (0 == rv && cvalue) { + value = cvalue; + 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; +#endif +} + PortEngine::PortHandle JACKAudioBackend:: get_port_by_name (const std::string& name) const { @@ -211,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 { @@ -284,8 +334,8 @@ JACKAudioBackend::get_ports (const string& port_name_pattern, DataType type, Por GET_PRIVATE_JACK_POINTER_RET (_priv_jack,0); - const char** ports = jack_get_ports (_priv_jack, port_name_pattern.c_str(), - ardour_data_type_to_jack_port_type (type), + const char** ports = jack_get_ports (_priv_jack, port_name_pattern.c_str(), + ardour_data_type_to_jack_port_type (type), ardour_port_flags_to_jack_flags (flags)); if (ports == 0) { @@ -297,7 +347,7 @@ JACKAudioBackend::get_ports (const string& port_name_pattern, DataType type, Por } jack_free (ports); - + return s.size(); } @@ -388,7 +438,7 @@ PortEngine::PortHandle JACKAudioBackend::register_port (const std::string& shortname, ARDOUR::DataType type, ARDOUR::PortFlags flags) { GET_PRIVATE_JACK_POINTER_RET (_priv_jack, 0); - return jack_port_register (_priv_jack, shortname.c_str(), + return jack_port_register (_priv_jack, shortname.c_str(), ardour_data_type_to_jack_port_type (type), ardour_port_flags_to_jack_flags (flags), 0); @@ -411,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; } @@ -438,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; @@ -474,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; @@ -486,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;