weak/runtime jack linking: load libjack dynamically at runtime
[ardour.git] / libs / backends / jack / jack_audiobackend.cc
index b60d2418c9868717e45638d245644dbb905c4330..64991c16231fff4bff29d84cf8f0d9e5dba0514f 100644 (file)
@@ -27,9 +27,6 @@
 
 #include "pbd/error.h"
 
-#include "jack/jack.h"
-#include "jack/thread.h"
-
 #include "ardour/audioengine.h"
 #include "ardour/session.h"
 #include "ardour/types.h"
@@ -862,6 +859,16 @@ JACKAudioBackend::join_process_threads ()
 bool
 JACKAudioBackend::in_process_thread ()
 {
+#ifdef COMPILER_MINGW
+       if (_main_thread == GetCurrentThread()) {
+               return true;
+       }
+#else // pthreads
+       if (pthread_equal (_main_thread, pthread_self()) != 0) {
+               return true;
+       }
+#endif
+
        for (std::vector<jack_native_thread_t>::const_iterator i = _jack_threads.begin ();
             i != _jack_threads.end(); i++) {
 
@@ -909,6 +916,13 @@ JACKAudioBackend::process_thread ()
         /* JACK doesn't do this for us when we use the wait API
          */
 
+#ifdef COMPILER_MINGW
+       _main_thread = GetCurrentThread();
+#else
+       _main_thread = pthread_self ();
+#endif
+
+
         AudioEngine::thread_init_callback (this);
 
         while (1) {
@@ -1158,3 +1172,11 @@ JACKAudioBackend::speed_and_position (double& speed, framepos_t& position)
        position = pos.frame;
        return starting;
 }
+
+int
+JACKAudioBackend::reset_device ()
+{
+        /* XXX need to figure out what this means for JACK
+         */
+        return 0;
+}