Commit 4086b3ca authored by sletz's avatar sletz
Browse files

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
parent 3ee6e1f1
......@@ -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.
......
......@@ -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,
......
......@@ -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
......@@ -36,6 +36,7 @@ struct JackGlobals {
static JackMutex* fOpenMutex;
static bool fServerRunning;
static JackClient* fClientTable[];
static jack_thread_creator_t fJackThreadCreator;
};
......
......@@ -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
......
......@@ -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;
}
......
......@@ -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
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment