Browse Source

Virtualize and allow overriding of thread creation function, to allow Wine support (from JACK1).

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@3437 0c269be4-1314-0410-8aa9-9f06e86f4224
tags/1.9.2
sletz 17 years ago
parent
commit
4086b3ca90
7 changed files with 40 additions and 1 deletions
  1. +4
    -0
      ChangeLog
  2. +6
    -0
      common/JackAPI.cpp
  3. +2
    -0
      common/JackGlobals.cpp
  4. +1
    -0
      common/JackGlobals.h
  5. +23
    -0
      common/jack/thread.h
  6. +2
    -1
      posix/JackPosixThread.cpp
  7. +2
    -0
      posix/JackTypes_os.h

+ 4
- 0
ChangeLog View File

@@ -24,6 +24,10 @@ Torben Hohn
Jackdmp changes log
---------------------------

2009-03-12 Stephane Letz <letz@grame.fr>
* Virtualize and allow overriding of thread creation function, to allow Wine support (from JACK1).

2009-03-12 Stephane Letz <letz@grame.fr>
* Try automatic adaptative mode in adapters.


+ 6
- 0
common/JackAPI.cpp View File

@@ -222,6 +222,7 @@ extern "C"
EXPORT int jack_client_stop_thread (jack_client_t* client, pthread_t thread);
EXPORT int jack_client_kill_thread (jack_client_t* client, pthread_t thread);
EXPORT void jack_set_thread_creator (jack_thread_creator_t jtc);

EXPORT char * jack_get_internal_client_name (jack_client_t *client,
jack_intclient_t intclient);
@@ -1792,6 +1793,11 @@ EXPORT int jack_client_kill_thread(jack_client_t* client, pthread_t thread)
return JackThread::KillImp(thread);
}

EXPORT void jack_set_thread_creator (jack_thread_creator_t jtc)
{
JackGlobals::fJackThreadCreator = jtc;
}

// intclient.h
EXPORT int jack_internal_client_new (const char *client_name,
const char *load_name,


+ 2
- 0
common/JackGlobals.cpp View File

@@ -32,4 +32,6 @@ JackMutex* JackGlobals::fOpenMutex = new JackMutex();
bool JackGlobals::fServerRunning = false;
JackClient* JackGlobals::fClientTable[CLIENT_NUM] = {};

jack_thread_creator_t JackGlobals::fJackThreadCreator = pthread_create;

} // end of namespace

+ 1
- 0
common/JackGlobals.h View File

@@ -36,6 +36,7 @@ struct JackGlobals {
static JackMutex* fOpenMutex;
static bool fServerRunning;
static JackClient* fClientTable[];
static jack_thread_creator_t fJackThreadCreator;
};



+ 23
- 0
common/jack/thread.h View File

@@ -117,6 +117,29 @@ int jack_client_stop_thread(jack_client_t* client, pthread_t thread);
*/
int jack_client_kill_thread(jack_client_t* client, 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


+ 2
- 1
posix/JackPosixThread.cpp View File

@@ -21,6 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "JackPosixThread.h"
#include "JackError.h"
#include "JackTime.h"
#include "JackGlobals.h"
#include <string.h> // for memset
#include <unistd.h> // for _POSIX_PRIORITY_SCHEDULING check

@@ -139,7 +140,7 @@ int JackPosixThread::StartImp(pthread_t* thread, int priority, int realtime, voi
return -1;
}

if ((res = pthread_create(thread, &attributes, start_routine, arg))) {
if ((res = JackGlobals::fJackThreadCreator(thread, &attributes, start_routine, arg))) {
jack_error("Cannot create thread res = %d err = %s", res, strerror(errno));
return -1;
}


+ 2
- 0
posix/JackTypes_os.h View File

@@ -26,4 +26,6 @@
typedef unsigned long long UInt64;
typedef pthread_key_t jack_tls_key;

typedef int (*jack_thread_creator_t)(pthread_t*, const pthread_attr_t*, void* (*function)(void*), void* arg);

#endif

Loading…
Cancel
Save