Commit da82d0e4 authored by sletz's avatar sletz
Browse files

Works again on Windows.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4750 0c269be4-1314-0410-8aa9-9f06e86f4224
parent 75699f9b
......@@ -32,7 +32,7 @@ JackMessageBuffer::JackMessageBuffer()
:fInit(NULL),
fInitArg(NULL),
fThread(this),
fGuard("JackMessageBuffer"),
fGuard(),
fInBuffer(0),
fOutBuffer(0),
fOverruns(0),
......@@ -49,7 +49,7 @@ bool JackMessageBuffer::Start()
return true;
} else {
return false;
}
}
}
bool JackMessageBuffer::Stop()
......@@ -133,7 +133,7 @@ bool JackMessageBuffer::Create()
return false;
}
}
return true;
}
......
......@@ -76,19 +76,34 @@ namespace Jack
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()
{
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()
{
return (ReleaseMutex(fMutex) != 0);
if (!ReleaseMutex(fMutex)) {
jack_log("JackWinProcessSync::Unlock ReleaseMutex err = %d", GetLastError());
return false;
} else {
return true;
}
}
bool JackWinCriticalSection::Lock()
{
EnterCriticalSection(&fSection);
......@@ -106,8 +121,6 @@ namespace Jack
return true;
}
} // namespace
......@@ -71,10 +71,15 @@ class SERVER_EXPORT JackWinMutex
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"));
}
......@@ -94,7 +99,7 @@ class SERVER_EXPORT JackWinCriticalSection
protected:
LPCRITICAL_SECTION fSection;
CRITICAL_SECTION fSection;
public:
......
......@@ -15,8 +15,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
*/
#ifndef __JackWinProcessSync__
#define __JackWinProcessSync__
......@@ -39,12 +38,17 @@ class JackWinProcessSync : public JackWinMutex
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"));
}
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