diff --git a/common/JackMessageBuffer.cpp b/common/JackMessageBuffer.cpp index 64382c66..fd5b5175 100644 --- a/common/JackMessageBuffer.cpp +++ b/common/JackMessageBuffer.cpp @@ -127,7 +127,7 @@ bool JackMessageBuffer::Create() if (fInstance == NULL) { fInstance = new JackMessageBuffer(); if (!fInstance->Start()) { - jack_error("JackMessageBuffer::Create cannot start thread..."); + jack_error("JackMessageBuffer::Create cannot start thread"); delete fInstance; fInstance = NULL; return false; diff --git a/windows/JackWinMutex.h b/windows/JackWinMutex.h index 8e40ec91..f8f1b552 100644 --- a/windows/JackWinMutex.h +++ b/windows/JackWinMutex.h @@ -23,7 +23,7 @@ #include "JackCompilerDeps.h" #include "JackException.h" -#include +#include #include namespace Jack @@ -46,7 +46,7 @@ class SERVER_EXPORT JackBaseWinMutex { // In recursive mode by default 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() @@ -75,6 +75,7 @@ class SERVER_EXPORT JackWinMutex char buffer[MAX_PATH]; snprintf(buffer, sizeof(buffer), "%s_%s", "JackWinMutex", name); fMutex = CreateMutex(NULL, FALSE, buffer); + ThrowIf((fMutex == 0), JackException("JackWinMutex: could not init the mutex")); } virtual ~JackWinMutex() diff --git a/windows/JackWinProcessSync.cpp b/windows/JackWinProcessSync.cpp index 40ff26d5..86b777ca 100644 --- a/windows/JackWinProcessSync.cpp +++ b/windows/JackWinProcessSync.cpp @@ -55,11 +55,15 @@ void JackWinProcessSync::LockedSignalAll() LockedSignal(); } -/* 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() @@ -70,8 +74,15 @@ void JackWinProcessSync::LockedWait() bool JackWinProcessSync::TimedWait(long usec) { - ReleaseMutex(fMutex); + if (!ReleaseMutex(fMutex)) { + jack_error("JackWinProcessSync::TimedWait ReleaseMutex err = %d", GetLastError()); + } + DWORD res = WaitForSingleObject(fEvent, usec / 1000); + if (res != WAIT_OBJECT_0) { + jack_error("JackWinProcessSync::TimedWait WaitForSingleObject err = %d", GetLastError()); + } + 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... return TimedWait(usec); } -*/ + +/* // Code from APPLE CAGuard.cpp : does not seem to work as expected... void JackWinProcessSync::Wait() @@ -144,7 +156,7 @@ bool JackWinProcessSync::LockedTimedWait(long usec) return (res == WAIT_OBJECT_0); } - +*/ } // end of namespace diff --git a/windows/JackWinProcessSync.h b/windows/JackWinProcessSync.h index cdc94f7b..25cb4ec3 100644 --- a/windows/JackWinProcessSync.h +++ b/windows/JackWinProcessSync.h @@ -41,10 +41,11 @@ class JackWinProcessSync : public JackWinMutex JackWinProcessSync(const char* name = NULL):JackWinMutex() { - //fEvent = CreateEvent(NULL, FALSE, FALSE, NULL); char buffer[MAX_PATH]; 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() {