#include <boost/function.hpp>
#include "ardour/types.h"
+#include "ardour/audioengine.h"
+#include "ardour/port_engine.h"
+#include "ardour/visibility.h"
-namespace ARDOUR {
+#ifdef ARDOURBACKEND_DLL_EXPORTS // defined if we are building the ARDOUR Panners DLLs (instead of using them)
+ #define ARDOURBACKEND_API LIBARDOUR_HELPER_DLL_EXPORT
+#else
+ #define ARDOURBACKEND_API LIBARDOUR_HELPER_DLL_IMPORT
+#endif
+#define ARDOURBACKEND_LOCAL LIBARDOUR_HELPER_DLL_LOCAL
-class AudioEngine;
-class PortEngine;
-class PortManager;
+namespace ARDOUR {
-class AudioBackend {
+class AudioBackend : public PortEngine {
public:
- AudioBackend (AudioEngine& e) : engine (e){}
+ AudioBackend (AudioEngine& e) : PortEngine (e), engine (e) {}
virtual ~AudioBackend () {}
/** Return the name of this backend.
*/
virtual std::string name() const = 0;
- /** Return a private, type-free pointer to any data
- * that might be useful to a concrete implementation
- */
- virtual void* private_handle() const = 0;
-
- /** Return true if the underlying mechanism/API is still available
- * for us to utilize. return false if some or all of the AudioBackend
- * API can no longer be effectively used.
- */
- virtual bool connected() const = 0;
-
/** Return true if the callback from the underlying mechanism/API
* (CoreAudio, JACK, ASIO etc.) occurs in a thread subject to realtime
* constraints. Return false otherwise.
struct AudioBackendInfo {
const char* name;
+ /** Using arg1 and arg2, initialize this audiobackend.
+ *
+ * Returns zero on success, non-zero otherwise.
+ */
int (*instantiate) (const std::string& arg1, const std::string& arg2);
+
+ /** Release all resources associated with this audiobackend
+ */
int (*deinstantiate) (void);
- boost::shared_ptr<AudioBackend> (*backend_factory) (AudioEngine&);
- boost::shared_ptr<PortEngine> (*portengine_factory) (PortManager&);
+ /** Factory method to create an AudioBackend-derived class.
+ *
+ * Returns a valid shared_ptr to the object if successfull,
+ * or a "null" shared_ptr otherwise.
+ */
+ boost::shared_ptr<AudioBackend> (*factory) (AudioEngine&);
/** Return true if the underlying mechanism/API has been
* configured and does not need (re)configuration in order
static AudioEngine* _instance;
- boost::shared_ptr<AudioBackend> _backend;
-
Glib::Threads::Mutex _process_lock;
Glib::Threads::Cond session_removed;
bool session_remove_pending;
PortEngine (PortManager& pm) : manager (pm) {}
virtual ~PortEngine() {}
+ /** Return a private, type-free pointer to any data
+ * that might be useful to a concrete implementation
+ */
+ virtual void* private_handle() const = 0;
+
/* We use void* here so that the API can be defined for any implementation.
*
* We could theoretically use a template (PortEngine<T>) and define
typedef void* PortHandle;
- /** Return a typeless pointer to an object that may be of interest
- * that understands the internals of a particular PortEngine
- * implementation.
- *
- * XXX the existence of this method is a band-aid over some design
- * issues and will it will be removed in the future
- */
- virtual void* private_handle() const = 0;
-
- virtual bool connected() const = 0;
-
/** Return the name of this process as used by the port manager
* when naming ports.
*/
virtual const std::string& my_name() const = 0;
+
+ /** Return true if the underlying mechanism/API is still available
+ * for us to utilize. return false if some or all of the AudioBackend
+ * API can no longer be effectively used.
+ */
+ virtual bool available() const = 0;
/** Return the maximum size of a port name
*/
#include "ardour/chan_count.h"
#include "ardour/midiport_manager.h"
#include "ardour/port.h"
-#include "ardour/port_engine.h"
namespace ARDOUR {
+class PortEngine;
+class AudioBackend;
+
class PortManager
{
public:
PortManager ();
virtual ~PortManager() {}
- void set_port_engine (PortEngine& pe);
- PortEngine& port_engine() { return *_impl; }
+ PortEngine& port_engine();
uint32_t port_name_size() const;
std::string my_name() const;
PBD::Signal5<void, boost::weak_ptr<Port>, std::string, boost::weak_ptr<Port>, std::string, bool> PortConnectedOrDisconnected;
protected:
- boost::shared_ptr<PortEngine> _impl;
+ boost::shared_ptr<AudioBackend> _backend;
SerializedRCUManager<Ports> ports;
bool _port_remove_in_progress;
--- /dev/null
+/*
+ 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_visibility_h__
+#define __libardour_visibility_h__
+
+/* _WIN32 is defined by most compilers targetting Windows, but within the
+ * ardour source tree, we also define COMPILER_MSVC or COMPILER_MINGW depending
+ * on how a Windows build is built.
+ */
+
+#if defined _WIN32 || defined __CYGWIN__ || defined(COMPILER_MSVC) || defined(COMPILER_MINGW)
+ #define LIBARDOUR_HELPER_DLL_IMPORT __declspec(dllimport)
+ #define LIBARDOUR_HELPER_DLL_EXPORT __declspec(dllexport)
+ #define LIBARDOUR_HELPER_DLL_LOCAL
+#else
+ #if __GNUC__ >= 4
+ #define LIBARDOUR_HELPER_DLL_IMPORT __attribute__ ((visibility ("default")))
+ #define LIBARDOUR_HELPER_DLL_EXPORT __attribute__ ((visibility ("default")))
+ #define LIBARDOUR_HELPER_DLL_LOCAL __attribute__ ((visibility ("hidden")))
+ #else
+ #define LIBARDOUR_HELPER_DLL_IMPORT
+ #define LIBARDOUR_HELPER_DLL_EXPORT
+ #define LIBARDOUR_HELPER_DLL_LOCAL
+ #endif
+#endif
+
+#endif /* __libardour_visibility_h__ */
{
Glib::Module module (path);
AudioBackendInfo* info;
- void* sym = 0;
+ AudioBackendInfo* (*dfunc)(void);
+ void* func = 0;
if (!module) {
error << string_compose(_("AudioEngine: cannot load module \"%1\" (%2)"), path,
return 0;
}
- if (!module.get_symbol ("descriptor", sym)) {
- error << string_compose(_("AudioEngine: backend at \"%1\" has no descriptor."), path) << endmsg;
+ if (!module.get_symbol ("descriptor", func)) {
+ error << string_compose(_("AudioEngine: backend at \"%1\" has no descriptor function."), path) << endmsg;
error << Glib::Module::get_last_error() << endmsg;
return 0;
}
module.make_resident ();
- info = (AudioBackendInfo*) sym;
+ dfunc = (AudioBackendInfo* (*)(void))func;
+ info = dfunc();
return info;
}
throw failed_constructor ();
}
- _backend = b->second->backend_factory (*this);
- _impl = b->second->portengine_factory (*this);
+ _backend = b->second->factory (*this);
} catch (exception& e) {
error << string_compose (_("Could not create backend for %1: %2"), name, e.what()) << endmsg;
return false;
}
- return _backend->connected();
+ return _backend->available();
}
void
bool
Port::connected_to (std::string const & o) const
{
- if (!port_engine.connected()) {
+ if (!port_engine.available()) {
return false;
}
int
Port::get_connections (std::vector<std::string> & c) const
{
- if (!port_engine.connected()) {
+ if (!port_engine.available()) {
c.insert (c.end(), _connections.begin(), _connections.end());
return c.size();
}
#include "pbd/error.h"
#include "ardour/async_midi_port.h"
-#include "ardour/debug.h"
-#include "ardour/port_manager.h"
+#include "ardour/audio_backend.h"
#include "ardour/audio_port.h"
+#include "ardour/debug.h"
#include "ardour/midi_port.h"
#include "ardour/midiport_manager.h"
+#include "ardour/port_manager.h"
#include "i18n.h"
string
PortManager::make_port_name_relative (const string& portname) const
{
- if (!_impl) {
+ if (!_backend) {
return portname;
}
string::size_type len;
string::size_type n;
- string self = _impl->my_name();
+ string self = _backend->my_name();
len = portname.length();
return portname;
}
- str = _impl->my_name();
+ str = _backend->my_name();
str += ':';
str += portname;
bool
PortManager::port_is_mine (const string& portname) const
{
- if (!_impl) {
+ if (!_backend) {
return true;
}
- string self = _impl->my_name();
+ string self = _backend->my_name();
if (portname.find_first_of (':') != string::npos) {
if (portname.substr (0, self.length ()) != self) {
bool
PortManager::port_is_physical (const std::string& portname) const
{
- if (!_impl) {
+ if (!_backend) {
return false;
}
- PortEngine::PortHandle ph = _impl->get_port_by_name (portname);
+ PortEngine::PortHandle ph = _backend->get_port_by_name (portname);
if (!ph) {
return false;
}
- return _impl->port_is_physical (ph);
+ return _backend->port_is_physical (ph);
}
void
PortManager::get_physical_outputs (DataType type, std::vector<std::string>& s)
{
- if (!_impl) {
+ if (!_backend) {
return;
}
- _impl->get_physical_outputs (type, s);
+ _backend->get_physical_outputs (type, s);
}
void
PortManager::get_physical_inputs (DataType type, std::vector<std::string>& s)
{
- if (!_impl) {
+ if (!_backend) {
return;
}
- _impl->get_physical_inputs (type, s);
+ _backend->get_physical_inputs (type, s);
}
ChanCount
PortManager::n_physical_outputs () const
{
- if (!_impl) {
+ if (!_backend) {
return ChanCount::ZERO;
}
- return _impl->n_physical_outputs ();
+ return _backend->n_physical_outputs ();
}
ChanCount
PortManager::n_physical_inputs () const
{
- if (!_impl) {
+ if (!_backend) {
return ChanCount::ZERO;
}
- return _impl->n_physical_inputs ();
+ return _backend->n_physical_inputs ();
}
/** @param name Full or short name of port
boost::shared_ptr<Port>
PortManager::get_port_by_name (const string& portname)
{
- if (!_impl) {
+ if (!_backend) {
return boost::shared_ptr<Port>();
}
and cheap), and if so, rename the port (which will alter
the port map as a side effect).
*/
- const std::string check = make_port_name_relative (_impl->get_port_name (x->second->port_handle()));
+ const std::string check = make_port_name_relative (_backend->get_port_name (x->second->port_handle()));
if (check != rel) {
x->second->set_name (check);
}
int
PortManager::get_ports (const string& port_name_pattern, DataType type, PortFlags flags, vector<string>& s)
{
- if (!_impl) {
+ if (!_backend) {
return 0;
}
- return _impl->get_ports (port_name_pattern, type, flags, s);
+ return _backend->get_ports (port_name_pattern, type, flags, s);
}
void
PortManager::port_registration_failure (const std::string& portname)
{
- if (!_impl) {
+ if (!_backend) {
return;
}
- string full_portname = _impl->my_name();
+ string full_portname = _backend->my_name();
full_portname += ':';
full_portname += portname;
- PortEngine::PortHandle p = _impl->get_port_by_name (full_portname);
+ PortEngine::PortHandle p = _backend->get_port_by_name (full_portname);
string reason;
if (p) {
bool
PortManager::connected (const string& port_name)
{
- if (!_impl) {
+ if (!_backend) {
return false;
}
- PortEngine::PortHandle handle = _impl->get_port_by_name (port_name);
+ PortEngine::PortHandle handle = _backend->get_port_by_name (port_name);
if (!handle) {
return false;
}
- return _impl->connected (handle);
+ return _backend->connected (handle);
}
int
} else {
/* neither port is known to us ...hand-off to the PortEngine
*/
- if (_impl) {
- ret = _impl->connect (s, d);
+ if (_backend) {
+ ret = _backend->connect (s, d);
} else {
ret = -1;
}
} else {
/* neither port is known to us ...hand-off to the PortEngine
*/
- if (_impl) {
- ret = _impl->disconnect (s, d);
+ if (_backend) {
+ ret = _backend->disconnect (s, d);
} else {
ret = -1;
}
bool
PortManager::can_request_input_monitoring () const
{
- if (!_impl) {
+ if (!_backend) {
return false;
}
- return _impl->can_monitor_input ();
+ return _backend->can_monitor_input ();
}
void
PortManager::request_input_monitoring (const string& name, bool yn) const
{
- if (!_impl) {
+ if (!_backend) {
return;
}
- PortEngine::PortHandle ph = _impl->get_port_by_name (name);
+ PortEngine::PortHandle ph = _backend->get_port_by_name (name);
if (ph) {
- _impl->request_input_monitoring (ph, yn);
+ _backend->request_input_monitoring (ph, yn);
}
}
void
PortManager::ensure_input_monitoring (const string& name, bool yn) const
{
- if (!_impl) {
+ if (!_backend) {
return;
}
- PortEngine::PortHandle ph = _impl->get_port_by_name (name);
+ PortEngine::PortHandle ph = _backend->get_port_by_name (name);
if (ph) {
- _impl->ensure_input_monitoring (ph, yn);
+ _backend->ensure_input_monitoring (ph, yn);
}
}
uint32_t
PortManager::port_name_size() const
{
- if (!_impl) {
+ if (!_backend) {
return 0;
}
- return _impl->port_name_size ();
+ return _backend->port_name_size ();
}
string
PortManager::my_name() const
{
- if (!_impl) {
+ if (!_backend) {
return string();
}
- return _impl->my_name();
+ return _backend->my_name();
}
int
}
}
}
+
+PortEngine&
+PortManager::port_engine()
+{
+ assert (_backend);
+ return *_backend;
+}
#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>
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)
{
static int
deinstantiate ()
{
- port_engine.reset ();
backend.reset ();
jack_connection.reset ();
return JackConnection::server_running ();
}
-extern "C" {
-
-
- /* functions looked up using dlopen-and-cousins, and so naming scope
- * must be non-mangled.
- */
-
- ARDOUR::AudioBackendInfo descriptor = {
- "JACK",
- instantiate,
- deinstantiate,
- backend_factory,
- portengine_factory,
- already_configured,
- };
-}
+static ARDOUR::AudioBackendInfo _descriptor = {
+ "JACK",
+ instantiate,
+ deinstantiate,
+ backend_factory,
+ already_configured,
+};
+
+extern "C" ARDOURBACKEND_API ARDOUR::AudioBackendInfo* descriptor() { return &_descriptor; }
#include "jack_audiobackend.h"
#include "jack_connection.h"
-#include "jack_portengine.h"
#include "jack_utils.h"
#include "i18n.h"
, _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));
}
}
bool
-JACKAudioBackend::connected() const
+JACKAudioBackend::available() const
{
return (private_handle() != 0);
}
{
vector<float> f;
- if (connected()) {
+ if (available()) {
f.push_back (sample_rate());
return f;
}
{
vector<uint32_t> s;
- if (connected()) {
+ if (available()) {
s.push_back (buffer_size());
return s;
}
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;
}
int
JACKAudioBackend::set_sample_rate (float sr)
{
- if (!connected()) {
+ if (!available()) {
_target_sample_rate = sr;
return 0;
}
int
JACKAudioBackend::set_buffer_size (uint32_t nframes)
{
- if (!connected()) {
+ if (!available()) {
_target_buffer_size = nframes;
return 0;
}
int
JACKAudioBackend::set_input_channels (uint32_t cnt)
{
- if (connected()) {
+ if (available()) {
return -1;
}
int
JACKAudioBackend::set_output_channels (uint32_t cnt)
{
- if (connected()) {
+ if (available()) {
return -1;
}
int
JACKAudioBackend::set_systemic_input_latency (uint32_t l)
{
- if (connected()) {
+ if (available()) {
return -1;
}
int
JACKAudioBackend::set_systemic_output_latency (uint32_t l)
{
- if (connected()) {
+ if (available()) {
return -1;
}
std::string
JACKAudioBackend::device_name () const
{
- if (connected()) {
+ if (available()) {
return "???";
}
float
JACKAudioBackend::sample_rate () const
{
- if (connected()) {
+ if (available()) {
return _current_sample_rate;
}
return _target_sample_rate;
uint32_t
JACKAudioBackend::buffer_size () const
{
- if (connected()) {
+ if (available()) {
return _current_buffer_size;
}
return _target_buffer_size;
uint32_t
JACKAudioBackend::input_channels () const
{
- if (connected()) {
+ if (available()) {
return n_physical (JackPortIsInput).n_audio();
}
return _target_input_channels;
uint32_t
JACKAudioBackend::output_channels () const
{
- if (connected()) {
+ if (available()) {
return n_physical (JackPortIsOutput).n_audio();
}
return _target_output_channels;
string cmdline;
if (!get_jack_command_line_string (options, cmdline)) {
- /* error, somehow */
+ /* error, somehow - we will still try to start JACK
+ * automatically but it will be without our preferred options
+ */
return;
}
int
JACKAudioBackend::start ()
{
- if (!connected()) {
+ if (!available()) {
if (!_jack_connection->server_running()) {
setup_jack_startup_command ();
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;
}
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);
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);
+ }
}
}
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;
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;
void* process_thread ();
static void* _start_process_thread (void*);
- ChanCount n_physical (unsigned long) const;
-
void setup_jack_startup_command ();
/* pffooo */
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
#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"
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 */
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;
}
bool
-JACKPortEngine::connected (PortHandle port, bool process_callback_safe)
+JACKAudioBackend::connected (PortHandle port, bool process_callback_safe)
{
bool ret = false;
}
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;
}
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;
}
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;
}
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;
}
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);
}
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;
* 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);
}
* 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;
}
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(),
}
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);
}
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;
}
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;
}
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;
}
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 ();
}
+++ /dev/null
-/*
- 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__ */
obj.use = 'ardour libpbd'
obj.vnum = JACKBACKEND_VERSION
obj.install_path = os.path.join(bld.env['LIBDIR'], 'ardour3', 'backends')
- obj.defines = ['PACKAGE="' + I18N_PACKAGE + '"']
-
+ obj.defines = ['PACKAGE="' + I18N_PACKAGE + '"',
+ 'ARDOURBACKEND_DLL_EXPORTS'
+ ]
#
# device discovery code in the jack backend needs ALSA