Browse Source

Memory locking now working on Windows.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4577 0c269be4-1314-0410-8aa9-9f06e86f4224
tags/1.9.8
sletz 13 years ago
parent
commit
f7bcd227cc
7 changed files with 31 additions and 40 deletions
  1. +0
    -3
      common/JackControlAPI.cpp
  2. +16
    -8
      common/JackShmMem.cpp
  3. +0
    -15
      common/JackTools.cpp
  4. +0
    -3
      common/JackTools.h
  5. +15
    -11
      windows/JackShmMem_os.h
  6. BIN
      windows/Setup/src/32bits/JackRouter.dll
  7. BIN
      windows/Setup/src/64bits/JackRouter.dll

+ 0
- 3
common/JackControlAPI.cpp View File

@@ -900,9 +900,6 @@ jackctl_server_open(
jack_cleanup_shm();
JackTools::CleanupFiles(server_ptr->name.str);

// OS specific initialisations
//JackTools::InitOS();

if (!server_ptr->realtime.b && server_ptr->client_timeout.i == 0) {
server_ptr->client_timeout.i = 500; /* 0.5 sec; usable when non realtime. */
}


+ 16
- 8
common/JackShmMem.cpp View File

@@ -1,20 +1,20 @@
/*
Copyright (C) 2004-2008 Grame
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
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
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.
*/

#include "JackError.h"
@@ -33,7 +33,7 @@ JackShmMem::JackShmMem()
JackShmMemAble::Init();
LockMemory();
}
JackShmMem::~JackShmMem()
{
UnlockMemory();
@@ -45,7 +45,7 @@ void JackShmMemAble::Init()
fInfo.ptr.attached_at = gInfo.ptr.attached_at;
fInfo.size = gInfo.size;
}
void* JackShmMem::operator new(size_t size, void* memory)
{
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)
{
{
if (obj) {
JackShmMem::operator delete(obj, 0);
}
@@ -111,7 +111,11 @@ void LockMemoryImp(void* ptr, size_t size)
if (CHECK_MLOCK((char*)ptr, size)) {
jack_log("Succeeded in locking %u byte memory area", size);
} 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));
#endif
}
}

@@ -121,7 +125,11 @@ void InitLockMemoryImp(void* ptr, size_t size)
memset(ptr, 0, size);
jack_log("Succeeded in locking %u byte memory area", size);
} else {
#ifdef WIN32
jack_error("Cannot lock down memory area (%d)", GetLastError());
#else
jack_error("Cannot lock down memory area (%s)", strerror(errno));
#endif
}
}



+ 0
- 15
common/JackTools.cpp View File

@@ -237,21 +237,6 @@ namespace Jack {
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

void BuildClientPath(char* path_to_so, int path_len, const char* so_name)


+ 0
- 3
common/JackTools.h View File

@@ -68,9 +68,6 @@ namespace Jack
static void CleanupFiles(const char* server_name);
static int GetTmpdir();
static void RewriteName(const char* name, char* new_name);

static void InitOS();

static void ThrowJackNetException();

// For OSX only


+ 15
- 11
windows/JackShmMem_os.h View File

@@ -17,33 +17,37 @@

*/


#ifndef __JackShmMem_WIN32__
#define __JackShmMem_WIN32__

#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;
HANDLE hProc = GetCurrentProcess();
if (GetProcessWorkingSetSize(hProc, &minWSS, &maxWSS)) {
if (GetProcessWorkingSetSize(hProc, &minWSS, &maxWSS)) {
const size_t increase = size + (10 * 4096);
maxWSS += increase; minWSS += increase;
maxWSS += increase;
minWSS += increase;
if (!SetProcessWorkingSetSize(hProc, minWSS, maxWSS)) {
jack_error("SetProcessWorkingSetSize error %d", GetLastError());
jack_error("SetProcessWorkingSetSize error = %d", GetLastError());
return false;
} else if (!VirtualLock((ptr), (size))) {
jack_error("VirtualLock error %d", GetLastError());
} else {
jack_error("VirtualLock error = %d", GetLastError());
return false;
} else {
return true;
}
} else {
return false;
}
} else {
return true;
}
return false;
}

#define CHECK_MUNLOCK(ptr, size) (VirtualUnlock((ptr), (size)) != 0)
#define CHECK_MLOCKALL()(false)
#define CHECK_MUNLOCKALL()(false)


BIN
windows/Setup/src/32bits/JackRouter.dll View File


BIN
windows/Setup/src/64bits/JackRouter.dll View File


Loading…
Cancel
Save