summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2013-09-12 11:32:09 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2013-09-12 11:32:09 -0400
commit4a6412aebe4f18578f201e99ddc74fc5d9cb6bfc (patch)
tree339637963f785f97b766424b9d63f4ee201af754
parentbb826f4beebfcedc50570b818c305560d2233e47 (diff)
parent4df3666738607039445ebc9fa083bf5c23ac5539 (diff)
merge with master
-rw-r--r--libs/ardour/ardour/audio_backend.h8
-rw-r--r--libs/ardour/ardour/audioengine.h3
-rw-r--r--libs/ardour/ardour/graph.h3
-rw-r--r--libs/ardour/ardour/types.h11
-rw-r--r--libs/ardour/audioengine.cc10
-rw-r--r--libs/ardour/graph.cc12
-rw-r--r--libs/backends/jack/jack_audiobackend.cc8
-rw-r--r--libs/backends/jack/jack_audiobackend.h3
-rw-r--r--libs/backends/jack/jack_utils.cc7
-rw-r--r--libs/backends/jack/jack_utils.h2
10 files changed, 53 insertions, 14 deletions
diff --git a/libs/ardour/ardour/audio_backend.h b/libs/ardour/ardour/audio_backend.h
index ab37bea526..6c4a54da3e 100644
--- a/libs/ardour/ardour/audio_backend.h
+++ b/libs/ardour/ardour/audio_backend.h
@@ -399,7 +399,13 @@ class AudioBackend {
* stacksize. The thread will begin executing @param func, and will exit
* when that function returns.
*/
- virtual int create_process_thread (boost::function<void()> func, pthread_t*, size_t stacksize) = 0;
+ virtual int create_process_thread (boost::function<void()> func, AudioBackendNativeThread*, size_t stacksize) = 0;
+
+ /** Wait for the thread specified by @param thread to exit.
+ *
+ * Return zero on success, non-zero on failure.
+ */
+ virtual int wait_for_process_thread_exit (AudioBackendNativeThread thread) = 0;
virtual void update_latencies () = 0;
diff --git a/libs/ardour/ardour/audioengine.h b/libs/ardour/ardour/audioengine.h
index cf4f91d4d0..21206da8fc 100644
--- a/libs/ardour/ardour/audioengine.h
+++ b/libs/ardour/ardour/audioengine.h
@@ -100,7 +100,8 @@ public:
pframes_t sample_time_at_cycle_start ();
pframes_t samples_since_cycle_start ();
bool get_sync_offset (pframes_t& offset) const;
- int create_process_thread (boost::function<void()> func, pthread_t*, size_t stacksize);
+ int create_process_thread (boost::function<void()> func, AudioBackendNativeThread*, size_t stacksize);
+ int wait_for_process_thread_exit (AudioBackendNativeThread);
bool is_realtime() const;
bool connected() const;
diff --git a/libs/ardour/ardour/graph.h b/libs/ardour/ardour/graph.h
index cac09d34af..08af6fb721 100644
--- a/libs/ardour/ardour/graph.h
+++ b/libs/ardour/ardour/graph.h
@@ -36,6 +36,7 @@
#include "pbd/semutils.h"
#include "ardour/types.h"
+#include "ardour/audio_backend.h"
#include "ardour/session_handle.h"
namespace ARDOUR
@@ -92,7 +93,7 @@ protected:
virtual void session_going_away ();
private:
- std::list<pthread_t> _thread_list;
+ std::list<AudioBackendNativeThread> _thread_list;
volatile bool _quit_threads;
void reset_thread_list ();
diff --git a/libs/ardour/ardour/types.h b/libs/ardour/ardour/types.h
index 17bffc20e4..f2319d7669 100644
--- a/libs/ardour/ardour/types.h
+++ b/libs/ardour/ardour/types.h
@@ -26,6 +26,7 @@
#include <boost/shared_ptr.hpp>
#include <sys/types.h>
#include <stdint.h>
+#include <pthread.h>
#include <inttypes.h>
@@ -609,6 +610,16 @@ namespace ARDOUR {
uint32_t max; //< samples
};
+/* PLATFORM SPECIFIC #ifdef's here */
+
+ /** Define the native thread type used on the platform */
+ typedef pthread_t AudioBackendNativeThread;
+ static inline bool self_thread_equal (AudioBackendNativeThread thr) {
+ return pthread_equal (thr, pthread_self());
+ }
+
+/* PLATFORM SPECIFIC #endif's here */
+
} // namespace ARDOUR
diff --git a/libs/ardour/audioengine.cc b/libs/ardour/audioengine.cc
index 0ff8cd89ef..ded8bf39b5 100644
--- a/libs/ardour/audioengine.cc
+++ b/libs/ardour/audioengine.cc
@@ -814,7 +814,7 @@ AudioEngine::get_sync_offset (pframes_t& offset) const
}
int
-AudioEngine::create_process_thread (boost::function<void()> func, pthread_t* thr, size_t stacksize)
+AudioEngine::create_process_thread (boost::function<void()> func, AudioBackendNativeThread* thr, size_t stacksize)
{
if (!_backend) {
return -1;
@@ -822,6 +822,14 @@ AudioEngine::create_process_thread (boost::function<void()> func, pthread_t* thr
return _backend->create_process_thread (func, thr, stacksize);
}
+int
+AudioEngine::wait_for_process_thread_exit (AudioBackendNativeThread thr)
+{
+ if (!_backend) {
+ return 0;
+ }
+ return _backend->wait_for_process_thread_exit (thr);
+}
int
AudioEngine::set_device_name (const std::string& name)
diff --git a/libs/ardour/graph.cc b/libs/ardour/graph.cc
index 2425f8b6ef..50a66b6144 100644
--- a/libs/ardour/graph.cc
+++ b/libs/ardour/graph.cc
@@ -102,7 +102,7 @@ Graph::reset_thread_list ()
}
Glib::Threads::Mutex::Lock lm (_session.engine().process_lock());
- jack_native_thread_t a_thread;
+ AudioBackendNativeThread a_thread;
if (!_thread_list.empty()) {
drop_threads ();
@@ -147,8 +147,8 @@ Graph::drop_threads ()
_callback_start_sem.signal ();
- for (list<jack_native_thread_t>::iterator i = _thread_list.begin(); i != _thread_list.end(); ++i) {
- AudioEngine::instance()->stop_process_thread(*i);
+ for (list<AudioBackendNativeThread>::iterator i = _thread_list.begin(); i != _thread_list.end(); ++i) {
+ AudioEngine::instance()->wait_for_process_thread_exit (*i);
}
_thread_list.clear ();
@@ -584,12 +584,10 @@ Graph::process_one_route (Route* route)
bool
Graph::in_process_thread () const
{
-#ifndef COMPILER_MINGW
- for (list<pthread_t>::const_iterator i = _thread_list.begin (); i != _thread_list.end(); ++i) {
- if (pthread_equal(*i, pthread_self())) {
+ for (list<AudioBackendNativeThread>::const_iterator i = _thread_list.begin (); i != _thread_list.end(); ++i) {
+ if (self_thread_equal (*i)) {
return true;
}
}
-#endif
return false;
}
diff --git a/libs/backends/jack/jack_audiobackend.cc b/libs/backends/jack/jack_audiobackend.cc
index e004849896..89a93a76f6 100644
--- a/libs/backends/jack/jack_audiobackend.cc
+++ b/libs/backends/jack/jack_audiobackend.cc
@@ -789,6 +789,14 @@ JACKAudioBackend::create_process_thread (boost::function<void()> f, pthread_t* t
return 0;
}
+int
+JACKAudioBackend::wait_for_process_thread_exit (AudioBackendNativeThread thr)
+{
+ void* status;
+ /* this doesn't actively try to stop the thread, it just waits till it exits */
+ return pthread_join (thr, &status);
+}
+
void*
JACKAudioBackend::_start_process_thread (void* arg)
{
diff --git a/libs/backends/jack/jack_audiobackend.h b/libs/backends/jack/jack_audiobackend.h
index 1389e15c4a..61f1bbb602 100644
--- a/libs/backends/jack/jack_audiobackend.h
+++ b/libs/backends/jack/jack_audiobackend.h
@@ -100,7 +100,8 @@ class JACKAudioBackend : public AudioBackend {
size_t raw_buffer_size (DataType t);
- int create_process_thread (boost::function<void()> func, pthread_t*, size_t stacksize);
+ int create_process_thread (boost::function<void()> func, AudioBackendNativeThread*, size_t stacksize);
+ int wait_for_process_thread_exit (AudioBackendNativeThread);
void transport_start ();
void transport_stop ();
diff --git a/libs/backends/jack/jack_utils.cc b/libs/backends/jack/jack_utils.cc
index 77f3d95aa1..93fc3d440a 100644
--- a/libs/backends/jack/jack_utils.cc
+++ b/libs/backends/jack/jack_utils.cc
@@ -682,7 +682,7 @@ ARDOUR::JackCommandLineOptions::JackCommandLineOptions ()
}
bool
-ARDOUR::get_jack_command_line_string (const JackCommandLineOptions& options, string& command_line)
+ARDOUR::get_jack_command_line_string (JackCommandLineOptions& options, string& command_line)
{
vector<string> args;
@@ -699,6 +699,11 @@ ARDOUR::get_jack_command_line_string (const JackCommandLineOptions& options, str
}
#endif
+ /* XXX hack to enforce qjackctl-like behaviour */
+ if (options.timeout == 0) {
+ options.timeout = 200;
+ }
+
if (options.timeout) {
args.push_back ("-t");
args.push_back (to_string (options.timeout, std::dec));
diff --git a/libs/backends/jack/jack_utils.h b/libs/backends/jack/jack_utils.h
index 7565353198..a7521ad1c4 100644
--- a/libs/backends/jack/jack_utils.h
+++ b/libs/backends/jack/jack_utils.h
@@ -231,5 +231,5 @@ namespace ARDOUR {
/**
* @return true if able to build a valid command line based on options
*/
- bool get_jack_command_line_string (const JackCommandLineOptions& options, std::string& command_line);
+ bool get_jack_command_line_string (JackCommandLineOptions& options, std::string& command_line);
}