2013-08-01 14:43:12 -04:00
|
|
|
/*
|
|
|
|
Copyright (C) 2013 Paul Davis
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2013-08-03 11:57:56 -04:00
|
|
|
#include "pbd/error.h"
|
2013-08-01 14:43:12 -04:00
|
|
|
|
2013-09-13 11:21:43 -04:00
|
|
|
#include "jack_audiobackend.h"
|
2013-09-07 11:03:57 -04:00
|
|
|
#include "jack_connection.h"
|
|
|
|
|
2013-08-01 14:43:12 -04:00
|
|
|
#include "ardour/port_manager.h"
|
|
|
|
|
2013-08-03 11:57:56 -04:00
|
|
|
#include "i18n.h"
|
|
|
|
|
2013-08-01 14:43:12 -04:00
|
|
|
using namespace ARDOUR;
|
2013-08-03 11:57:56 -04:00
|
|
|
using namespace PBD;
|
2013-08-01 14:43:12 -04:00
|
|
|
using std::string;
|
|
|
|
using std::vector;
|
|
|
|
|
2013-07-31 19:47:20 -04:00
|
|
|
#define GET_PRIVATE_JACK_POINTER(localvar) jack_client_t* localvar = _jack_connection->jack(); if (!(localvar)) { return; }
|
|
|
|
#define GET_PRIVATE_JACK_POINTER_RET(localvar,r) jack_client_t* localvar = _jack_connection->jack(); if (!(localvar)) { return r; }
|
|
|
|
|
|
|
|
static uint32_t
|
|
|
|
ardour_port_flags_to_jack_flags (PortFlags flags)
|
|
|
|
{
|
|
|
|
uint32_t jack_flags = 0;
|
|
|
|
|
2013-08-01 14:43:12 -04:00
|
|
|
if (flags & IsInput) {
|
2013-07-31 19:47:20 -04:00
|
|
|
jack_flags |= JackPortIsInput;
|
|
|
|
}
|
2013-08-01 14:43:12 -04:00
|
|
|
if (flags & IsOutput) {
|
2013-07-31 19:47:20 -04:00
|
|
|
jack_flags |= JackPortIsOutput;
|
|
|
|
}
|
2013-08-01 14:43:12 -04:00
|
|
|
if (flags & IsTerminal) {
|
2013-07-31 19:47:20 -04:00
|
|
|
jack_flags |= JackPortIsTerminal;
|
|
|
|
}
|
|
|
|
if (flags & IsPhysical) {
|
|
|
|
jack_flags |= JackPortIsPhysical;
|
|
|
|
}
|
|
|
|
if (flags & CanMonitor) {
|
|
|
|
jack_flags |= JackPortCanMonitor;
|
|
|
|
}
|
|
|
|
|
|
|
|
return jack_flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DataType
|
|
|
|
jack_port_type_to_ardour_data_type (const char* jack_type)
|
|
|
|
{
|
|
|
|
if (strcmp (jack_type, JACK_DEFAULT_AUDIO_TYPE) == 0) {
|
|
|
|
return DataType::AUDIO;
|
|
|
|
} else if (strcmp (jack_type, JACK_DEFAULT_MIDI_TYPE) == 0) {
|
|
|
|
return DataType::MIDI;
|
|
|
|
}
|
|
|
|
return DataType::NIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char*
|
|
|
|
ardour_data_type_to_jack_port_type (DataType d)
|
2013-07-30 17:48:57 -04:00
|
|
|
{
|
2013-07-31 19:47:20 -04:00
|
|
|
switch (d) {
|
|
|
|
case DataType::AUDIO:
|
|
|
|
return JACK_DEFAULT_AUDIO_TYPE;
|
|
|
|
case DataType::MIDI:
|
|
|
|
return JACK_DEFAULT_MIDI_TYPE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2013-08-03 11:57:56 -04:00
|
|
|
void
|
2013-09-13 11:21:43 -04:00
|
|
|
JACKAudioBackend::when_connected_to_jack ()
|
2013-08-03 11:57:56 -04:00
|
|
|
{
|
|
|
|
/* register callbacks for stuff that is our responsibility */
|
|
|
|
|
|
|
|
jack_client_t* client = _jack_connection->jack();
|
|
|
|
|
|
|
|
if (!client) {
|
|
|
|
/* how could this happen? it could ... */
|
|
|
|
error << _("Already disconnected from JACK before PortEngine could register callbacks") << endmsg;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
jack_set_port_registration_callback (client, _registration_callback, this);
|
|
|
|
jack_set_port_connect_callback (client, _connect_callback, this);
|
|
|
|
jack_set_graph_order_callback (client, _graph_order_callback, this);
|
|
|
|
}
|
|
|
|
|
2013-08-01 14:43:12 -04:00
|
|
|
int
|
2013-09-13 11:21:43 -04:00
|
|
|
JACKAudioBackend::set_port_name (PortHandle port, const std::string& name)
|
2013-08-01 14:43:12 -04:00
|
|
|
{
|
2015-07-02 14:02:00 -04:00
|
|
|
#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
|
2013-08-01 14:43:12 -04:00
|
|
|
return jack_port_set_name ((jack_port_t*) port, name.c_str());
|
2015-07-02 14:02:00 -04:00
|
|
|
#endif
|
2013-08-01 14:43:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
string
|
2013-09-13 11:21:43 -04:00
|
|
|
JACKAudioBackend::get_port_name (PortHandle port) const
|
2013-08-01 14:43:12 -04:00
|
|
|
{
|
|
|
|
return jack_port_name ((jack_port_t*) port);
|
|
|
|
}
|
2013-07-31 19:47:20 -04:00
|
|
|
|
2015-03-08 12:26:46 -04:00
|
|
|
int
|
|
|
|
JACKAudioBackend::get_port_property (PortHandle port, const std::string& key, std::string& value, std::string& type) const
|
|
|
|
{
|
2015-04-23 09:29:35 -04:00
|
|
|
#ifdef HAVE_JACK_METADATA // really everyone ought to have this by now.
|
2015-03-08 12:26:46 -04:00
|
|
|
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) {
|
|
|
|
value = cvalue;
|
|
|
|
type = ctype;
|
|
|
|
jack_free(cvalue);
|
|
|
|
jack_free(ctype);
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
#else
|
|
|
|
return -1;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2013-10-28 09:46:59 -04:00
|
|
|
PortEngine::PortHandle
|
2013-09-13 11:21:43 -04:00
|
|
|
JACKAudioBackend:: get_port_by_name (const std::string& name) const
|
2013-08-01 14:43:12 -04:00
|
|
|
{
|
|
|
|
GET_PRIVATE_JACK_POINTER_RET (_priv_jack, 0);
|
2013-10-28 09:46:59 -04:00
|
|
|
return (PortHandle) jack_port_by_name (_priv_jack, name.c_str());
|
2013-07-30 17:48:57 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-09-13 11:21:43 -04:00
|
|
|
JACKAudioBackend::_registration_callback (jack_port_id_t /*id*/, int /*reg*/, void* arg)
|
2013-07-30 17:48:57 -04:00
|
|
|
{
|
2013-09-13 11:21:43 -04:00
|
|
|
static_cast<JACKAudioBackend*> (arg)->manager.registration_callback ();
|
2013-08-01 14:43:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2013-09-13 11:21:43 -04:00
|
|
|
JACKAudioBackend::_graph_order_callback (void *arg)
|
2013-08-01 14:43:12 -04:00
|
|
|
{
|
2013-09-13 11:21:43 -04:00
|
|
|
return static_cast<JACKAudioBackend*> (arg)->manager.graph_order_callback ();
|
2013-07-30 17:48:57 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-09-13 11:21:43 -04:00
|
|
|
JACKAudioBackend::_connect_callback (jack_port_id_t id_a, jack_port_id_t id_b, int conn, void* arg)
|
2013-07-30 17:48:57 -04:00
|
|
|
{
|
2013-09-13 11:21:43 -04:00
|
|
|
static_cast<JACKAudioBackend*> (arg)->connect_callback (id_a, id_b, conn);
|
2013-07-30 17:48:57 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-09-13 11:21:43 -04:00
|
|
|
JACKAudioBackend::connect_callback (jack_port_id_t id_a, jack_port_id_t id_b, int conn)
|
2013-07-30 17:48:57 -04:00
|
|
|
{
|
2013-08-01 14:43:12 -04:00
|
|
|
if (manager.port_remove_in_progress()) {
|
2013-07-30 17:48:57 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
GET_PRIVATE_JACK_POINTER (_priv_jack);
|
|
|
|
|
2013-07-31 19:47:20 -04:00
|
|
|
jack_port_t* a = jack_port_by_id (_priv_jack, id_a);
|
|
|
|
jack_port_t* b = jack_port_by_id (_priv_jack, id_b);
|
2013-07-30 17:48:57 -04:00
|
|
|
|
2013-08-01 14:43:12 -04:00
|
|
|
manager.connect_callback (jack_port_name (a), jack_port_name (b), conn == 0 ? false : true);
|
2013-07-30 17:48:57 -04:00
|
|
|
}
|
|
|
|
|
2013-08-01 14:43:12 -04:00
|
|
|
bool
|
2013-09-13 11:21:43 -04:00
|
|
|
JACKAudioBackend::connected (PortHandle port, bool process_callback_safe)
|
2013-07-30 17:48:57 -04:00
|
|
|
{
|
2013-08-01 14:43:12 -04:00
|
|
|
bool ret = false;
|
|
|
|
|
2013-09-05 21:39:43 -04:00
|
|
|
const char** ports;
|
|
|
|
|
|
|
|
if (process_callback_safe) {
|
|
|
|
ports = jack_port_get_connections ((jack_port_t*)port);
|
|
|
|
} else {
|
|
|
|
GET_PRIVATE_JACK_POINTER_RET (_priv_jack, false);
|
|
|
|
ports = jack_port_get_all_connections (_priv_jack, (jack_port_t*)port);
|
|
|
|
}
|
2013-08-01 14:43:12 -04:00
|
|
|
|
|
|
|
if (ports) {
|
|
|
|
ret = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
jack_free (ports);
|
|
|
|
|
|
|
|
return ret;
|
2013-07-31 19:47:20 -04:00
|
|
|
}
|
2013-07-30 17:48:57 -04:00
|
|
|
|
2013-08-01 14:43:12 -04:00
|
|
|
bool
|
2013-09-13 11:21:43 -04:00
|
|
|
JACKAudioBackend::connected_to (PortHandle port, const std::string& other, bool process_callback_safe)
|
2013-07-31 19:47:20 -04:00
|
|
|
{
|
2013-08-01 14:43:12 -04:00
|
|
|
bool ret = false;
|
2013-09-05 21:39:43 -04:00
|
|
|
const char** ports;
|
|
|
|
|
|
|
|
if (process_callback_safe) {
|
|
|
|
ports = jack_port_get_connections ((jack_port_t*)port);
|
|
|
|
} else {
|
|
|
|
GET_PRIVATE_JACK_POINTER_RET (_priv_jack, false);
|
|
|
|
ports = jack_port_get_all_connections (_priv_jack, (jack_port_t*)port);
|
|
|
|
}
|
2013-08-01 14:43:12 -04:00
|
|
|
|
|
|
|
if (ports) {
|
|
|
|
for (int i = 0; ports[i]; ++i) {
|
|
|
|
if (other == ports[i]) {
|
|
|
|
ret = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
jack_free (ports);
|
2013-07-30 17:48:57 -04:00
|
|
|
}
|
2013-07-31 19:47:20 -04:00
|
|
|
|
2013-08-01 14:43:12 -04:00
|
|
|
return ret;
|
2013-07-30 17:48:57 -04:00
|
|
|
}
|
|
|
|
|
2013-08-01 14:43:12 -04:00
|
|
|
bool
|
2013-09-13 11:21:43 -04:00
|
|
|
JACKAudioBackend::physically_connected (PortHandle p, bool process_callback_safe)
|
2013-07-25 22:40:21 -04:00
|
|
|
{
|
2013-08-01 14:43:12 -04:00
|
|
|
GET_PRIVATE_JACK_POINTER_RET (_priv_jack, false);
|
|
|
|
jack_port_t* port = (jack_port_t*) p;
|
2013-07-25 22:40:21 -04:00
|
|
|
|
2013-09-05 21:39:43 -04:00
|
|
|
const char** ports;
|
|
|
|
|
|
|
|
if (process_callback_safe) {
|
|
|
|
ports = jack_port_get_connections ((jack_port_t*)port);
|
|
|
|
} else {
|
|
|
|
GET_PRIVATE_JACK_POINTER_RET (_priv_jack, false);
|
|
|
|
ports = jack_port_get_all_connections (_priv_jack, (jack_port_t*)port);
|
|
|
|
}
|
2013-07-25 22:40:21 -04:00
|
|
|
|
2013-08-01 14:43:12 -04:00
|
|
|
if (ports) {
|
|
|
|
for (int i = 0; ports[i]; ++i) {
|
2013-07-25 22:40:21 -04:00
|
|
|
|
2013-08-01 14:43:12 -04:00
|
|
|
jack_port_t* other = jack_port_by_name (_priv_jack, ports[i]);
|
2013-07-25 22:40:21 -04:00
|
|
|
|
2013-08-01 14:43:12 -04:00
|
|
|
if (other && (jack_port_flags (other) & JackPortIsPhysical)) {
|
2013-07-25 22:40:21 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2013-08-01 14:43:12 -04:00
|
|
|
jack_free (ports);
|
2013-07-25 22:40:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2013-07-30 23:26:46 -04:00
|
|
|
|
2013-08-01 18:49:40 -04:00
|
|
|
int
|
2013-09-13 11:21:43 -04:00
|
|
|
JACKAudioBackend::get_connections (PortHandle port, vector<string>& s, bool process_callback_safe)
|
2013-08-01 18:49:40 -04:00
|
|
|
{
|
2013-09-05 21:39:43 -04:00
|
|
|
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);
|
|
|
|
ports = jack_port_get_all_connections (_priv_jack, (jack_port_t*)port);
|
|
|
|
}
|
2013-08-01 18:49:40 -04:00
|
|
|
|
|
|
|
if (ports) {
|
|
|
|
for (int i = 0; ports[i]; ++i) {
|
|
|
|
s.push_back (ports[i]);
|
|
|
|
}
|
|
|
|
jack_free (ports);
|
|
|
|
}
|
|
|
|
|
|
|
|
return s.size();
|
|
|
|
}
|
|
|
|
|
2013-07-30 23:26:46 -04:00
|
|
|
DataType
|
2013-09-13 11:21:43 -04:00
|
|
|
JACKAudioBackend::port_data_type (PortHandle p) const
|
2013-07-30 23:26:46 -04:00
|
|
|
{
|
2013-08-01 14:43:12 -04:00
|
|
|
return jack_port_type_to_ardour_data_type (jack_port_type ((jack_port_t*) p));
|
2013-07-31 19:47:20 -04:00
|
|
|
}
|
2013-07-30 23:26:46 -04:00
|
|
|
|
2013-07-31 19:47:20 -04:00
|
|
|
const string&
|
2013-09-13 11:21:43 -04:00
|
|
|
JACKAudioBackend::my_name() const
|
2013-07-31 19:47:20 -04:00
|
|
|
{
|
2013-08-01 14:43:12 -04:00
|
|
|
return _jack_connection->client_name();
|
2013-07-31 19:47:20 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-09-13 11:21:43 -04:00
|
|
|
JACKAudioBackend::port_is_physical (PortHandle ph) const
|
2013-07-31 19:47:20 -04:00
|
|
|
{
|
|
|
|
if (!ph) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-08-01 14:43:12 -04:00
|
|
|
return jack_port_flags ((jack_port_t*) ph) & JackPortIsPhysical;
|
2013-07-31 19:47:20 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2013-09-13 11:21:43 -04:00
|
|
|
JACKAudioBackend::get_ports (const string& port_name_pattern, DataType type, PortFlags flags, vector<string>& s) const
|
2013-07-31 19:47:20 -04:00
|
|
|
{
|
|
|
|
|
|
|
|
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),
|
|
|
|
ardour_port_flags_to_jack_flags (flags));
|
|
|
|
|
|
|
|
if (ports == 0) {
|
2013-08-01 14:43:12 -04:00
|
|
|
return 0;
|
2013-07-30 23:26:46 -04:00
|
|
|
}
|
|
|
|
|
2013-07-31 19:47:20 -04:00
|
|
|
for (uint32_t i = 0; ports[i]; ++i) {
|
|
|
|
s.push_back (ports[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
jack_free (ports);
|
|
|
|
|
|
|
|
return s.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
ChanCount
|
2013-09-13 11:21:43 -04:00
|
|
|
JACKAudioBackend::n_physical_inputs () const
|
2013-07-31 19:47:20 -04:00
|
|
|
{
|
|
|
|
return n_physical (JackPortIsInput);
|
|
|
|
}
|
|
|
|
|
|
|
|
ChanCount
|
2013-09-13 11:21:43 -04:00
|
|
|
JACKAudioBackend::n_physical_outputs () const
|
2013-07-31 19:47:20 -04:00
|
|
|
{
|
|
|
|
return n_physical (JackPortIsOutput);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-09-13 11:21:43 -04:00
|
|
|
JACKAudioBackend::get_physical (DataType type, unsigned long flags, vector<string>& phy) const
|
2013-07-31 19:47:20 -04:00
|
|
|
{
|
|
|
|
GET_PRIVATE_JACK_POINTER (_priv_jack);
|
|
|
|
const char ** ports;
|
|
|
|
|
2013-08-01 14:43:12 -04:00
|
|
|
if ((ports = jack_get_ports (_priv_jack, NULL, ardour_data_type_to_jack_port_type (type), JackPortIsPhysical | flags)) == 0) {
|
2013-07-31 19:47:20 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ports) {
|
|
|
|
for (uint32_t i = 0; ports[i]; ++i) {
|
|
|
|
if (strstr (ports[i], "Midi-Through")) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
phy.push_back (ports[i]);
|
|
|
|
}
|
|
|
|
jack_free (ports);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Get physical ports for which JackPortIsOutput is set; ie those that correspond to
|
|
|
|
* a physical input connector.
|
|
|
|
*/
|
|
|
|
void
|
2013-09-13 11:21:43 -04:00
|
|
|
JACKAudioBackend::get_physical_inputs (DataType type, vector<string>& ins)
|
2013-07-31 19:47:20 -04:00
|
|
|
{
|
|
|
|
get_physical (type, JackPortIsOutput, ins);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Get physical ports for which JackPortIsInput is set; ie those that correspond to
|
|
|
|
* a physical output connector.
|
|
|
|
*/
|
|
|
|
void
|
2013-09-13 11:21:43 -04:00
|
|
|
JACKAudioBackend::get_physical_outputs (DataType type, vector<string>& outs)
|
2013-07-31 19:47:20 -04:00
|
|
|
{
|
|
|
|
get_physical (type, JackPortIsInput, outs);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
2013-09-13 11:21:43 -04:00
|
|
|
JACKAudioBackend::can_monitor_input () const
|
2013-07-31 19:47:20 -04:00
|
|
|
{
|
|
|
|
GET_PRIVATE_JACK_POINTER_RET (_priv_jack,false);
|
|
|
|
const char ** ports;
|
|
|
|
|
|
|
|
if ((ports = jack_get_ports (_priv_jack, NULL, JACK_DEFAULT_AUDIO_TYPE, JackPortCanMonitor)) == 0) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
jack_free (ports);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-08-01 18:49:40 -04:00
|
|
|
int
|
2013-09-13 11:21:43 -04:00
|
|
|
JACKAudioBackend::request_input_monitoring (PortHandle port, bool yn)
|
2013-08-01 18:49:40 -04:00
|
|
|
{
|
|
|
|
return jack_port_request_monitor ((jack_port_t*) port, yn);
|
|
|
|
}
|
|
|
|
int
|
2013-09-13 11:21:43 -04:00
|
|
|
JACKAudioBackend::ensure_input_monitoring (PortHandle port, bool yn)
|
2013-08-01 18:49:40 -04:00
|
|
|
{
|
|
|
|
return jack_port_ensure_monitor ((jack_port_t*) port, yn);
|
|
|
|
}
|
|
|
|
bool
|
2013-09-13 11:21:43 -04:00
|
|
|
JACKAudioBackend::monitoring_input (PortHandle port)
|
2013-08-01 18:49:40 -04:00
|
|
|
{
|
|
|
|
return jack_port_monitoring_input ((jack_port_t*) port);
|
|
|
|
}
|
|
|
|
|
2013-08-01 14:43:12 -04:00
|
|
|
PortEngine::PortHandle
|
2013-09-13 11:21:43 -04:00
|
|
|
JACKAudioBackend::register_port (const std::string& shortname, ARDOUR::DataType type, ARDOUR::PortFlags flags)
|
2013-08-01 14:43:12 -04:00
|
|
|
{
|
|
|
|
GET_PRIVATE_JACK_POINTER_RET (_priv_jack, 0);
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-09-13 11:21:43 -04:00
|
|
|
JACKAudioBackend::unregister_port (PortHandle port)
|
2013-08-01 14:43:12 -04:00
|
|
|
{
|
|
|
|
GET_PRIVATE_JACK_POINTER (_priv_jack);
|
|
|
|
(void) jack_port_unregister (_priv_jack, (jack_port_t*) port);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2013-09-13 11:21:43 -04:00
|
|
|
JACKAudioBackend::connect (PortHandle port, const std::string& other)
|
2013-08-01 14:43:12 -04:00
|
|
|
{
|
|
|
|
GET_PRIVATE_JACK_POINTER_RET (_priv_jack, -1);
|
|
|
|
return jack_connect (_priv_jack, jack_port_name ((jack_port_t*) port), other.c_str());
|
|
|
|
}
|
|
|
|
int
|
2013-09-13 11:21:43 -04:00
|
|
|
JACKAudioBackend::connect (const std::string& src, const std::string& dst)
|
2013-08-01 14:43:12 -04:00
|
|
|
{
|
|
|
|
GET_PRIVATE_JACK_POINTER_RET (_priv_jack, -1);
|
2013-09-05 21:39:43 -04:00
|
|
|
|
|
|
|
int r = jack_connect (_priv_jack, src.c_str(), dst.c_str());
|
|
|
|
return r;
|
2013-08-01 14:43:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2013-09-13 11:21:43 -04:00
|
|
|
JACKAudioBackend::disconnect (PortHandle port, const std::string& other)
|
2013-08-01 14:43:12 -04:00
|
|
|
{
|
|
|
|
GET_PRIVATE_JACK_POINTER_RET (_priv_jack, -1);
|
|
|
|
return jack_disconnect (_priv_jack, jack_port_name ((jack_port_t*) port), other.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2013-09-13 11:21:43 -04:00
|
|
|
JACKAudioBackend::disconnect (const std::string& src, const std::string& dst)
|
2013-08-01 14:43:12 -04:00
|
|
|
{
|
|
|
|
GET_PRIVATE_JACK_POINTER_RET (_priv_jack, -1);
|
|
|
|
return jack_disconnect (_priv_jack, src.c_str(), dst.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2013-09-13 11:21:43 -04:00
|
|
|
JACKAudioBackend::disconnect_all (PortHandle port)
|
2013-08-01 14:43:12 -04:00
|
|
|
{
|
|
|
|
GET_PRIVATE_JACK_POINTER_RET (_priv_jack, -1);
|
|
|
|
return jack_port_disconnect (_priv_jack, (jack_port_t*) port);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2013-09-13 11:21:43 -04:00
|
|
|
JACKAudioBackend::midi_event_get (pframes_t& timestamp, size_t& size, uint8_t** buf, void* port_buffer, uint32_t event_index)
|
2013-08-01 14:43:12 -04:00
|
|
|
{
|
|
|
|
jack_midi_event_t ev;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if ((ret = jack_midi_event_get (&ev, port_buffer, event_index)) == 0) {
|
|
|
|
timestamp = ev.time;
|
|
|
|
size = ev.size;
|
|
|
|
*buf = ev.buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2013-09-13 11:21:43 -04:00
|
|
|
JACKAudioBackend::midi_event_put (void* port_buffer, pframes_t timestamp, const uint8_t* buffer, size_t size)
|
2013-08-01 14:43:12 -04:00
|
|
|
{
|
|
|
|
return jack_midi_event_write (port_buffer, timestamp, buffer, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
2013-09-13 11:21:43 -04:00
|
|
|
JACKAudioBackend::get_midi_event_count (void* port_buffer)
|
2013-08-01 14:43:12 -04:00
|
|
|
{
|
|
|
|
return jack_midi_get_event_count (port_buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-09-13 11:21:43 -04:00
|
|
|
JACKAudioBackend::midi_clear (void* port_buffer)
|
2013-08-01 14:43:12 -04:00
|
|
|
{
|
|
|
|
jack_midi_clear_buffer (port_buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-09-13 11:21:43 -04:00
|
|
|
JACKAudioBackend::set_latency_range (PortHandle port, bool for_playback, LatencyRange r)
|
2013-08-01 14:43:12 -04:00
|
|
|
{
|
|
|
|
jack_latency_range_t range;
|
|
|
|
|
|
|
|
range.min = r.min;
|
|
|
|
range.max = r.max;
|
|
|
|
|
|
|
|
jack_port_set_latency_range ((jack_port_t*) port, for_playback ? JackPlaybackLatency : JackCaptureLatency, &range);
|
|
|
|
}
|
|
|
|
|
|
|
|
LatencyRange
|
2013-09-13 11:21:43 -04:00
|
|
|
JACKAudioBackend::get_latency_range (PortHandle port, bool for_playback)
|
2013-08-01 14:43:12 -04:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
ret.max = range.max;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void*
|
2013-09-13 11:21:43 -04:00
|
|
|
JACKAudioBackend::get_buffer (PortHandle port, pframes_t nframes)
|
2013-08-01 14:43:12 -04:00
|
|
|
{
|
|
|
|
return jack_port_get_buffer ((jack_port_t*) port, nframes);
|
|
|
|
}
|
2013-08-01 18:49:40 -04:00
|
|
|
|
|
|
|
uint32_t
|
2013-09-13 11:21:43 -04:00
|
|
|
JACKAudioBackend::port_name_size() const
|
2013-08-01 18:49:40 -04:00
|
|
|
{
|
|
|
|
return jack_port_name_size ();
|
|
|
|
}
|