update JACK backend to use new inheritance structure for AudioBackend
This commit is contained in:
parent
f9d08daa47
commit
83a826095d
|
@ -19,12 +19,10 @@
|
|||
|
||||
#include "jack_connection.h"
|
||||
#include "jack_audiobackend.h"
|
||||
#include "jack_portengine.h"
|
||||
|
||||
using namespace ARDOUR;
|
||||
|
||||
static boost::shared_ptr<JACKAudioBackend> backend;
|
||||
static boost::shared_ptr<JACKPortEngine> port_engine;
|
||||
static boost::shared_ptr<JackConnection> jack_connection;
|
||||
|
||||
static boost::shared_ptr<AudioBackend>
|
||||
|
@ -41,20 +39,6 @@ backend_factory (AudioEngine& ae)
|
|||
return backend;
|
||||
}
|
||||
|
||||
static boost::shared_ptr<PortEngine>
|
||||
portengine_factory (PortManager& pm)
|
||||
{
|
||||
if (!jack_connection) {
|
||||
return boost::shared_ptr<PortEngine>();
|
||||
}
|
||||
|
||||
if (!port_engine) {
|
||||
port_engine.reset (new JACKPortEngine (pm, jack_connection));
|
||||
}
|
||||
|
||||
return port_engine;
|
||||
}
|
||||
|
||||
static int
|
||||
instantiate (const std::string& arg1, const std::string& arg2)
|
||||
{
|
||||
|
@ -70,7 +54,6 @@ instantiate (const std::string& arg1, const std::string& arg2)
|
|||
static int
|
||||
deinstantiate ()
|
||||
{
|
||||
port_engine.reset ();
|
||||
backend.reset ();
|
||||
jack_connection.reset ();
|
||||
|
||||
|
@ -95,7 +78,6 @@ extern "C" {
|
|||
instantiate,
|
||||
deinstantiate,
|
||||
backend_factory,
|
||||
portengine_factory,
|
||||
already_configured,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
|
||||
#include "jack_audiobackend.h"
|
||||
#include "jack_connection.h"
|
||||
#include "jack_portengine.h"
|
||||
#include "jack_utils.h"
|
||||
|
||||
#include "i18n.h"
|
||||
|
@ -67,6 +66,7 @@ JACKAudioBackend::JACKAudioBackend (AudioEngine& e, boost::shared_ptr<JackConnec
|
|||
, _current_sample_rate (0)
|
||||
, _current_buffer_size (0)
|
||||
{
|
||||
_jack_connection->Connected.connect_same_thread (jack_connection_connection, boost::bind (&JACKAudioBackend::when_connected_to_jack, this));
|
||||
_jack_connection->Disconnected.connect_same_thread (disconnect_connection, boost::bind (&JACKAudioBackend::disconnected, this, _1));
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ JACKAudioBackend::private_handle() const
|
|||
}
|
||||
|
||||
bool
|
||||
JACKAudioBackend::connected() const
|
||||
JACKAudioBackend::available() const
|
||||
{
|
||||
return (private_handle() != 0);
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ JACKAudioBackend::available_sample_rates (const string& /*device*/) const
|
|||
{
|
||||
vector<float> f;
|
||||
|
||||
if (connected()) {
|
||||
if (available()) {
|
||||
f.push_back (sample_rate());
|
||||
return f;
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ JACKAudioBackend::available_buffer_sizes (const string& /*device*/) const
|
|||
{
|
||||
vector<uint32_t> s;
|
||||
|
||||
if (connected()) {
|
||||
if (available()) {
|
||||
s.push_back (buffer_size());
|
||||
return s;
|
||||
}
|
||||
|
@ -223,7 +223,7 @@ JACKAudioBackend::available_output_channel_count (const string& /*device*/) cons
|
|||
int
|
||||
JACKAudioBackend::set_device_name (const string& dev)
|
||||
{
|
||||
if (connected()) {
|
||||
if (available()) {
|
||||
/* need to stop and restart JACK for this to work, at present */
|
||||
return -1;
|
||||
}
|
||||
|
@ -235,7 +235,7 @@ JACKAudioBackend::set_device_name (const string& dev)
|
|||
int
|
||||
JACKAudioBackend::set_sample_rate (float sr)
|
||||
{
|
||||
if (!connected()) {
|
||||
if (!available()) {
|
||||
_target_sample_rate = sr;
|
||||
return 0;
|
||||
}
|
||||
|
@ -252,7 +252,7 @@ JACKAudioBackend::set_sample_rate (float sr)
|
|||
int
|
||||
JACKAudioBackend::set_buffer_size (uint32_t nframes)
|
||||
{
|
||||
if (!connected()) {
|
||||
if (!available()) {
|
||||
_target_buffer_size = nframes;
|
||||
return 0;
|
||||
}
|
||||
|
@ -293,7 +293,7 @@ JACKAudioBackend::set_interleaved (bool yn)
|
|||
int
|
||||
JACKAudioBackend::set_input_channels (uint32_t cnt)
|
||||
{
|
||||
if (connected()) {
|
||||
if (available()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -305,7 +305,7 @@ JACKAudioBackend::set_input_channels (uint32_t cnt)
|
|||
int
|
||||
JACKAudioBackend::set_output_channels (uint32_t cnt)
|
||||
{
|
||||
if (connected()) {
|
||||
if (available()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -317,7 +317,7 @@ JACKAudioBackend::set_output_channels (uint32_t cnt)
|
|||
int
|
||||
JACKAudioBackend::set_systemic_input_latency (uint32_t l)
|
||||
{
|
||||
if (connected()) {
|
||||
if (available()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -329,7 +329,7 @@ JACKAudioBackend::set_systemic_input_latency (uint32_t l)
|
|||
int
|
||||
JACKAudioBackend::set_systemic_output_latency (uint32_t l)
|
||||
{
|
||||
if (connected()) {
|
||||
if (available()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -343,7 +343,7 @@ JACKAudioBackend::set_systemic_output_latency (uint32_t l)
|
|||
std::string
|
||||
JACKAudioBackend::device_name () const
|
||||
{
|
||||
if (connected()) {
|
||||
if (available()) {
|
||||
return "???";
|
||||
}
|
||||
|
||||
|
@ -353,7 +353,7 @@ JACKAudioBackend::device_name () const
|
|||
float
|
||||
JACKAudioBackend::sample_rate () const
|
||||
{
|
||||
if (connected()) {
|
||||
if (available()) {
|
||||
return _current_sample_rate;
|
||||
}
|
||||
return _target_sample_rate;
|
||||
|
@ -362,7 +362,7 @@ JACKAudioBackend::sample_rate () const
|
|||
uint32_t
|
||||
JACKAudioBackend::buffer_size () const
|
||||
{
|
||||
if (connected()) {
|
||||
if (available()) {
|
||||
return _current_buffer_size;
|
||||
}
|
||||
return _target_buffer_size;
|
||||
|
@ -383,7 +383,7 @@ JACKAudioBackend::interleaved () const
|
|||
uint32_t
|
||||
JACKAudioBackend::input_channels () const
|
||||
{
|
||||
if (connected()) {
|
||||
if (available()) {
|
||||
return n_physical (JackPortIsInput).n_audio();
|
||||
}
|
||||
return _target_input_channels;
|
||||
|
@ -392,7 +392,7 @@ JACKAudioBackend::input_channels () const
|
|||
uint32_t
|
||||
JACKAudioBackend::output_channels () const
|
||||
{
|
||||
if (connected()) {
|
||||
if (available()) {
|
||||
return n_physical (JackPortIsOutput).n_audio();
|
||||
}
|
||||
return _target_output_channels;
|
||||
|
@ -467,7 +467,7 @@ JACKAudioBackend::setup_jack_startup_command ()
|
|||
int
|
||||
JACKAudioBackend::start ()
|
||||
{
|
||||
if (!connected()) {
|
||||
if (!available()) {
|
||||
|
||||
if (!_jack_connection->server_running()) {
|
||||
setup_jack_startup_command ();
|
||||
|
@ -738,9 +738,9 @@ JACKAudioBackend::jack_sync_callback (jack_transport_state_t state, jack_positio
|
|||
int
|
||||
JACKAudioBackend::_xrun_callback (void *arg)
|
||||
{
|
||||
JACKAudioBackend* ae = static_cast<JACKAudioBackend*> (arg);
|
||||
if (ae->connected()) {
|
||||
ae->engine.Xrun (); /* EMIT SIGNAL */
|
||||
JACKAudioBackend* jab = static_cast<JACKAudioBackend*> (arg);
|
||||
if (jab->available()) {
|
||||
jab->engine.Xrun (); /* EMIT SIGNAL */
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -749,8 +749,8 @@ JACKAudioBackend::_xrun_callback (void *arg)
|
|||
void
|
||||
JACKAudioBackend::_session_callback (jack_session_event_t *event, void *arg)
|
||||
{
|
||||
JACKAudioBackend* ae = static_cast<JACKAudioBackend*> (arg);
|
||||
ARDOUR::Session* session = ae->engine.session();
|
||||
JACKAudioBackend* jab = static_cast<JACKAudioBackend*> (arg);
|
||||
ARDOUR::Session* session = jab->engine.session();
|
||||
|
||||
if (session) {
|
||||
session->jack_session_event (event);
|
||||
|
@ -942,8 +942,10 @@ JACKAudioBackend::n_physical (unsigned long flags) const
|
|||
if (ports) {
|
||||
for (uint32_t i = 0; ports[i]; ++i) {
|
||||
if (!strstr (ports[i], "Midi-Through")) {
|
||||
DataType t (jack_port_type (jack_port_by_name (_priv_jack, ports[i])));
|
||||
c.set (t, c.get (t) + 1);
|
||||
DataType t = port_data_type (jack_port_by_name (_priv_jack, ports[i]));
|
||||
if (t != DataType::NIL) {
|
||||
c.set (t, c.get (t) + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,10 +44,12 @@ class JACKAudioBackend : public AudioBackend {
|
|||
public:
|
||||
JACKAudioBackend (AudioEngine& e, boost::shared_ptr<JackConnection>);
|
||||
~JACKAudioBackend ();
|
||||
|
||||
/* AUDIOBACKEND API */
|
||||
|
||||
std::string name() const;
|
||||
void* private_handle() const;
|
||||
bool connected() const;
|
||||
bool available() const;
|
||||
bool is_realtime () const;
|
||||
|
||||
bool requires_driver_selection() const;
|
||||
|
@ -115,9 +117,68 @@ class JACKAudioBackend : public AudioBackend {
|
|||
void update_latencies ();
|
||||
|
||||
static bool already_configured();
|
||||
|
||||
/* PORTENGINE API */
|
||||
|
||||
const std::string& my_name() const;
|
||||
uint32_t port_name_size() const;
|
||||
|
||||
int set_port_name (PortHandle, const std::string&);
|
||||
std::string get_port_name (PortHandle) const;
|
||||
PortHandle* get_port_by_name (const std::string&) const;
|
||||
|
||||
int get_ports (const std::string& port_name_pattern, DataType type, PortFlags flags, std::vector<std::string>&) const;
|
||||
|
||||
DataType port_data_type (PortHandle) const;
|
||||
|
||||
PortHandle register_port (const std::string& shortname, ARDOUR::DataType, ARDOUR::PortFlags);
|
||||
void unregister_port (PortHandle);
|
||||
|
||||
bool connected (PortHandle, bool process_callback_safe);
|
||||
bool connected_to (PortHandle, const std::string&, bool process_callback_safe);
|
||||
bool physically_connected (PortHandle, bool process_callback_safe);
|
||||
int get_connections (PortHandle, std::vector<std::string>&, bool process_callback_safe);
|
||||
int connect (PortHandle, const std::string&);
|
||||
|
||||
int disconnect (PortHandle, const std::string&);
|
||||
int disconnect_all (PortHandle);
|
||||
int connect (const std::string& src, const std::string& dst);
|
||||
int disconnect (const std::string& src, const std::string& dst);
|
||||
|
||||
/* MIDI */
|
||||
|
||||
int midi_event_get (pframes_t& timestamp, size_t& size, uint8_t** buf, void* port_buffer, uint32_t event_index);
|
||||
int midi_event_put (void* port_buffer, pframes_t timestamp, const uint8_t* buffer, size_t size);
|
||||
uint32_t get_midi_event_count (void* port_buffer);
|
||||
void midi_clear (void* port_buffer);
|
||||
|
||||
/* Monitoring */
|
||||
|
||||
bool can_monitor_input() const;
|
||||
int request_input_monitoring (PortHandle, bool);
|
||||
int ensure_input_monitoring (PortHandle, bool);
|
||||
bool monitoring_input (PortHandle);
|
||||
|
||||
/* Latency management
|
||||
*/
|
||||
|
||||
void set_latency_range (PortHandle, bool for_playback, LatencyRange);
|
||||
LatencyRange get_latency_range (PortHandle, bool for_playback);
|
||||
|
||||
/* Physical ports */
|
||||
|
||||
bool port_is_physical (PortHandle) const;
|
||||
void get_physical_outputs (DataType type, std::vector<std::string>&);
|
||||
void get_physical_inputs (DataType type, std::vector<std::string>&);
|
||||
ChanCount n_physical_outputs () const;
|
||||
ChanCount n_physical_inputs () const;
|
||||
|
||||
/* Getting access to the data buffer for a port */
|
||||
|
||||
void* get_buffer (PortHandle, pframes_t);
|
||||
|
||||
private:
|
||||
boost::shared_ptr<JackConnection> _jack_connection; //< shared with JACKPortEngine
|
||||
boost::shared_ptr<JackConnection> _jack_connection;
|
||||
bool _running;
|
||||
bool _freewheeling;
|
||||
std::map<DataType,size_t> _raw_buffer_sizes;
|
||||
|
@ -158,8 +219,6 @@ class JACKAudioBackend : public AudioBackend {
|
|||
void* process_thread ();
|
||||
static void* _start_process_thread (void*);
|
||||
|
||||
ChanCount n_physical (unsigned long) const;
|
||||
|
||||
void setup_jack_startup_command ();
|
||||
|
||||
/* pffooo */
|
||||
|
@ -183,6 +242,20 @@ class JACKAudioBackend : public AudioBackend {
|
|||
mutable DriverDeviceMap all_devices;
|
||||
|
||||
PBD::ScopedConnection disconnect_connection;
|
||||
|
||||
/* PORTENGINE RELATED */
|
||||
|
||||
static int _graph_order_callback (void *arg);
|
||||
static void _registration_callback (jack_port_id_t, int, void *);
|
||||
static void _connect_callback (jack_port_id_t, jack_port_id_t, int, void *);
|
||||
|
||||
void connect_callback (jack_port_id_t, jack_port_id_t, int);
|
||||
|
||||
ChanCount n_physical (unsigned long flags) const;
|
||||
void get_physical (DataType type, unsigned long flags, std::vector<std::string>& phy) const;
|
||||
|
||||
void when_connected_to_jack ();
|
||||
PBD::ScopedConnection jack_connection_connection;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -22,8 +22,9 @@
|
|||
|
||||
#include "pbd/error.h"
|
||||
|
||||
#include "jack_portengine.h"
|
||||
#include "jack_audiobackend.h"
|
||||
#include "jack_connection.h"
|
||||
#include "jack/midiport.h"
|
||||
|
||||
#include "ardour/port_manager.h"
|
||||
|
||||
|
@ -85,24 +86,8 @@ ardour_data_type_to_jack_port_type (DataType d)
|
|||
return "";
|
||||
}
|
||||
|
||||
JACKPortEngine::JACKPortEngine (PortManager& pm, boost::shared_ptr<JackConnection> jc)
|
||||
: PortEngine (pm)
|
||||
, _jack_connection (jc)
|
||||
{
|
||||
_jack_connection->Connected.connect_same_thread (jack_connection_connection, boost::bind (&JACKPortEngine::connected_to_jack, this));
|
||||
}
|
||||
|
||||
JACKPortEngine::~JACKPortEngine ()
|
||||
{
|
||||
/* a default destructor would do this, and so would this one,
|
||||
but we'll make it explicit in case we ever need to debug
|
||||
the lifetime of the JACKConnection
|
||||
*/
|
||||
_jack_connection.reset ();
|
||||
}
|
||||
|
||||
void
|
||||
JACKPortEngine::connected_to_jack ()
|
||||
JACKAudioBackend::when_connected_to_jack ()
|
||||
{
|
||||
/* register callbacks for stuff that is our responsibility */
|
||||
|
||||
|
@ -119,57 +104,45 @@ JACKPortEngine::connected_to_jack ()
|
|||
jack_set_graph_order_callback (client, _graph_order_callback, this);
|
||||
}
|
||||
|
||||
void*
|
||||
JACKPortEngine::private_handle() const
|
||||
{
|
||||
return _jack_connection->jack();
|
||||
}
|
||||
|
||||
bool
|
||||
JACKPortEngine::connected() const
|
||||
{
|
||||
return _jack_connection->connected();
|
||||
}
|
||||
|
||||
int
|
||||
JACKPortEngine::set_port_name (PortHandle port, const std::string& name)
|
||||
JACKAudioBackend::set_port_name (PortHandle port, const std::string& name)
|
||||
{
|
||||
return jack_port_set_name ((jack_port_t*) port, name.c_str());
|
||||
}
|
||||
|
||||
string
|
||||
JACKPortEngine::get_port_name (PortHandle port) const
|
||||
JACKAudioBackend::get_port_name (PortHandle port) const
|
||||
{
|
||||
return jack_port_name ((jack_port_t*) port);
|
||||
}
|
||||
|
||||
PortEngine::PortHandle*
|
||||
JACKPortEngine:: get_port_by_name (const std::string& name) const
|
||||
JACKAudioBackend:: get_port_by_name (const std::string& name) const
|
||||
{
|
||||
GET_PRIVATE_JACK_POINTER_RET (_priv_jack, 0);
|
||||
return (PortHandle*) jack_port_by_name (_priv_jack, name.c_str());
|
||||
}
|
||||
|
||||
void
|
||||
JACKPortEngine::_registration_callback (jack_port_id_t /*id*/, int /*reg*/, void* arg)
|
||||
JACKAudioBackend::_registration_callback (jack_port_id_t /*id*/, int /*reg*/, void* arg)
|
||||
{
|
||||
static_cast<JACKPortEngine*> (arg)->manager.registration_callback ();
|
||||
static_cast<JACKAudioBackend*> (arg)->manager.registration_callback ();
|
||||
}
|
||||
|
||||
int
|
||||
JACKPortEngine::_graph_order_callback (void *arg)
|
||||
JACKAudioBackend::_graph_order_callback (void *arg)
|
||||
{
|
||||
return static_cast<JACKPortEngine*> (arg)->manager.graph_order_callback ();
|
||||
return static_cast<JACKAudioBackend*> (arg)->manager.graph_order_callback ();
|
||||
}
|
||||
|
||||
void
|
||||
JACKPortEngine::_connect_callback (jack_port_id_t id_a, jack_port_id_t id_b, int conn, void* arg)
|
||||
JACKAudioBackend::_connect_callback (jack_port_id_t id_a, jack_port_id_t id_b, int conn, void* arg)
|
||||
{
|
||||
static_cast<JACKPortEngine*> (arg)->connect_callback (id_a, id_b, conn);
|
||||
static_cast<JACKAudioBackend*> (arg)->connect_callback (id_a, id_b, conn);
|
||||
}
|
||||
|
||||
void
|
||||
JACKPortEngine::connect_callback (jack_port_id_t id_a, jack_port_id_t id_b, int conn)
|
||||
JACKAudioBackend::connect_callback (jack_port_id_t id_a, jack_port_id_t id_b, int conn)
|
||||
{
|
||||
if (manager.port_remove_in_progress()) {
|
||||
return;
|
||||
|
@ -184,7 +157,7 @@ JACKPortEngine::connect_callback (jack_port_id_t id_a, jack_port_id_t id_b, int
|
|||
}
|
||||
|
||||
bool
|
||||
JACKPortEngine::connected (PortHandle port, bool process_callback_safe)
|
||||
JACKAudioBackend::connected (PortHandle port, bool process_callback_safe)
|
||||
{
|
||||
bool ret = false;
|
||||
|
||||
|
@ -207,7 +180,7 @@ JACKPortEngine::connected (PortHandle port, bool process_callback_safe)
|
|||
}
|
||||
|
||||
bool
|
||||
JACKPortEngine::connected_to (PortHandle port, const std::string& other, bool process_callback_safe)
|
||||
JACKAudioBackend::connected_to (PortHandle port, const std::string& other, bool process_callback_safe)
|
||||
{
|
||||
bool ret = false;
|
||||
const char** ports;
|
||||
|
@ -232,7 +205,7 @@ JACKPortEngine::connected_to (PortHandle port, const std::string& other, bool pr
|
|||
}
|
||||
|
||||
bool
|
||||
JACKPortEngine::physically_connected (PortHandle p, bool process_callback_safe)
|
||||
JACKAudioBackend::physically_connected (PortHandle p, bool process_callback_safe)
|
||||
{
|
||||
GET_PRIVATE_JACK_POINTER_RET (_priv_jack, false);
|
||||
jack_port_t* port = (jack_port_t*) p;
|
||||
|
@ -262,7 +235,7 @@ JACKPortEngine::physically_connected (PortHandle p, bool process_callback_safe)
|
|||
}
|
||||
|
||||
int
|
||||
JACKPortEngine::get_connections (PortHandle port, vector<string>& s, bool process_callback_safe)
|
||||
JACKAudioBackend::get_connections (PortHandle port, vector<string>& s, bool process_callback_safe)
|
||||
{
|
||||
const char** ports;
|
||||
|
||||
|
@ -284,19 +257,19 @@ JACKPortEngine::get_connections (PortHandle port, vector<string>& s, bool proces
|
|||
}
|
||||
|
||||
DataType
|
||||
JACKPortEngine::port_data_type (PortHandle p) const
|
||||
JACKAudioBackend::port_data_type (PortHandle p) const
|
||||
{
|
||||
return jack_port_type_to_ardour_data_type (jack_port_type ((jack_port_t*) p));
|
||||
}
|
||||
|
||||
const string&
|
||||
JACKPortEngine::my_name() const
|
||||
JACKAudioBackend::my_name() const
|
||||
{
|
||||
return _jack_connection->client_name();
|
||||
}
|
||||
|
||||
bool
|
||||
JACKPortEngine::port_is_physical (PortHandle ph) const
|
||||
JACKAudioBackend::port_is_physical (PortHandle ph) const
|
||||
{
|
||||
if (!ph) {
|
||||
return false;
|
||||
|
@ -306,7 +279,7 @@ JACKPortEngine::port_is_physical (PortHandle ph) const
|
|||
}
|
||||
|
||||
int
|
||||
JACKPortEngine::get_ports (const string& port_name_pattern, DataType type, PortFlags flags, vector<string>& s) const
|
||||
JACKAudioBackend::get_ports (const string& port_name_pattern, DataType type, PortFlags flags, vector<string>& s) const
|
||||
{
|
||||
|
||||
GET_PRIVATE_JACK_POINTER_RET (_priv_jack,0);
|
||||
|
@ -329,44 +302,19 @@ JACKPortEngine::get_ports (const string& port_name_pattern, DataType type, PortF
|
|||
}
|
||||
|
||||
ChanCount
|
||||
JACKPortEngine::n_physical (unsigned long flags) const
|
||||
{
|
||||
ChanCount c;
|
||||
|
||||
GET_PRIVATE_JACK_POINTER_RET (_priv_jack, c);
|
||||
|
||||
const char ** ports = jack_get_ports (_priv_jack, NULL, NULL, JackPortIsPhysical | flags);
|
||||
|
||||
if (ports) {
|
||||
for (uint32_t i = 0; ports[i]; ++i) {
|
||||
if (!strstr (ports[i], "Midi-Through")) {
|
||||
DataType t = port_data_type (jack_port_by_name (_priv_jack, ports[i]));
|
||||
if (t != DataType::NIL) {
|
||||
c.set (t, c.get (t) + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
jack_free (ports);
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
ChanCount
|
||||
JACKPortEngine::n_physical_inputs () const
|
||||
JACKAudioBackend::n_physical_inputs () const
|
||||
{
|
||||
return n_physical (JackPortIsInput);
|
||||
}
|
||||
|
||||
ChanCount
|
||||
JACKPortEngine::n_physical_outputs () const
|
||||
JACKAudioBackend::n_physical_outputs () const
|
||||
{
|
||||
return n_physical (JackPortIsOutput);
|
||||
}
|
||||
|
||||
void
|
||||
JACKPortEngine::get_physical (DataType type, unsigned long flags, vector<string>& phy) const
|
||||
JACKAudioBackend::get_physical (DataType type, unsigned long flags, vector<string>& phy) const
|
||||
{
|
||||
GET_PRIVATE_JACK_POINTER (_priv_jack);
|
||||
const char ** ports;
|
||||
|
@ -390,7 +338,7 @@ JACKPortEngine::get_physical (DataType type, unsigned long flags, vector<string>
|
|||
* a physical input connector.
|
||||
*/
|
||||
void
|
||||
JACKPortEngine::get_physical_inputs (DataType type, vector<string>& ins)
|
||||
JACKAudioBackend::get_physical_inputs (DataType type, vector<string>& ins)
|
||||
{
|
||||
get_physical (type, JackPortIsOutput, ins);
|
||||
}
|
||||
|
@ -399,14 +347,14 @@ JACKPortEngine::get_physical_inputs (DataType type, vector<string>& ins)
|
|||
* a physical output connector.
|
||||
*/
|
||||
void
|
||||
JACKPortEngine::get_physical_outputs (DataType type, vector<string>& outs)
|
||||
JACKAudioBackend::get_physical_outputs (DataType type, vector<string>& outs)
|
||||
{
|
||||
get_physical (type, JackPortIsInput, outs);
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
JACKPortEngine::can_monitor_input () const
|
||||
JACKAudioBackend::can_monitor_input () const
|
||||
{
|
||||
GET_PRIVATE_JACK_POINTER_RET (_priv_jack,false);
|
||||
const char ** ports;
|
||||
|
@ -421,32 +369,23 @@ JACKPortEngine::can_monitor_input () const
|
|||
}
|
||||
|
||||
int
|
||||
JACKPortEngine::request_input_monitoring (PortHandle port, bool yn)
|
||||
JACKAudioBackend::request_input_monitoring (PortHandle port, bool yn)
|
||||
{
|
||||
return jack_port_request_monitor ((jack_port_t*) port, yn);
|
||||
}
|
||||
int
|
||||
JACKPortEngine::ensure_input_monitoring (PortHandle port, bool yn)
|
||||
JACKAudioBackend::ensure_input_monitoring (PortHandle port, bool yn)
|
||||
{
|
||||
return jack_port_ensure_monitor ((jack_port_t*) port, yn);
|
||||
}
|
||||
bool
|
||||
JACKPortEngine::monitoring_input (PortHandle port)
|
||||
JACKAudioBackend::monitoring_input (PortHandle port)
|
||||
{
|
||||
return jack_port_monitoring_input ((jack_port_t*) port);
|
||||
}
|
||||
|
||||
|
||||
pframes_t
|
||||
JACKPortEngine::sample_time_at_cycle_start ()
|
||||
{
|
||||
GET_PRIVATE_JACK_POINTER_RET (_priv_jack, 0);
|
||||
return jack_last_frame_time (_priv_jack);
|
||||
}
|
||||
|
||||
|
||||
PortEngine::PortHandle
|
||||
JACKPortEngine::register_port (const std::string& shortname, ARDOUR::DataType type, ARDOUR::PortFlags flags)
|
||||
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(),
|
||||
|
@ -456,20 +395,20 @@ JACKPortEngine::register_port (const std::string& shortname, ARDOUR::DataType ty
|
|||
}
|
||||
|
||||
void
|
||||
JACKPortEngine::unregister_port (PortHandle port)
|
||||
JACKAudioBackend::unregister_port (PortHandle port)
|
||||
{
|
||||
GET_PRIVATE_JACK_POINTER (_priv_jack);
|
||||
(void) jack_port_unregister (_priv_jack, (jack_port_t*) port);
|
||||
}
|
||||
|
||||
int
|
||||
JACKPortEngine::connect (PortHandle port, const std::string& other)
|
||||
JACKAudioBackend::connect (PortHandle port, const std::string& other)
|
||||
{
|
||||
GET_PRIVATE_JACK_POINTER_RET (_priv_jack, -1);
|
||||
return jack_connect (_priv_jack, jack_port_name ((jack_port_t*) port), other.c_str());
|
||||
}
|
||||
int
|
||||
JACKPortEngine::connect (const std::string& src, const std::string& dst)
|
||||
JACKAudioBackend::connect (const std::string& src, const std::string& dst)
|
||||
{
|
||||
GET_PRIVATE_JACK_POINTER_RET (_priv_jack, -1);
|
||||
|
||||
|
@ -478,28 +417,28 @@ JACKPortEngine::connect (const std::string& src, const std::string& dst)
|
|||
}
|
||||
|
||||
int
|
||||
JACKPortEngine::disconnect (PortHandle port, const std::string& other)
|
||||
JACKAudioBackend::disconnect (PortHandle port, const std::string& other)
|
||||
{
|
||||
GET_PRIVATE_JACK_POINTER_RET (_priv_jack, -1);
|
||||
return jack_disconnect (_priv_jack, jack_port_name ((jack_port_t*) port), other.c_str());
|
||||
}
|
||||
|
||||
int
|
||||
JACKPortEngine::disconnect (const std::string& src, const std::string& dst)
|
||||
JACKAudioBackend::disconnect (const std::string& src, const std::string& dst)
|
||||
{
|
||||
GET_PRIVATE_JACK_POINTER_RET (_priv_jack, -1);
|
||||
return jack_disconnect (_priv_jack, src.c_str(), dst.c_str());
|
||||
}
|
||||
|
||||
int
|
||||
JACKPortEngine::disconnect_all (PortHandle port)
|
||||
JACKAudioBackend::disconnect_all (PortHandle port)
|
||||
{
|
||||
GET_PRIVATE_JACK_POINTER_RET (_priv_jack, -1);
|
||||
return jack_port_disconnect (_priv_jack, (jack_port_t*) port);
|
||||
}
|
||||
|
||||
int
|
||||
JACKPortEngine::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** buf, void* port_buffer, uint32_t event_index)
|
||||
{
|
||||
jack_midi_event_t ev;
|
||||
int ret;
|
||||
|
@ -514,25 +453,25 @@ JACKPortEngine::midi_event_get (pframes_t& timestamp, size_t& size, uint8_t** bu
|
|||
}
|
||||
|
||||
int
|
||||
JACKPortEngine::midi_event_put (void* port_buffer, pframes_t timestamp, const uint8_t* buffer, size_t size)
|
||||
JACKAudioBackend::midi_event_put (void* port_buffer, pframes_t timestamp, const uint8_t* buffer, size_t size)
|
||||
{
|
||||
return jack_midi_event_write (port_buffer, timestamp, buffer, size);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
JACKPortEngine::get_midi_event_count (void* port_buffer)
|
||||
JACKAudioBackend::get_midi_event_count (void* port_buffer)
|
||||
{
|
||||
return jack_midi_get_event_count (port_buffer);
|
||||
}
|
||||
|
||||
void
|
||||
JACKPortEngine::midi_clear (void* port_buffer)
|
||||
JACKAudioBackend::midi_clear (void* port_buffer)
|
||||
{
|
||||
jack_midi_clear_buffer (port_buffer);
|
||||
}
|
||||
|
||||
void
|
||||
JACKPortEngine::set_latency_range (PortHandle port, bool for_playback, LatencyRange r)
|
||||
JACKAudioBackend::set_latency_range (PortHandle port, bool for_playback, LatencyRange r)
|
||||
{
|
||||
jack_latency_range_t range;
|
||||
|
||||
|
@ -543,7 +482,7 @@ JACKPortEngine::set_latency_range (PortHandle port, bool for_playback, LatencyRa
|
|||
}
|
||||
|
||||
LatencyRange
|
||||
JACKPortEngine::get_latency_range (PortHandle port, bool for_playback)
|
||||
JACKAudioBackend::get_latency_range (PortHandle port, bool for_playback)
|
||||
{
|
||||
jack_latency_range_t range;
|
||||
LatencyRange ret;
|
||||
|
@ -557,13 +496,13 @@ JACKPortEngine::get_latency_range (PortHandle port, bool for_playback)
|
|||
}
|
||||
|
||||
void*
|
||||
JACKPortEngine::get_buffer (PortHandle port, pframes_t nframes)
|
||||
JACKAudioBackend::get_buffer (PortHandle port, pframes_t nframes)
|
||||
{
|
||||
return jack_port_get_buffer ((jack_port_t*) port, nframes);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
JACKPortEngine::port_name_size() const
|
||||
JACKAudioBackend::port_name_size() const
|
||||
{
|
||||
return jack_port_name_size ();
|
||||
}
|
||||
|
|
|
@ -1,132 +0,0 @@
|
|||
/*
|
||||
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.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __libardour_jack_portengine_h__
|
||||
#define __libardour_jack_portengine_h__
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <jack/types.h>
|
||||
#include <jack/midiport.h>
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#include "pbd/signals.h"
|
||||
|
||||
#include "ardour/port_engine.h"
|
||||
#include "ardour/types.h"
|
||||
|
||||
namespace ARDOUR {
|
||||
|
||||
class JackConnection;
|
||||
|
||||
class JACKPortEngine : public PortEngine
|
||||
{
|
||||
public:
|
||||
JACKPortEngine (PortManager&, boost::shared_ptr<JackConnection>);
|
||||
~JACKPortEngine();
|
||||
|
||||
void* private_handle() const;
|
||||
bool connected() const;
|
||||
|
||||
const std::string& my_name() const;
|
||||
|
||||
uint32_t port_name_size() const;
|
||||
|
||||
int set_port_name (PortHandle, const std::string&);
|
||||
std::string get_port_name (PortHandle) const;
|
||||
PortHandle* get_port_by_name (const std::string&) const;
|
||||
|
||||
int get_ports (const std::string& port_name_pattern, DataType type, PortFlags flags, std::vector<std::string>&) const;
|
||||
|
||||
DataType port_data_type (PortHandle) const;
|
||||
|
||||
PortHandle register_port (const std::string& shortname, ARDOUR::DataType, ARDOUR::PortFlags);
|
||||
void unregister_port (PortHandle);
|
||||
|
||||
bool connected (PortHandle, bool process_callback_safe);
|
||||
bool connected_to (PortHandle, const std::string&, bool process_callback_safe);
|
||||
bool physically_connected (PortHandle, bool process_callback_safe);
|
||||
int get_connections (PortHandle, std::vector<std::string>&, bool process_callback_safe);
|
||||
int connect (PortHandle, const std::string&);
|
||||
|
||||
int disconnect (PortHandle, const std::string&);
|
||||
int disconnect_all (PortHandle);
|
||||
int connect (const std::string& src, const std::string& dst);
|
||||
int disconnect (const std::string& src, const std::string& dst);
|
||||
|
||||
/* MIDI */
|
||||
|
||||
int midi_event_get (pframes_t& timestamp, size_t& size, uint8_t** buf, void* port_buffer, uint32_t event_index);
|
||||
int midi_event_put (void* port_buffer, pframes_t timestamp, const uint8_t* buffer, size_t size);
|
||||
uint32_t get_midi_event_count (void* port_buffer);
|
||||
void midi_clear (void* port_buffer);
|
||||
|
||||
/* Monitoring */
|
||||
|
||||
bool can_monitor_input() const;
|
||||
int request_input_monitoring (PortHandle, bool);
|
||||
int ensure_input_monitoring (PortHandle, bool);
|
||||
bool monitoring_input (PortHandle);
|
||||
|
||||
/* Latency management
|
||||
*/
|
||||
|
||||
void set_latency_range (PortHandle, bool for_playback, LatencyRange);
|
||||
LatencyRange get_latency_range (PortHandle, bool for_playback);
|
||||
|
||||
/* Physical ports */
|
||||
|
||||
bool port_is_physical (PortHandle) const;
|
||||
void get_physical_outputs (DataType type, std::vector<std::string>&);
|
||||
void get_physical_inputs (DataType type, std::vector<std::string>&);
|
||||
ChanCount n_physical_outputs () const;
|
||||
ChanCount n_physical_inputs () const;
|
||||
|
||||
/* Getting access to the data buffer for a port */
|
||||
|
||||
void* get_buffer (PortHandle, pframes_t);
|
||||
|
||||
/* Miscellany */
|
||||
|
||||
pframes_t sample_time_at_cycle_start ();
|
||||
|
||||
private:
|
||||
boost::shared_ptr<JackConnection> _jack_connection;
|
||||
|
||||
static int _graph_order_callback (void *arg);
|
||||
static void _registration_callback (jack_port_id_t, int, void *);
|
||||
static void _connect_callback (jack_port_id_t, jack_port_id_t, int, void *);
|
||||
|
||||
void connect_callback (jack_port_id_t, jack_port_id_t, int);
|
||||
|
||||
ChanCount n_physical (unsigned long flags) const;
|
||||
void get_physical (DataType type, unsigned long flags, std::vector<std::string>& phy) const;
|
||||
|
||||
PBD::ScopedConnection jack_connection_connection;
|
||||
void connected_to_jack ();
|
||||
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif /* __libardour_jack_portengine_h__ */
|
Loading…
Reference in New Issue
Block a user