don't ping JACK server 4 times to see if it is already up when ardour starts
authorPaul Davis <paul@linuxaudiosystems.com>
Thu, 26 Sep 2013 02:56:28 +0000 (22:56 -0400)
committerPaul Davis <paul@linuxaudiosystems.com>
Thu, 26 Sep 2013 02:56:28 +0000 (22:56 -0400)
libs/backends/jack/jack_api.cc
libs/backends/jack/jack_audiobackend.cc
libs/backends/jack/jack_connection.cc
libs/backends/jack/jack_connection.h

index 836acfda11a54b1b818f6d2d17b8b2bc6ffdbc3b..c8859a1fc97a8cd0d1dd1a005ef8625dcfda49db 100644 (file)
@@ -63,7 +63,7 @@ deinstantiate ()
 static bool
 already_configured ()
 {
-       return JackConnection::server_running ();
+       return !JackConnection::in_control ();
 }
 
 static ARDOUR::AudioBackendInfo _descriptor = {
index d4e2f310d3e78478d7e5135a1e034ca1cfdff277..c6a523f4d211e4236a7c50605f1f20bd7d945a4a 100644 (file)
@@ -513,7 +513,10 @@ JACKAudioBackend::start ()
 {
        if (!available()) {
 
-               if (!_jack_connection->server_running()) {
+               if (_jack_connection->in_control()) {
+                       /* we will be starting JACK, so set up the 
+                          command that JACK will use when it (auto-)starts
+                       */
                        setup_jack_startup_command ();
                }
 
index d5d25c747f2106c7b944f0f38808a50906dab73e..b3d7fcecc479e87423a4dd651205d49ccf3a205c 100644 (file)
@@ -36,6 +36,8 @@ using std::vector;
 using std::cerr;
 using std::endl;
 
+bool JackConnection::_in_control = false;
+
 static void jack_halted_callback (void* arg)
 {
        JackConnection* jc = static_cast<JackConnection*> (arg);
@@ -54,17 +56,9 @@ JackConnection::JackConnection (const std::string& arg1, const std::string& arg2
        , _client_name (arg1)
        , session_uuid (arg2)
 {
-       _in_control = !server_running();
-}
-
-JackConnection::~JackConnection ()
-{
-       close ();
-}
+       /* See if the server is already up 
+        */
 
-bool
-JackConnection::server_running ()
-{
         EnvironmentalProtectionAgency* global_epa = EnvironmentalProtectionAgency::get_global_epa ();
         boost::scoped_ptr<EnvironmentalProtectionAgency> current_epa;
 
@@ -83,10 +77,15 @@ JackConnection::server_running ()
 
        if (status == 0) {
                jack_client_close (c);
-               return true;
+               _in_control = false;
+       } else {
+               _in_control = true;
        }
+}
 
-       return false;
+JackConnection::~JackConnection ()
+{
+       close ();
 }
 
 int
@@ -106,19 +105,6 @@ JackConnection::open ()
                 global_epa->restore ();
         }
 
-       /* check to see if the server is already running so that we know if we
-        * are starting it.
-        */
-
-       jack_client_t* c = jack_client_open ("ardourprobe", JackNoStartServer, &status);
-
-       if (status == 0) {
-               _in_control = false;
-               jack_client_close (c);
-       } else {
-               _in_control = true;
-       }
-
        /* ensure that PATH or equivalent includes likely locations of the JACK
         * server, in case the user's default does not.
         */
index 229d9697d9c296875bb2130d0c177e1cdd23d896..8d15be6e3a47330a26bbaa6d428c91c614a77291 100644 (file)
@@ -27,15 +27,13 @@ class JackConnection {
     void halted_callback ();
     void halted_info_callback (jack_status_t, const char*);
 
-    bool in_control() const { return _in_control; }
+    static bool in_control() { return _in_control; }
 
-    static bool server_running();
-    
   private:
     jack_client_t* volatile _jack;
     std::string _client_name;
     std::string session_uuid;
-    bool _in_control;
+    static bool _in_control;
 };
 
 } // namespace