Merge branch 'master' into cairocanvas
authorPaul Davis <paul@linuxaudiosystems.com>
Wed, 27 Nov 2013 21:19:01 +0000 (16:19 -0500)
committerPaul Davis <paul@linuxaudiosystems.com>
Wed, 27 Nov 2013 21:19:01 +0000 (16:19 -0500)
libs/ardour/ardour/audio_backend.h
libs/backends/jack/jack_audiobackend.cc
libs/backends/jack/jack_audiobackend.h
libs/backends/jack/jack_connection.cc
libs/midi++2/ipmidi_port.cc
libs/midi++2/midi++/ipmidi_port.h
libs/midi++2/midi++/mmc.h
libs/midi++2/midi++/port.h
libs/midi++2/midi++/types.h
libs/midi++2/port.cc
libs/midi++2/wscript

index 26ced33885b76f69063a0c6681639b51449dbbcc..17d7cd4010413023b8733d336f13348f8f3305bd 100644 (file)
@@ -282,17 +282,7 @@ class AudioBackend : public PortEngine {
     virtual std::string midi_option () const = 0;
     
     /* State Control */
-
-    /* non-virtual method to avoid possible overrides of default
-     * parameters. See Scott Meyers or other books on C++ to
-     * understand this pattern, or possibly just this:
-     *
-     * http://stackoverflow.com/questions/12139786/good-pratice-default-arguments-for-pure-virtual-method
-     */ 
-    int start (bool for_latency_measurement=false) {
-           return _start (for_latency_measurement);
-    }
-
     /** Start using the device named in the most recent call
      * to set_device(), with the parameters set by various
      * the most recent calls to set_sample_rate() etc. etc.
@@ -308,8 +298,24 @@ class AudioBackend : public PortEngine {
      *        any existing systemic latency settings.
      *
      * Return zero if successful, negative values otherwise.
-     */
-    virtual int _start (bool for_latency_measurement) = 0;
+     *
+     *
+     *
+     *
+     * Why is this non-virtual but ::_start() is virtual ?
+     * Virtual methods with default parameters create possible ambiguity
+     * because a derived class may implement the same method with a different
+     * type or value of default parameter.
+     *
+     * So we make this non-virtual method to avoid possible overrides of
+     * default parameters. See Scott Meyers or other books on C++ to understand
+     * this pattern, or possibly just this:
+     *
+     * http://stackoverflow.com/questions/12139786/good-pratice-default-arguments-for-pure-virtual-method
+     */ 
+    int start (bool for_latency_measurement=false) {
+           return _start (for_latency_measurement);
+    }
 
     /** Stop using the device currently in use. 
      *
@@ -481,6 +487,8 @@ class AudioBackend : public PortEngine {
 
   protected:
     AudioEngine&          engine;
+
+    virtual int _start (bool for_latency_measurement) = 0;
 };
 
 struct AudioBackendInfo {
index d45719036f3146c1ad56e25f6863cf785cc2bbb4..ccd80e2e84e6bbb84fadd5075dcbde14507e01d9 100644 (file)
@@ -547,8 +547,11 @@ JACKAudioBackend::_start (bool for_latency_measurement)
        /* Now that we have buffer size and sample rate established, the engine 
           can go ahead and do its stuff
        */
-       
-       engine.reestablish_ports ();
+
+       if (engine.reestablish_ports ()) {
+               error << _("Could not re-establish ports after connecting to JACK") << endmsg;
+               return -1;
+       }
 
        if (!jack_port_type_get_buffer_size) {
                warning << _("This version of JACK is old - you should upgrade to a newer version that supports jack_port_type_get_buffer_size()") << endmsg;
index 2c77e6112b89fb55cdb3daf92c7092cfef8f03eb..299bb1cefd098a9f7b577d68b073f7e7882dafc5 100644 (file)
@@ -89,7 +89,6 @@ class JACKAudioBackend : public AudioBackend {
     std::string control_app_name () const;
     void launch_control_app ();
 
-    int _start (bool for_latency_measurement);
     int stop ();
     int freewheel (bool);
 
@@ -272,6 +271,9 @@ class JACKAudioBackend : public AudioBackend {
     */
 
     JACKSession* _session;
+
+  protected:
+    int _start (bool for_latency_measurement);
 };
 
 } // namespace
index b3d7fcecc479e87423a4dd651205d49ccf3a205c..09e6c9d6e7c02d2a4ba5d7c20eac7c6a63339068 100644 (file)
@@ -143,7 +143,12 @@ JackConnection::close ()
        if (_priv_jack) {       
                int ret = jack_client_close (_priv_jack);
                _jack = 0;
+
+               /* If we started JACK, it will be closing down */
+               usleep (500000);
+
                Disconnected (""); /* EMIT SIGNAL */
+
                return ret;
        }
 
index c90a3dbe6fd133a2200c21cf4ce38fd9e92ed2e6..c4544c237b9645dd296ba0193226f30535e58bf9 100644 (file)
@@ -36,9 +36,6 @@ typedef int socklen_t;
 inline void closesocket(int s) { ::close(s); }
 #endif
 
-#include <jack/jack.h>
-#include <jack/midiport.h>
-
 #include "pbd/xml++.h"
 #include "pbd/error.h"
 #include "pbd/failed_constructor.h"
index c077170026a8e7e8dbf0e87a988fe89008115321..8d5cecdf11b23d126a2fe0fc5daeb18394f96583 100644 (file)
@@ -41,8 +41,6 @@
 
 #include <glibmm/threads.h>
 
-#include <jack/types.h>
-
 #include "pbd/xml++.h"
 #include "pbd/crossthread.h"
 #include "pbd/signals.h"
index 01f8bf3b8ad107993e5b0713ff16cdf73fe6e8e0..0f2a69d5d750636663deed83733476ee2b284f66 100644 (file)
@@ -20,7 +20,6 @@
 #ifndef __midipp_mmc_h_h__
 #define __midipp_mmc_h_h__
 
-#include <jack/types.h>
 #include "timecode/time.h"
 
 #include "pbd/signals.h"
index 6d778beab298ffc0c7859d1ff043359fe1614414..f16743337c8c7e626b7604929c5a578e94ccdf46 100644 (file)
@@ -22,7 +22,9 @@
 #include <string>
 #include <iostream>
 
-#include <jack/types.h>
+#include <jack/types.h> /* XXX ... desirable to get rid of this but needed for
+                        * now due to use of JackPortIsXXXX
+                        */
 
 #include "pbd/xml++.h"
 #include "pbd/crossthread.h"
index 185e1e6f3f1c12cb4d462cb7f0e0ee44e09ff8ae..598bb8ab5a5a26442c25755c596eb897a8f2c43b 100644 (file)
@@ -20,7 +20,6 @@
 #ifndef __midi_types_h__
 #define __midi_types_h__
 
-#include <jack/jack.h>
 #include <inttypes.h>
 
 namespace MIDI {
@@ -32,8 +31,8 @@ namespace MIDI {
        typedef uint32_t       timestamp_t;
 
        /** XXX: dupes from libardour */
-       typedef int64_t        framecnt_t;
-       typedef jack_nframes_t pframes_t;
+       typedef int64_t  framecnt_t;
+       typedef uint32_t pframes_t;
 
        enum eventType {
            none = 0x0,
index 14802028671d6eba23aff504dbb77d6abaf60de4..90ec260eae1cb8822a0e12f2bfdbb66d715d2275 100644 (file)
@@ -22,9 +22,6 @@
 #include <fcntl.h>
 #include <errno.h>
 
-#include <jack/jack.h>
-#include <jack/midiport.h>
-
 #include "pbd/xml++.h"
 #include "pbd/error.h"
 #include "pbd/failed_constructor.h"
index 0abbab7d40ed6e6d82f67249d1d68e362049f12c..000cc39e5fc2fcaca29b04b68d91eeb6f4a0f883 100644 (file)
@@ -50,7 +50,6 @@ def configure(conf):
                     'midipp', MAJOR, MINOR, MICRO)
     autowaf.configure(conf)
     autowaf.check_pkg(conf, 'cppunit', uselib_store='CPPUNIT', atleast_version='1.12.0', mandatory=False)
-    autowaf.check_pkg(conf, 'jack', uselib_store='JACK', atleast_version='0.118.2')
     autowaf.check_pkg(conf, 'libxml-2.0', uselib_store='XML')
     autowaf.check_pkg(conf, 'sigc++-2.0', uselib_store='SIGCPP', atleast_version='2.0')
 
@@ -64,13 +63,13 @@ def build(bld):
         obj              = bld.shlib(features = 'cxx cxxshlib', source=libmidi_sources)
     else:
         obj              = bld.stlib(features = 'cxx cxxstlib', source=libmidi_sources)
-        obj.cxxflags = [ '-fPIC', '-DWITH_JACK_MIDI' ]
+        obj.cxxflags = [ '-fPIC' ]
     # everybody loves JACK
     obj.export_includes = ['.']
     obj.includes     = ['.', '../surfaces/control_protocol', '../ardour' ]
     obj.name         = 'libmidipp'
     obj.target       = 'midipp'
-    obj.uselib       = 'GLIBMM SIGCPP XML JACK OSX'
+    obj.uselib       = 'GLIBMM SIGCPP XML OSX'
     obj.use          = 'libpbd libevoral libtimecode'
     obj.vnum         = LIBMIDIPP_LIB_VERSION
     obj.install_path = os.path.join(bld.env['LIBDIR'], 'ardour3')