13
0

Use jack_native_thread_t for portability

Requires future attention in AudioEngine due to timbyr's use JACK2 extension to JACK API
This commit is contained in:
Paul Davis 2013-07-11 15:08:10 -04:00
parent a69847b671
commit fa2dcea820
4 changed files with 29 additions and 7 deletions

View File

@ -258,7 +258,8 @@ _ the regular process() call to session->process() is not made.
static void destroy();
void died ();
int create_process_thread (boost::function<void()>, pthread_t*, size_t stacksize);
int create_process_thread (boost::function<void()>, jack_native_thread_t*, size_t stacksize);
bool stop_process_thread (jack_native_thread_t);
private:
static AudioEngine* _instance;

View File

@ -92,7 +92,7 @@ protected:
virtual void session_going_away ();
private:
std::list<pthread_t> _thread_list;
std::list<jack_native_thread_t> _thread_list;
volatile bool _quit_threads;
void reset_thread_list ();

View File

@ -1548,7 +1548,7 @@ AudioEngine::is_realtime () const
}
int
AudioEngine::create_process_thread (boost::function<void()> f, pthread_t* thread, size_t stacksize)
AudioEngine::create_process_thread (boost::function<void()> f, jack_native_thread_t* thread, size_t stacksize)
{
GET_PRIVATE_JACK_POINTER_RET (_jack, 0);
ThreadData* td = new ThreadData (this, f, stacksize);
@ -1561,6 +1561,28 @@ AudioEngine::create_process_thread (boost::function<void()> f, pthread_t* thread
return 0;
}
bool
AudioEngine::stop_process_thread (jack_native_thread_t thread)
{
/**
* can't use GET_PRIVATE_JACK_POINTER_RET (_jack, 0) here
* because _jack is 0 when this is called. At least for
* Jack 2 _jack arg is not used so it should be OK
*/
#ifdef USING_JACK2_EXPANSION_OF_JACK_API
if (jack_client_stop_thread (_jack, thread) != 0) {
error << "AudioEngine: cannot stop process thread" << endmsg;
return false;
}
#else
void* status;
pthread_join (thread, &status);
#endif
return true;
}
void*
AudioEngine::_start_process_thread (void* arg)
{

View File

@ -101,7 +101,7 @@ Graph::reset_thread_list ()
}
Glib::Threads::Mutex::Lock lm (_session.engine().process_lock());
pthread_t a_thread;
jack_native_thread_t 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<jack_native_thread_t>::iterator i = _thread_list.begin(); i != _thread_list.end(); ++i) {
AudioEngine::instance()->stop_process_thread(*i);
}
_thread_list.clear ();