git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@2548 0c269be4-1314-0410-8aa9-9f06e86f4224tags/1.90
@@ -21,6 +21,10 @@ Romain Moret | |||||
Jackdmp changes log | Jackdmp changes log | ||||
--------------------------- | --------------------------- | ||||
2008-06-20 Stephane Letz <letz@grame.fr> | |||||
* Add new jack_client_stop_thread and jack_client_kill_thread API. | |||||
2008-06-19 Stephane Letz <letz@grame.fr> | 2008-06-19 Stephane Letz <letz@grame.fr> | ||||
* Embed JackEngineControl in JackDriver (starting from Tim Blechmann idea). | * Embed JackEngineControl in JackDriver (starting from Tim Blechmann idea). | ||||
@@ -222,6 +222,9 @@ extern "C" | |||||
void *(*start_routine)(void*), | void *(*start_routine)(void*), | ||||
void *arg); | void *arg); | ||||
EXPORT int jack_drop_real_time_scheduling (pthread_t thread); | EXPORT int jack_drop_real_time_scheduling (pthread_t thread); | ||||
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 char * jack_get_internal_client_name (jack_client_t *client, | EXPORT char * jack_get_internal_client_name (jack_client_t *client, | ||||
jack_intclient_t intclient); | jack_intclient_t intclient); | ||||
@@ -1613,6 +1616,24 @@ EXPORT int jack_drop_real_time_scheduling(pthread_t thread) | |||||
#endif | #endif | ||||
} | } | ||||
EXPORT int jack_client_stop_thread(jack_client_t* client, pthread_t thread) | |||||
{ | |||||
#ifdef WIN32 | |||||
return JackWinThread::StopImp(thread); | |||||
#else | |||||
return JackPosixThread::StopImp(thread); | |||||
#endif | |||||
} | |||||
EXPORT int jack_client_kill_thread(jack_client_t* client, pthread_t thread) | |||||
{ | |||||
#ifdef WIN32 | |||||
return JackWinThread::KillImp(thread); | |||||
#else | |||||
return JackPosixThread::KillImp(thread); | |||||
#endif | |||||
} | |||||
// intclient.h | // intclient.h | ||||
EXPORT int jack_internal_client_new (const char *client_name, | EXPORT int jack_internal_client_new (const char *client_name, | ||||
const char *load_name, | const char *load_name, | ||||
@@ -177,6 +177,31 @@ int JackPosixThread::Stop() | |||||
} | } | ||||
} | } | ||||
int JackPosixThread::KillImp(pthread_t thread) | |||||
{ | |||||
if (thread != (pthread_t)NULL) { // If thread has been started | |||||
jack_log("JackPosixThread::Kill"); | |||||
void* status; | |||||
pthread_cancel(thread); | |||||
pthread_join(thread, &status); | |||||
return 0; | |||||
} else { | |||||
return -1; | |||||
} | |||||
} | |||||
int JackPosixThread::StopImp(pthread_t thread) | |||||
{ | |||||
if (thread != (pthread_t)NULL) { // If thread has been started | |||||
jack_log("JackPosixThread::Stop"); | |||||
void* status; | |||||
pthread_join(thread, &status); | |||||
return 0; | |||||
} else { | |||||
return -1; | |||||
} | |||||
} | |||||
int JackPosixThread::AcquireRealTime() | int JackPosixThread::AcquireRealTime() | ||||
{ | { | ||||
return (fThread != (pthread_t)NULL) ? AcquireRealTimeImp(fThread, fPriority) : -1; | return (fThread != (pthread_t)NULL) ? AcquireRealTimeImp(fThread, fPriority) : -1; | ||||
@@ -67,6 +67,8 @@ class EXPORT JackPosixThread : public detail::JackThread | |||||
static int AcquireRealTimeImp(pthread_t thread, int priority); | static int AcquireRealTimeImp(pthread_t thread, int priority); | ||||
static int DropRealTimeImp(pthread_t thread); | static int DropRealTimeImp(pthread_t thread); | ||||
static int StartImp(pthread_t* thread, int priority, int realtime, void*(*start_routine)(void*), void* arg); | static int StartImp(pthread_t* thread, int priority, int realtime, void*(*start_routine)(void*), void* arg); | ||||
static int StopImp(pthread_t thread); | |||||
static int KillImp(pthread_t thread); | |||||
}; | }; | ||||
@@ -83,6 +83,24 @@ extern "C" | |||||
* @returns 0, if successful; otherwise an error number. | * @returns 0, if successful; otherwise an error number. | ||||
*/ | */ | ||||
int jack_drop_real_time_scheduling (pthread_t thread); | int jack_drop_real_time_scheduling (pthread_t thread); | ||||
/** | |||||
* Stop the thread, waiting for the thread handler to terminate. | |||||
* | |||||
* @param thread POSIX thread ID. | |||||
* | |||||
* @returns 0, if successful; otherwise an error number. | |||||
*/ | |||||
int jack_client_stop_thread(jack_client_t* client, pthread_t thread); | |||||
/** | |||||
* Cancel the thread then waits for the thread handler to terminate. | |||||
* | |||||
* @param thread POSIX thread ID. | |||||
* | |||||
* @returns 0, if successful; otherwise an error number. | |||||
*/ | |||||
int jack_client_kill_thread(jack_client_t* client, pthread_t thread); | |||||
#ifdef __cplusplus | #ifdef __cplusplus | ||||
} | } | ||||
@@ -157,6 +157,29 @@ int JackWinThread::Stop() | |||||
} | } | ||||
} | } | ||||
int JackWinThread::KillImp(pthread_t thread) | |||||
{ | |||||
if (thread) { // If thread has been started | |||||
TerminateThread(thread, 0); | |||||
WaitForSingleObject(thread, INFINITE); | |||||
CloseHandle(thread); | |||||
return 0; | |||||
} else { | |||||
return -1; | |||||
} | |||||
} | |||||
int JackWinThread::StopImp(pthread_t thread) | |||||
{ | |||||
if (thread) { // If thread has been started | |||||
WaitForSingleObject(thread, INFINITE); | |||||
CloseHandle(thread); | |||||
return 0; | |||||
} else { | |||||
return -1; | |||||
} | |||||
} | |||||
int JackWinThread::AcquireRealTime() | int JackWinThread::AcquireRealTime() | ||||
{ | { | ||||
return (fThread) ? AcquireRealTimeImp(fThread, fPriority) : -1; | return (fThread) ? AcquireRealTimeImp(fThread, fPriority) : -1; | ||||
@@ -65,6 +65,8 @@ class EXPORT JackWinThread : public detail::JackThread | |||||
static int AcquireRealTimeImp(pthread_t thread, int priority); | static int AcquireRealTimeImp(pthread_t thread, int priority); | ||||
static int DropRealTimeImp(pthread_t thread); | static int DropRealTimeImp(pthread_t thread); | ||||
static int StartImp(pthread_t* thread, int priority, int realtime, ThreadCallback start_routine, void* arg); | static int StartImp(pthread_t* thread, int priority, int realtime, ThreadCallback start_routine, void* arg); | ||||
static int StopImp(pthread_t thread); | |||||
static int KillImp(pthread_t thread); | |||||
}; | }; | ||||