git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@2359 0c269be4-1314-0410-8aa9-9f06e86f4224tags/1.90
| @@ -36,9 +36,11 @@ void* JackPosixThread::ThreadHandler(void* arg) | |||||
| jack_error("pthread_setcanceltype err = %s", strerror(err)); | jack_error("pthread_setcanceltype err = %s", strerror(err)); | ||||
| } | } | ||||
| set_threaded_log_function(); | |||||
| // Signal creation thread when started with StartSync | // Signal creation thread when started with StartSync | ||||
| jack_log("ThreadHandler: start"); | jack_log("ThreadHandler: start"); | ||||
| obj->fStatus = kRunning; | |||||
| obj->fStatus = kIniting; | |||||
| // Call Init method | // Call Init method | ||||
| if (!runnable->Init()) { | if (!runnable->Init()) { | ||||
| @@ -46,6 +48,8 @@ void* JackPosixThread::ThreadHandler(void* arg) | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| obj->fStatus = kRunning; | |||||
| // If Init succeed, start the thread loop | // If Init succeed, start the thread loop | ||||
| bool res = true; | bool res = true; | ||||
| while (obj->fStatus == kRunning && res) { | while (obj->fStatus == kRunning && res) { | ||||
| @@ -78,7 +82,7 @@ int JackPosixThread::StartSync() | |||||
| return -1; | return -1; | ||||
| } else { | } else { | ||||
| int count = 0; | int count = 0; | ||||
| while (fStatus != kRunning && ++count < 1000) { | |||||
| while (fStatus == kStarting && ++count < 1000) { | |||||
| JackSleep(1000); | JackSleep(1000); | ||||
| } | } | ||||
| return (count == 1000) ? -1 : 0; | return (count == 1000) ? -1 : 0; | ||||
| @@ -62,7 +62,7 @@ class JackThread | |||||
| { | { | ||||
| public: | public: | ||||
| enum kThreadState {kIdle, kStarting, kRunning}; | |||||
| enum kThreadState {kIdle, kStarting, kIniting, kRunning}; | |||||
| protected: | protected: | ||||
| @@ -68,6 +68,7 @@ int JackThreadedDriver::Stop() | |||||
| // Kill the thread in Init phase | // Kill the thread in Init phase | ||||
| case JackThread::kStarting: | case JackThread::kStarting: | ||||
| case JackThread::kIniting: | |||||
| if (fThread->Kill() < 0) { | if (fThread->Kill() < 0) { | ||||
| jack_error("Cannot kill thread"); | jack_error("Cannot kill thread"); | ||||
| return -1; | return -1; | ||||
| @@ -31,9 +31,11 @@ DWORD WINAPI JackWinThread::ThreadHandler(void* arg) | |||||
| JackWinThread* obj = (JackWinThread*)arg; | JackWinThread* obj = (JackWinThread*)arg; | ||||
| JackRunnableInterface* runnable = obj->fRunnable; | JackRunnableInterface* runnable = obj->fRunnable; | ||||
| set_threaded_log_function(); | |||||
| // Signal creation thread when started with StartSync | // Signal creation thread when started with StartSync | ||||
| jack_log("ThreadHandler: start"); | jack_log("ThreadHandler: start"); | ||||
| obj->fStatus = kRunning; | |||||
| obj->fStatus = kIniting; | |||||
| // Call Init method | // Call Init method | ||||
| if (!runnable->Init()) { | if (!runnable->Init()) { | ||||
| @@ -41,6 +43,8 @@ DWORD WINAPI JackWinThread::ThreadHandler(void* arg) | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| obj->fStatus = kRunning; | |||||
| // If Init succeed, start the thread loop | // If Init succeed, start the thread loop | ||||
| bool res = true; | bool res = true; | ||||
| while (obj->fStatus == kRunning && res) { | while (obj->fStatus == kRunning && res) { | ||||
| @@ -87,7 +91,7 @@ int JackWinThread::StartSync() | |||||
| return -1; | return -1; | ||||
| } else { | } else { | ||||
| int count = 0; | int count = 0; | ||||
| while (fStatus != kRunning && ++count < 1000) { | |||||
| while (fStatus == kStarting && ++count < 1000) { | |||||
| JackSleep(1000); | JackSleep(1000); | ||||
| } | } | ||||
| return (count == 1000) ? -1 : 0; | return (count == 1000) ? -1 : 0; | ||||