Browse Source

Works again on Windows.

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

+ 3
- 3
common/JackMessageBuffer.cpp View File

@@ -32,7 +32,7 @@ JackMessageBuffer::JackMessageBuffer()
:fInit(NULL), :fInit(NULL),
fInitArg(NULL), fInitArg(NULL),
fThread(this), fThread(this),
fGuard("JackMessageBuffer"),
fGuard(),
fInBuffer(0), fInBuffer(0),
fOutBuffer(0), fOutBuffer(0),
fOverruns(0), fOverruns(0),
@@ -49,7 +49,7 @@ bool JackMessageBuffer::Start()
return true; return true;
} else { } else {
return false; return false;
}
}
} }


bool JackMessageBuffer::Stop() bool JackMessageBuffer::Stop()
@@ -133,7 +133,7 @@ bool JackMessageBuffer::Create()
return false; return false;
} }
} }
return true; return true;
} }




+ 19
- 6
windows/JackWinMutex.cpp View File

@@ -76,19 +76,34 @@ namespace Jack


bool JackWinMutex::Lock() bool JackWinMutex::Lock()
{ {
return (WAIT_OBJECT_0 == WaitForSingleObject(fMutex, INFINITE));
if (WAIT_OBJECT_0 == WaitForSingleObject(fMutex, INFINITE)) {
return true;
} else {
jack_log("JackWinProcessSync::Lock WaitForSingleObject err = %d", GetLastError());
return false;
}
} }


bool JackWinMutex::Trylock() bool JackWinMutex::Trylock()
{ {
return (WAIT_OBJECT_0 == WaitForSingleObject(fMutex, 0));
if (WAIT_OBJECT_0 == WaitForSingleObject(fMutex, 0)) {
return true;
} else {
jack_log("JackWinProcessSync::Lock WaitForSingleObject err = %d", GetLastError());
return false;
}
} }


bool JackWinMutex::Unlock() bool JackWinMutex::Unlock()
{ {
return (ReleaseMutex(fMutex) != 0);
if (!ReleaseMutex(fMutex)) {
jack_log("JackWinProcessSync::Unlock ReleaseMutex err = %d", GetLastError());
return false;
} else {
return true;
}
} }
bool JackWinCriticalSection::Lock() bool JackWinCriticalSection::Lock()
{ {
EnterCriticalSection(&fSection); EnterCriticalSection(&fSection);
@@ -106,8 +121,6 @@ namespace Jack
return true; return true;
} }




} // namespace } // namespace





+ 10
- 5
windows/JackWinMutex.h View File

@@ -71,10 +71,15 @@ class SERVER_EXPORT JackWinMutex


JackWinMutex(const char* name = NULL) JackWinMutex(const char* name = NULL)
{ {
// In recursive mode by default
char buffer[MAX_PATH];
snprintf(buffer, sizeof(buffer), "%s_%s", "JackWinMutex", name);
fMutex = CreateMutex(NULL, FALSE, buffer);
// In recursive mode by default
if (name) {
char buffer[MAX_PATH];
snprintf(buffer, sizeof(buffer), "%s_%s", "JackWinMutex", name);
fMutex = CreateMutex(NULL, FALSE, buffer);
} else {
fMutex = CreateMutex(NULL, FALSE, NULL);
}

ThrowIf((fMutex == 0), JackException("JackWinMutex: could not init the mutex")); ThrowIf((fMutex == 0), JackException("JackWinMutex: could not init the mutex"));
} }


@@ -94,7 +99,7 @@ class SERVER_EXPORT JackWinCriticalSection


protected: protected:


LPCRITICAL_SECTION fSection;
CRITICAL_SECTION fSection;


public: public:




+ 11
- 7
windows/JackWinProcessSync.h View File

@@ -15,8 +15,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.


*/

*/


#ifndef __JackWinProcessSync__ #ifndef __JackWinProcessSync__
#define __JackWinProcessSync__ #define __JackWinProcessSync__
@@ -39,12 +38,17 @@ class JackWinProcessSync : public JackWinMutex


public: public:


JackWinProcessSync(const char* name = NULL):JackWinMutex()
JackWinProcessSync(const char* name = NULL):JackWinMutex(name)
{ {
char buffer[MAX_PATH];
snprintf(buffer, sizeof(buffer), "%s_%s", "WinProcessSync", name);
//fEvent = CreateEvent(NULL, TRUE, FALSE, buffer); // Needs ResetEvent
fEvent = CreateEvent(NULL, FALSE, FALSE, NULL); // Audo-reset event
if (name) {
char buffer[MAX_PATH];
snprintf(buffer, sizeof(buffer), "%s_%s", "JackWinProcessSync", name);
//fEvent = CreateEvent(NULL, TRUE, FALSE, buffer); // Needs ResetEvent
fEvent = CreateEvent(NULL, FALSE, FALSE, buffer); // Auto-reset event
} else {
fEvent = CreateEvent(NULL, FALSE, FALSE, NULL); // Auto-reset event
}

ThrowIf((fEvent == 0), JackException("JackWinProcessSync: could not init the event")); ThrowIf((fEvent == 0), JackException("JackWinProcessSync: could not init the event"));
} }
virtual ~JackWinProcessSync() virtual ~JackWinProcessSync()


Loading…
Cancel
Save