#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;
ardour_port_flags_to_jack_flags (PortFlags flags)
{
uint32_t jack_flags = 0;
-
+
if (flags & IsInput) {
jack_flags |= JackPortIsInput;
}
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
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
{
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 {
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) {
}
jack_free (ports);
-
+
return s.size();
}
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);
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;
}
}
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;
JACKAudioBackend::set_latency_range (PortHandle port, bool for_playback, LatencyRange r)
{
jack_latency_range_t range;
-
+
range.min = r.min;
range.max = r.max;
{
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;