Browse Source

"virtualize" and allow overriding of thread creation function, to allow Wine support

git-svn-id: svn+ssh://jackaudio.org/trunk/jack@3432 0c269be4-1314-0410-8aa9-9f06e86f4224
tags/0.117.0
paul 16 years ago
parent
commit
f862adb799
3 changed files with 35 additions and 4 deletions
  1. +23
    -0
      jack/thread.h
  2. +1
    -1
      libjack/messagebuffer.c
  3. +11
    -3
      libjack/thread.c

+ 23
- 0
jack/thread.h View File

@@ -102,6 +102,29 @@ int jack_client_create_thread (jack_client_t* client,
*/
int jack_drop_real_time_scheduling (pthread_t thread);

typedef int (*jack_thread_creator_t)(pthread_t*,
const pthread_attr_t*,
void* (*function)(void*),
void* arg);
/**
* This function can be used in very very specialized cases
* where it is necessary that client threads created by JACK
* are created by something other than pthread_create(). After
* it is used, any threads that JACK needs for the client will
* will be created by calling the function passed to this
* function.
*
* No normal application/client should consider calling this.
* The specific case for which it was created involves running
* win32/x86 plugins under Wine on Linux, where it is necessary
* that all threads that might call win32 functions are known
* to Wine.
*
* @param creator a function that creates a new thread
*
*/
void jack_set_thread_creator (jack_thread_creator_t creator);

/* @} */

#ifdef __cplusplus


+ 1
- 1
libjack/messagebuffer.c View File

@@ -92,7 +92,7 @@ jack_messagebuffer_init ()
mb_overruns = 0;
mb_initialized = 1;

if (pthread_create(&mb_writer_thread, NULL, &mb_thread_func, NULL) != 0)
if (jack_thread_creator (&mb_writer_thread, NULL, &mb_thread_func, NULL) != 0)
mb_initialized = 0;
}



+ 11
- 3
libjack/thread.c View File

@@ -39,6 +39,14 @@
#include <sysdeps/pThreadUtilities.h>
#endif

jack_thread_creator_t jack_thread_creator = pthread_create;

void
jack_set_thread_creator (jack_thread_creator_t jtc)
{
jack_thread_creator = jtc;
}

static inline void
log_result (char *msg, int res)
{
@@ -126,7 +134,7 @@ jack_client_create_thread (jack_client_t* client,
int result = 0;

if (!realtime) {
result = pthread_create (thread, 0, start_routine, arg);
result = jack_thread_creator (thread, 0, start_routine, arg);
if (result) {
log_result("creating thread with default parameters",
result);
@@ -176,7 +184,7 @@ jack_client_create_thread (jack_client_t* client,
thread_args->realtime = 1;
thread_args->priority = priority;

result = pthread_create (thread, &attr, jack_thread_proxy, thread_args);
result = jack_thread_creator (thread, &attr, jack_thread_proxy, thread_args);
if (result) {
log_result ("creating realtime thread", result);
return result;
@@ -184,7 +192,7 @@ jack_client_create_thread (jack_client_t* client,

#else /* JACK_USE_MACH_THREADS */

result = pthread_create (thread, 0, start_routine, arg);
result = jack_thread_creator (thread, 0, start_routine, arg);
if (result) {
log_result ("creating realtime thread", result);
return result;


Loading…
Cancel
Save