mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-25 14:57:20 +00:00
[main] make it possible to manually specify the memory size
This commit is contained in:
parent
4fd59ce8c9
commit
d0756cf00c
@ -88,6 +88,7 @@ struct AppParams
|
|||||||
int x, y;
|
int x, y;
|
||||||
unsigned int w, h;
|
unsigned int w, h;
|
||||||
char * shmFile;
|
char * shmFile;
|
||||||
|
unsigned int shmSize;
|
||||||
bool showFPS;
|
bool showFPS;
|
||||||
bool useSpice;
|
bool useSpice;
|
||||||
char * spiceHost;
|
char * spiceHost;
|
||||||
@ -116,6 +117,7 @@ struct AppParams params =
|
|||||||
.w = 1024,
|
.w = 1024,
|
||||||
.h = 768,
|
.h = 768,
|
||||||
.shmFile = "/dev/shm/looking-glass",
|
.shmFile = "/dev/shm/looking-glass",
|
||||||
|
.shmSize = 0,
|
||||||
.showFPS = false,
|
.showFPS = false,
|
||||||
.useSpice = true,
|
.useSpice = true,
|
||||||
.spiceHost = "127.0.0.1",
|
.spiceHost = "127.0.0.1",
|
||||||
@ -624,7 +626,7 @@ static void * map_memory()
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
state.shmSize = st.st_size;
|
state.shmSize = params.shmSize ? params.shmSize : st.st_size;
|
||||||
state.shmFD = open(params.shmFile, O_RDWR, (mode_t)0600);
|
state.shmFD = open(params.shmFile, O_RDWR, (mode_t)0600);
|
||||||
if (state.shmFD < 0)
|
if (state.shmFD < 0)
|
||||||
{
|
{
|
||||||
@ -632,7 +634,7 @@ static void * map_memory()
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void * map = mmap(0, st.st_size, PROT_READ | PROT_WRITE, MAP_SHARED, state.shmFD, 0);
|
void * map = mmap(0, state.shmSize, PROT_READ | PROT_WRITE, MAP_SHARED, state.shmFD, 0);
|
||||||
if (map == MAP_FAILED)
|
if (map == MAP_FAILED)
|
||||||
{
|
{
|
||||||
DEBUG_ERROR("Failed to map the shared memory file: %s", params.shmFile);
|
DEBUG_ERROR("Failed to map the shared memory file: %s", params.shmFile);
|
||||||
@ -1000,6 +1002,7 @@ void doHelp(char * app)
|
|||||||
"\n"
|
"\n"
|
||||||
" -C PATH Specify an additional configuration file to load\n"
|
" -C PATH Specify an additional configuration file to load\n"
|
||||||
" -f PATH Specify the path to the shared memory file [current: %s]\n"
|
" -f PATH Specify the path to the shared memory file [current: %s]\n"
|
||||||
|
" -L SIZE Specify the size in MB of the shared memory file (0 = detect) [current: %d]\n"
|
||||||
"\n"
|
"\n"
|
||||||
" -s Disable spice client\n"
|
" -s Disable spice client\n"
|
||||||
" -c HOST Specify the spice host [current: %s]\n"
|
" -c HOST Specify the spice host [current: %s]\n"
|
||||||
@ -1028,6 +1031,7 @@ void doHelp(char * app)
|
|||||||
app,
|
app,
|
||||||
app,
|
app,
|
||||||
params.shmFile,
|
params.shmFile,
|
||||||
|
params.shmSize,
|
||||||
params.spiceHost,
|
params.spiceHost,
|
||||||
params.spicePort,
|
params.spicePort,
|
||||||
params.center ? "center" : x,
|
params.center ? "center" : x,
|
||||||
@ -1087,6 +1091,9 @@ static bool load_config(const char * configFile)
|
|||||||
params.shmFile = strdup(stmp);
|
params.shmFile = strdup(stmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (config_setting_lookup_int(global, "shmSize", &itmp))
|
||||||
|
params.shmSize = itmp * 1024 * 1024;
|
||||||
|
|
||||||
if (config_setting_lookup_string(global, "forceRenderer", &stmp))
|
if (config_setting_lookup_string(global, "forceRenderer", &stmp))
|
||||||
{
|
{
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
@ -1234,7 +1241,7 @@ int main(int argc, char * argv[])
|
|||||||
|
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
switch(getopt(argc, argv, "hC:f:sc:p:jMvkg:o:anrdFx:y:w:b:Ql"))
|
switch(getopt(argc, argv, "hC:fL:sc:p:jMvkg:o:anrdFx:y:w:b:Ql"))
|
||||||
{
|
{
|
||||||
case '?':
|
case '?':
|
||||||
case 'h':
|
case 'h':
|
||||||
@ -1256,6 +1263,10 @@ int main(int argc, char * argv[])
|
|||||||
params.shmFile = strdup(optarg);
|
params.shmFile = strdup(optarg);
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
case 'L':
|
||||||
|
params.shmSize = atoi(optarg) * 1024 * 1024;
|
||||||
|
continue;
|
||||||
|
|
||||||
case 's':
|
case 's':
|
||||||
params.useSpice = false;
|
params.useSpice = false;
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
Reference in New Issue
Block a user