Browse Source

Add new jack_client_stop_thread and jack_client_kill_thread API.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@2548 0c269be4-1314-0410-8aa9-9f06e86f4224
tags/1.90
sletz 17 years ago
parent
commit
8b5911a983
7 changed files with 95 additions and 0 deletions
  1. +4
    -0
      ChangeLog
  2. +21
    -0
      common/JackAPI.cpp
  3. +25
    -0
      common/JackPosixThread.cpp
  4. +2
    -0
      common/JackPosixThread.h
  5. +18
    -0
      common/jack/thread.h
  6. +23
    -0
      windows/JackWinThread.cpp
  7. +2
    -0
      windows/JackWinThread.h

+ 4
- 0
ChangeLog View File

@@ -21,6 +21,10 @@ Romain Moret
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>

* Embed JackEngineControl in JackDriver (starting from Tim Blechmann idea).


+ 21
- 0
common/JackAPI.cpp View File

@@ -222,6 +222,9 @@ extern "C"
void *(*start_routine)(void*),
void *arg);
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,
jack_intclient_t intclient);
@@ -1613,6 +1616,24 @@ EXPORT int jack_drop_real_time_scheduling(pthread_t thread)
#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
EXPORT int jack_internal_client_new (const char *client_name,
const char *load_name,


+ 25
- 0
common/JackPosixThread.cpp View File

@@ -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()
{
return (fThread != (pthread_t)NULL) ? AcquireRealTimeImp(fThread, fPriority) : -1;


+ 2
- 0
common/JackPosixThread.h View File

@@ -67,6 +67,8 @@ class EXPORT JackPosixThread : public detail::JackThread
static int AcquireRealTimeImp(pthread_t thread, int priority);
static int DropRealTimeImp(pthread_t thread);
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);

};



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

@@ -83,6 +83,24 @@ extern "C"
* @returns 0, if successful; otherwise an error number.
*/
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
}


+ 23
- 0
windows/JackWinThread.cpp View File

@@ -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()
{
return (fThread) ? AcquireRealTimeImp(fThread, fPriority) : -1;


+ 2
- 0
windows/JackWinThread.h View File

@@ -65,6 +65,8 @@ class EXPORT JackWinThread : public detail::JackThread
static int AcquireRealTimeImp(pthread_t thread, int priority);
static int DropRealTimeImp(pthread_t thread);
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);

};



Loading…
Cancel
Save