git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4577 0c269be4-1314-0410-8aa9-9f06e86f4224tags/1.9.8
@@ -900,9 +900,6 @@ jackctl_server_open( | |||||
jack_cleanup_shm(); | jack_cleanup_shm(); | ||||
JackTools::CleanupFiles(server_ptr->name.str); | JackTools::CleanupFiles(server_ptr->name.str); | ||||
// OS specific initialisations | |||||
//JackTools::InitOS(); | |||||
if (!server_ptr->realtime.b && server_ptr->client_timeout.i == 0) { | if (!server_ptr->realtime.b && server_ptr->client_timeout.i == 0) { | ||||
server_ptr->client_timeout.i = 500; /* 0.5 sec; usable when non realtime. */ | server_ptr->client_timeout.i = 500; /* 0.5 sec; usable when non realtime. */ | ||||
} | } | ||||
@@ -1,20 +1,20 @@ | |||||
/* | /* | ||||
Copyright (C) 2004-2008 Grame | Copyright (C) 2004-2008 Grame | ||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
it under the terms of the GNU Lesser General Public License as published by | it under the terms of the GNU Lesser General Public License as published by | ||||
the Free Software Foundation; either version 2.1 of the License, or | the Free Software Foundation; either version 2.1 of the License, or | ||||
(at your option) any later version. | (at your option) any later version. | ||||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | ||||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
GNU Lesser General Public License for more details. | GNU Lesser General Public License for more details. | ||||
You should have received a copy of the GNU Lesser General Public License | You should have received a copy of the GNU Lesser General Public License | ||||
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. | ||||
*/ | */ | ||||
#include "JackError.h" | #include "JackError.h" | ||||
@@ -33,7 +33,7 @@ JackShmMem::JackShmMem() | |||||
JackShmMemAble::Init(); | JackShmMemAble::Init(); | ||||
LockMemory(); | LockMemory(); | ||||
} | } | ||||
JackShmMem::~JackShmMem() | JackShmMem::~JackShmMem() | ||||
{ | { | ||||
UnlockMemory(); | UnlockMemory(); | ||||
@@ -45,7 +45,7 @@ void JackShmMemAble::Init() | |||||
fInfo.ptr.attached_at = gInfo.ptr.attached_at; | fInfo.ptr.attached_at = gInfo.ptr.attached_at; | ||||
fInfo.size = gInfo.size; | fInfo.size = gInfo.size; | ||||
} | } | ||||
void* JackShmMem::operator new(size_t size, void* memory) | void* JackShmMem::operator new(size_t size, void* memory) | ||||
{ | { | ||||
jack_log("JackShmMem::new placement size = %ld", size); | jack_log("JackShmMem::new placement size = %ld", size); | ||||
@@ -100,7 +100,7 @@ void JackShmMem::operator delete(void* p, size_t size) | |||||
} | } | ||||
void JackShmMem::operator delete(void* obj) | void JackShmMem::operator delete(void* obj) | ||||
{ | |||||
{ | |||||
if (obj) { | if (obj) { | ||||
JackShmMem::operator delete(obj, 0); | JackShmMem::operator delete(obj, 0); | ||||
} | } | ||||
@@ -111,7 +111,11 @@ void LockMemoryImp(void* ptr, size_t size) | |||||
if (CHECK_MLOCK((char*)ptr, size)) { | if (CHECK_MLOCK((char*)ptr, size)) { | ||||
jack_log("Succeeded in locking %u byte memory area", size); | jack_log("Succeeded in locking %u byte memory area", size); | ||||
} else { | } else { | ||||
#ifdef WIN32 | |||||
jack_error("Cannot lock down memory area size = %d (%d)", size, GetLastError()); | |||||
#else | |||||
jack_error("Cannot lock down memory area (%s)", strerror(errno)); | jack_error("Cannot lock down memory area (%s)", strerror(errno)); | ||||
#endif | |||||
} | } | ||||
} | } | ||||
@@ -121,7 +125,11 @@ void InitLockMemoryImp(void* ptr, size_t size) | |||||
memset(ptr, 0, size); | memset(ptr, 0, size); | ||||
jack_log("Succeeded in locking %u byte memory area", size); | jack_log("Succeeded in locking %u byte memory area", size); | ||||
} else { | } else { | ||||
#ifdef WIN32 | |||||
jack_error("Cannot lock down memory area (%d)", GetLastError()); | |||||
#else | |||||
jack_error("Cannot lock down memory area (%s)", strerror(errno)); | jack_error("Cannot lock down memory area (%s)", strerror(errno)); | ||||
#endif | |||||
} | } | ||||
} | } | ||||
@@ -237,21 +237,6 @@ namespace Jack { | |||||
new_name[i] = '\0'; | new_name[i] = '\0'; | ||||
} | } | ||||
void JackTools::InitOS() | |||||
{ | |||||
#ifdef WIN32 | |||||
SIZE_T dwMin, dwMax; | |||||
HANDLE hProcess = GetCurrentProcess(); | |||||
if (!GetProcessWorkingSetSize(hProcess, &dwMin, &dwMax)) { | |||||
jack_error("GetProcessWorkingSetSize failed (%d)", GetLastError()); | |||||
} else if (!SetProcessWorkingSetSize(hProcess, dwMin, dwMax * 5)) { | |||||
jack_error("SetProcessWorkingSetSize failed (%d)", GetLastError()); | |||||
} else { | |||||
jack_info("SetProcessWorkingSetSize min = %d max = %d", dwMin, dwMax * 5); | |||||
} | |||||
#endif | |||||
} | |||||
#ifdef WIN32 | #ifdef WIN32 | ||||
void BuildClientPath(char* path_to_so, int path_len, const char* so_name) | void BuildClientPath(char* path_to_so, int path_len, const char* so_name) | ||||
@@ -68,9 +68,6 @@ namespace Jack | |||||
static void CleanupFiles(const char* server_name); | static void CleanupFiles(const char* server_name); | ||||
static int GetTmpdir(); | static int GetTmpdir(); | ||||
static void RewriteName(const char* name, char* new_name); | static void RewriteName(const char* name, char* new_name); | ||||
static void InitOS(); | |||||
static void ThrowJackNetException(); | static void ThrowJackNetException(); | ||||
// For OSX only | // For OSX only | ||||
@@ -17,33 +17,37 @@ | |||||
*/ | */ | ||||
#ifndef __JackShmMem_WIN32__ | #ifndef __JackShmMem_WIN32__ | ||||
#define __JackShmMem_WIN32__ | #define __JackShmMem_WIN32__ | ||||
#include <windows.h> | #include <windows.h> | ||||
// See GetProcessWorkingSetSize and SetProcessWorkingSetSize | |||||
bool CHECK_MLOCK(ptr, size) | |||||
inline bool CHECK_MLOCK(void* ptr, size_t size) | |||||
{ | { | ||||
if (!VirtualLock((ptr), (size))) { | |||||
if (!VirtualLock((ptr), (size))) { | |||||
SIZE_T minWSS, maxWSS; | SIZE_T minWSS, maxWSS; | ||||
HANDLE hProc = GetCurrentProcess(); | HANDLE hProc = GetCurrentProcess(); | ||||
if (GetProcessWorkingSetSize(hProc, &minWSS, &maxWSS)) { | |||||
if (GetProcessWorkingSetSize(hProc, &minWSS, &maxWSS)) { | |||||
const size_t increase = size + (10 * 4096); | const size_t increase = size + (10 * 4096); | ||||
maxWSS += increase; minWSS += increase; | |||||
maxWSS += increase; | |||||
minWSS += increase; | |||||
if (!SetProcessWorkingSetSize(hProc, minWSS, maxWSS)) { | if (!SetProcessWorkingSetSize(hProc, minWSS, maxWSS)) { | ||||
jack_error("SetProcessWorkingSetSize error %d", GetLastError()); | |||||
jack_error("SetProcessWorkingSetSize error = %d", GetLastError()); | |||||
return false; | |||||
} else if (!VirtualLock((ptr), (size))) { | } else if (!VirtualLock((ptr), (size))) { | ||||
jack_error("VirtualLock error %d", GetLastError()); | |||||
} else { | |||||
jack_error("VirtualLock error = %d", GetLastError()); | |||||
return false; | |||||
} else { | |||||
return true; | return true; | ||||
} | } | ||||
} else { | |||||
return false; | |||||
} | } | ||||
} else { | |||||
return true; | |||||
} | } | ||||
return false; | |||||
} | } | ||||
#define CHECK_MUNLOCK(ptr, size) (VirtualUnlock((ptr), (size)) != 0) | #define CHECK_MUNLOCK(ptr, size) (VirtualUnlock((ptr), (size)) != 0) | ||||
#define CHECK_MLOCKALL()(false) | #define CHECK_MLOCKALL()(false) | ||||
#define CHECK_MUNLOCKALL()(false) | #define CHECK_MUNLOCKALL()(false) | ||||