Commit b60b76de authored by sletz's avatar sletz
Browse files

Correct JackWinProcessSync.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4747 0c269be4-1314-0410-8aa9-9f06e86f4224
parent ef38cd34
......@@ -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;
......
......@@ -23,7 +23,7 @@
#include "JackCompilerDeps.h"
#include "JackException.h"
#include <windows.h>
#include <windows.h>
#include <stdio.h>
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()
......
......@@ -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
......
......@@ -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()
{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment