Browse Source

Correct JackWinProcessSync.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4747 0c269be4-1314-0410-8aa9-9f06e86f4224
tags/1.9.9.5
sletz 13 years ago
parent
commit
b60b76de29
4 changed files with 25 additions and 11 deletions
  1. +1
    -1
      common/JackMessageBuffer.cpp
  2. +3
    -2
      windows/JackWinMutex.h
  3. +18
    -6
      windows/JackWinProcessSync.cpp
  4. +3
    -2
      windows/JackWinProcessSync.h

+ 1
- 1
common/JackMessageBuffer.cpp View File

@@ -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;


+ 3
- 2
windows/JackWinMutex.h View File

@@ -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()


+ 18
- 6
windows/JackWinProcessSync.cpp View File

@@ -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



+ 3
- 2
windows/JackWinProcessSync.h View File

@@ -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()
{


Loading…
Cancel
Save