git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4747 0c269be4-1314-0410-8aa9-9f06e86f4224tags/1.9.9.5
| @@ -127,7 +127,7 @@ bool JackMessageBuffer::Create() | |||||
| if (fInstance == NULL) { | if (fInstance == NULL) { | ||||
| fInstance = new JackMessageBuffer(); | fInstance = new JackMessageBuffer(); | ||||
| if (!fInstance->Start()) { | if (!fInstance->Start()) { | ||||
| jack_error("JackMessageBuffer::Create cannot start thread..."); | |||||
| jack_error("JackMessageBuffer::Create cannot start thread"); | |||||
| delete fInstance; | delete fInstance; | ||||
| fInstance = NULL; | fInstance = NULL; | ||||
| return false; | return false; | ||||
| @@ -23,7 +23,7 @@ | |||||
| #include "JackCompilerDeps.h" | #include "JackCompilerDeps.h" | ||||
| #include "JackException.h" | #include "JackException.h" | ||||
| #include <windows.h> | |||||
| #include <windows.h> | |||||
| #include <stdio.h> | #include <stdio.h> | ||||
| namespace Jack | namespace Jack | ||||
| @@ -46,7 +46,7 @@ class SERVER_EXPORT JackBaseWinMutex | |||||
| { | { | ||||
| // In recursive mode by default | // In recursive mode by default | ||||
| fMutex = CreateMutex(NULL, FALSE, NULL); | fMutex = CreateMutex(NULL, FALSE, NULL); | ||||
| ThrowIf(fMutex == 0, JackException("JackWinMutex: could not init the mutex")); | |||||
| ThrowIf((fMutex == 0), JackException("JackBaseWinMutex: could not init the mutex")); | |||||
| } | } | ||||
| virtual ~JackBaseWinMutex() | virtual ~JackBaseWinMutex() | ||||
| @@ -75,6 +75,7 @@ class SERVER_EXPORT JackWinMutex | |||||
| char buffer[MAX_PATH]; | char buffer[MAX_PATH]; | ||||
| snprintf(buffer, sizeof(buffer), "%s_%s", "JackWinMutex", name); | snprintf(buffer, sizeof(buffer), "%s_%s", "JackWinMutex", name); | ||||
| fMutex = CreateMutex(NULL, FALSE, buffer); | fMutex = CreateMutex(NULL, FALSE, buffer); | ||||
| ThrowIf((fMutex == 0), JackException("JackWinMutex: could not init the mutex")); | |||||
| } | } | ||||
| virtual ~JackWinMutex() | virtual ~JackWinMutex() | ||||
| @@ -55,11 +55,15 @@ void JackWinProcessSync::LockedSignalAll() | |||||
| LockedSignal(); | LockedSignal(); | ||||
| } | } | ||||
| /* | |||||
| void JackWinProcessSync::Wait() | void JackWinProcessSync::Wait() | ||||
| { | { | ||||
| ReleaseMutex(fMutex); | |||||
| WaitForSingleObject(fEvent, INFINITE); | |||||
| if (!ReleaseMutex(fMutex)) { | |||||
| jack_error("JackWinProcessSync::Wait ReleaseMutex err = %d", GetLastError()); | |||||
| } | |||||
| DWORD res = WaitForSingleObject(fEvent, INFINITE); | |||||
| if (res != WAIT_OBJECT_0) { | |||||
| jack_error("JackWinProcessSync::Wait WaitForSingleObject err = %d", GetLastError()); | |||||
| } | |||||
| } | } | ||||
| void JackWinProcessSync::LockedWait() | void JackWinProcessSync::LockedWait() | ||||
| @@ -70,8 +74,15 @@ void JackWinProcessSync::LockedWait() | |||||
| bool JackWinProcessSync::TimedWait(long usec) | bool JackWinProcessSync::TimedWait(long usec) | ||||
| { | { | ||||
| ReleaseMutex(fMutex); | |||||
| if (!ReleaseMutex(fMutex)) { | |||||
| jack_error("JackWinProcessSync::TimedWait ReleaseMutex err = %d", GetLastError()); | |||||
| } | |||||
| DWORD res = WaitForSingleObject(fEvent, usec / 1000); | DWORD res = WaitForSingleObject(fEvent, usec / 1000); | ||||
| if (res != WAIT_OBJECT_0) { | |||||
| jack_error("JackWinProcessSync::TimedWait WaitForSingleObject err = %d", GetLastError()); | |||||
| } | |||||
| return (res == WAIT_OBJECT_0); | return (res == WAIT_OBJECT_0); | ||||
| } | } | ||||
| @@ -80,8 +91,9 @@ bool JackWinProcessSync::LockedTimedWait(long usec) | |||||
| // Does it make sense on Windows, use non-locked version for now... | // Does it make sense on Windows, use non-locked version for now... | ||||
| return TimedWait(usec); | return TimedWait(usec); | ||||
| } | } | ||||
| */ | |||||
| /* | |||||
| // Code from APPLE CAGuard.cpp : does not seem to work as expected... | // Code from APPLE CAGuard.cpp : does not seem to work as expected... | ||||
| void JackWinProcessSync::Wait() | void JackWinProcessSync::Wait() | ||||
| @@ -144,7 +156,7 @@ bool JackWinProcessSync::LockedTimedWait(long usec) | |||||
| return (res == WAIT_OBJECT_0); | return (res == WAIT_OBJECT_0); | ||||
| } | } | ||||
| */ | |||||
| } // end of namespace | } // end of namespace | ||||
| @@ -41,10 +41,11 @@ class JackWinProcessSync : public JackWinMutex | |||||
| JackWinProcessSync(const char* name = NULL):JackWinMutex() | JackWinProcessSync(const char* name = NULL):JackWinMutex() | ||||
| { | { | ||||
| //fEvent = CreateEvent(NULL, FALSE, FALSE, NULL); | |||||
| char buffer[MAX_PATH]; | char buffer[MAX_PATH]; | ||||
| snprintf(buffer, sizeof(buffer), "%s_%s", "WinProcessSync", name); | snprintf(buffer, sizeof(buffer), "%s_%s", "WinProcessSync", name); | ||||
| fEvent = CreateEvent(NULL, TRUE, FALSE, buffer); // Needs ResetEvent | |||||
| //fEvent = CreateEvent(NULL, TRUE, FALSE, buffer); // Needs ResetEvent | |||||
| fEvent = CreateEvent(NULL, FALSE, FALSE, NULL); // Audo-reset event | |||||
| ThrowIf((fEvent == 0), JackException("JackWinProcessSync: could not init the event")); | |||||
| } | } | ||||
| virtual ~JackWinProcessSync() | virtual ~JackWinProcessSync() | ||||
| { | { | ||||