Merge branch 'master--arm' of https://github.com/nphilipp/ardour
authorPaul Davis <paul@linuxaudiosystems.com>
Fri, 13 Sep 2013 16:58:29 +0000 (12:58 -0400)
committerPaul Davis <paul@linuxaudiosystems.com>
Fri, 13 Sep 2013 16:58:29 +0000 (12:58 -0400)
14 files changed:
libs/ardour/ardour/audio_backend.h
libs/ardour/ardour/audioengine.h
libs/ardour/ardour/port_engine.h
libs/ardour/ardour/port_manager.h
libs/ardour/ardour/visibility.h [new file with mode: 0644]
libs/ardour/audioengine.cc
libs/ardour/port.cc
libs/ardour/port_manager.cc
libs/backends/jack/jack_api.cc
libs/backends/jack/jack_audiobackend.cc
libs/backends/jack/jack_audiobackend.h
libs/backends/jack/jack_portengine.cc
libs/backends/jack/jack_portengine.h [deleted file]
libs/backends/jack/wscript

index 6c4a54da3e2a6c84d420fc60e127debafba17a21..4d57f0b43d808cd153afe9d98fafb6486d048bdd 100644 (file)
 #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.
@@ -49,17 +55,6 @@ class AudioBackend {
      */
     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.
@@ -416,11 +411,22 @@ class AudioBackend {
 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
index 5762e709b305c1a1e3c46424e776ee6b83929f19..201d96047947278441295a6509f11aa681ff6f81 100644 (file)
@@ -200,8 +200,6 @@ public:
 
     static AudioEngine*       _instance;
 
-    boost::shared_ptr<AudioBackend> _backend;
-
     Glib::Threads::Mutex      _process_lock;
     Glib::Threads::Cond        session_removed;
     bool                       session_remove_pending;
index 71f93ea05e52dd1222fe5f520dc303e6b0659958..8c0ec9e75453ee0b9bc1655f8052a12d343061d5 100644 (file)
@@ -79,6 +79,11 @@ class PortEngine {
     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
@@ -89,21 +94,16 @@ class PortEngine {
        
     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 
      */
index 6d45597a413e5f6155f72e9366eae0c8a0e09226..ba15142d83550365f329263de2c82931e86bd96e 100644 (file)
 #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:
@@ -47,8 +49,7 @@ class PortManager
     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;
@@ -134,7 +135,7 @@ class PortManager
     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;
 
diff --git a/libs/ardour/ardour/visibility.h b/libs/ardour/ardour/visibility.h
new file mode 100644 (file)
index 0000000..09287b8
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+    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__ */
index 9c810a186f5ce7947e8f0504c987957f99bad58f..567f3c7671db49a24527380cc7466bca0bd8222b 100644 (file)
@@ -505,7 +505,8 @@ AudioEngine::backend_discover (const string& path)
 {
        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,
@@ -513,15 +514,16 @@ AudioEngine::backend_discover (const string& 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;
 }
@@ -572,8 +574,7 @@ AudioEngine::set_backend (const std::string& name, const std::string& arg1, cons
                        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;
@@ -704,7 +705,7 @@ AudioEngine::connected() const
                return false;
        }
 
-       return _backend->connected();
+       return _backend->available();
 }
 
 void
index e8629cbf14b2417d1d594a75df526449e070c272..cf961d68286d92281591d1561dc8d6ad8b04c4c6 100644 (file)
@@ -122,7 +122,7 @@ Port::disconnect_all ()
 bool
 Port::connected_to (std::string const & o) const
 {
-       if (!port_engine.connected()) {
+       if (!port_engine.available()) {
                return false;
        }
 
@@ -132,7 +132,7 @@ Port::connected_to (std::string const & o) const
 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();
        }
index 1758ea4a3fe3c562b6a4a39e3e8452c23104b7dc..c7adefc531c7528d8a1bd3eab74ddfe7335201ac 100644 (file)
 #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"
 
@@ -68,13 +69,13 @@ PortManager::remove_all_ports ()
 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();
 
@@ -100,7 +101,7 @@ PortManager::make_port_name_non_relative (const string& portname) const
                return portname;
        }
 
-       str  = _impl->my_name();
+       str  = _backend->my_name();
        str += ':';
        str += portname;
 
@@ -110,11 +111,11 @@ PortManager::make_port_name_non_relative (const string& portname) const
 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) {
@@ -128,54 +129,54 @@ PortManager::port_is_mine (const string& portname) const
 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
@@ -185,7 +186,7 @@ PortManager::n_physical_inputs () const
 boost::shared_ptr<Port>
 PortManager::get_port_by_name (const string& portname)
 {
-       if (!_impl) {
+       if (!_backend) {
                return boost::shared_ptr<Port>();
        }
 
@@ -204,7 +205,7 @@ PortManager::get_port_by_name (const string& portname)
                   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);
                }
@@ -243,26 +244,26 @@ PortManager::get_ports (DataType type, PortList& pl)
 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) {
@@ -356,17 +357,17 @@ PortManager::unregister_port (boost::shared_ptr<Port> port)
 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
@@ -387,8 +388,8 @@ PortManager::connect (const string& source, const string& destination)
        } 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;
                }
@@ -423,8 +424,8 @@ PortManager::disconnect (const string& source, const string& destination)
        } 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;
                }
@@ -516,59 +517,59 @@ PortManager::registration_callback ()
 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
@@ -657,3 +658,10 @@ PortManager::fade_out (gain_t base_gain, gain_t gain_step, pframes_t nframes)
                }
        }
 }
+
+PortEngine&
+PortManager::port_engine()
+{
+       assert (_backend);
+       return *_backend;
+}
index 0136161181e0068ef5dbc79bad4f539ab531277f..836acfda11a54b1b818f6d2d17b8b2bc6ffdbc3b 100644 (file)
 
 #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 ();
 
@@ -83,20 +66,13 @@ already_configured ()
        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; }
 
index 89a93a76f6a56c883fccb04d29d275debe747c50..c9bc2ad8ac4e2a20d8824f68365f5340eff0c31a 100644 (file)
@@ -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;
@@ -451,7 +451,9 @@ JACKAudioBackend::setup_jack_startup_command ()
        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;
        }
 
@@ -465,7 +467,7 @@ JACKAudioBackend::setup_jack_startup_command ()
 int
 JACKAudioBackend::start ()
 {
-       if (!connected()) {
+       if (!available()) {
 
                if (!_jack_connection->server_running()) {
                        setup_jack_startup_command ();
@@ -736,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;
 }
@@ -747,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);
@@ -940,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);
+                               }
                        }
                }
                
index 61f1bbb60250d1fca785c317b92b35630f4bf75b..655c939c512915c125c2cf98f4c150066b5c9206 100644 (file)
@@ -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
index bd352a2f118f8218d76eb79f348206c0f9bca9f4..0d66f504487abb50d484af76724c3a5d0c8d90a9 100644 (file)
@@ -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 ();
 }
diff --git a/libs/backends/jack/jack_portengine.h b/libs/backends/jack/jack_portengine.h
deleted file mode 100644 (file)
index 0e1eb48..0000000
+++ /dev/null
@@ -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__ */
index 3c47f3a6520ed0193894ebb717d6abbda8785dd5..98c39c7b16f27a9505f0b25be8ccf6b005cc5f4a 100644 (file)
@@ -38,8 +38,9 @@ def build(bld):
     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