Browse Source

Correct thread init phase

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@2359 0c269be4-1314-0410-8aa9-9f06e86f4224
tags/1.90
sletz 17 years ago
parent
commit
d7470105d7
4 changed files with 14 additions and 5 deletions
  1. +6
    -2
      common/JackPosixThread.cpp
  2. +1
    -1
      common/JackThread.h
  3. +1
    -0
      common/JackThreadedDriver.cpp
  4. +6
    -2
      windows/JackWinThread.cpp

+ 6
- 2
common/JackPosixThread.cpp View File

@@ -36,9 +36,11 @@ void* JackPosixThread::ThreadHandler(void* arg)
jack_error("pthread_setcanceltype err = %s", strerror(err));
}
set_threaded_log_function();
// Signal creation thread when started with StartSync
jack_log("ThreadHandler: start");
obj->fStatus = kRunning;
obj->fStatus = kIniting;
// Call Init method
if (!runnable->Init()) {
@@ -46,6 +48,8 @@ void* JackPosixThread::ThreadHandler(void* arg)
return 0;
}
obj->fStatus = kRunning;
// If Init succeed, start the thread loop
bool res = true;
while (obj->fStatus == kRunning && res) {
@@ -78,7 +82,7 @@ int JackPosixThread::StartSync()
return -1;
} else {
int count = 0;
while (fStatus != kRunning && ++count < 1000) {
while (fStatus == kStarting && ++count < 1000) {
JackSleep(1000);
}
return (count == 1000) ? -1 : 0;


+ 1
- 1
common/JackThread.h View File

@@ -62,7 +62,7 @@ class JackThread
{
public:
enum kThreadState {kIdle, kStarting, kRunning};
enum kThreadState {kIdle, kStarting, kIniting, kRunning};
protected:


+ 1
- 0
common/JackThreadedDriver.cpp View File

@@ -68,6 +68,7 @@ int JackThreadedDriver::Stop()
// Kill the thread in Init phase
case JackThread::kStarting:
case JackThread::kIniting:
if (fThread->Kill() < 0) {
jack_error("Cannot kill thread");
return -1;


+ 6
- 2
windows/JackWinThread.cpp View File

@@ -31,9 +31,11 @@ DWORD WINAPI JackWinThread::ThreadHandler(void* arg)
JackWinThread* obj = (JackWinThread*)arg;
JackRunnableInterface* runnable = obj->fRunnable;

set_threaded_log_function();
// Signal creation thread when started with StartSync
jack_log("ThreadHandler: start");
obj->fStatus = kRunning;
obj->fStatus = kIniting;
// Call Init method
if (!runnable->Init()) {
@@ -41,6 +43,8 @@ DWORD WINAPI JackWinThread::ThreadHandler(void* arg)
return 0;
}
obj->fStatus = kRunning;
// If Init succeed, start the thread loop
bool res = true;
while (obj->fStatus == kRunning && res) {
@@ -87,7 +91,7 @@ int JackWinThread::StartSync()
return -1;
} else {
int count = 0;
while (fStatus != kRunning && ++count < 1000) {
while (fStatus == kStarting && ++count < 1000) {
JackSleep(1000);
}
return (count == 1000) ? -1 : 0;


Loading…
Cancel
Save