add AudioBackendNativeThread to serve the same role as jack_native_thread_t
This commit is contained in:
parent
9f2ab81df6
commit
4df3666738
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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 ();
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
@ -816,7 +816,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;
|
||||
@ -824,6 +824,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)
|
||||
|
@ -101,7 +101,7 @@ Graph::reset_thread_list ()
|
||||
}
|
||||
|
||||
Glib::Threads::Mutex::Lock lm (_session.engine().process_lock());
|
||||
pthread_t a_thread;
|
||||
AudioBackendNativeThread a_thread;
|
||||
|
||||
if (!_thread_list.empty()) {
|
||||
drop_threads ();
|
||||
@ -146,9 +146,8 @@ Graph::drop_threads ()
|
||||
|
||||
_callback_start_sem.signal ();
|
||||
|
||||
for (list<pthread_t>::iterator i = _thread_list.begin(); i != _thread_list.end(); ++i) {
|
||||
void* status;
|
||||
pthread_join (*i, &status);
|
||||
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,8 +583,8 @@ Graph::process_one_route (Route* route)
|
||||
bool
|
||||
Graph::in_process_thread () const
|
||||
{
|
||||
for (list<pthread_t>::const_iterator i = _thread_list.begin (); i != _thread_list.end(); ++i) {
|
||||
if (*i == pthread_self()) {
|
||||
for (list<AudioBackendNativeThread>::const_iterator i = _thread_list.begin (); i != _thread_list.end(); ++i) {
|
||||
if (self_thread_equal (*i)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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 ();
|
||||
|
Loading…
Reference in New Issue
Block a user