From 84b2917706d17710fcf54171af784d28f1eb6a0c Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Wed, 22 May 2019 12:00:06 +1000 Subject: [PATCH] [client] app: new options to reduce CPU usage This patch increases the default cursor and frame polling interval from 1us to 1000us which for most use cases should be more then fast enough. It also adds two new configuration options to adjust these should it be required: * app:cursorPollInterval * app:framePollInterval --- VERSION | 2 +- client/src/config.c | 20 ++++++++++++++++++-- client/src/main.c | 5 ++--- client/src/main.h | 3 +++ 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/VERSION b/VERSION index 56ed76a0..b929b20f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -a12-205-g087387087e+1 \ No newline at end of file +a12-206-gfc66a4a19c+1 \ No newline at end of file diff --git a/client/src/config.c b/client/src/config.c index 3b6f9c3b..e771357e 100644 --- a/client/src/config.c +++ b/client/src/config.c @@ -86,6 +86,20 @@ static struct Option options[] = .type = OPTION_TYPE_BOOL, .value.x_bool = false, }, + { + .module = "app", + .name = "cursorPollInterval", + .description = "How often to check for a cursor update in microseconds", + .type = OPTION_TYPE_INT, + .value.x_int = 1000 + }, + { + .module = "app", + .name = "framePollInterval", + .description = "How often to check for a frame update in microseconds", + .type = OPTION_TYPE_INT, + .value.x_int = 1000 + }, // window options { @@ -344,8 +358,10 @@ bool config_load(int argc, char * argv[]) } // setup the application params for the basic types - params.shmFile = option_get_string("app", "shmFile"); - params.shmSize = option_get_int ("app", "shmSize") * 1048576; + params.shmFile = option_get_string("app", "shmFile" ); + params.shmSize = option_get_int ("app", "shmSize" ) * 1048576; + params.cursorPollInterval = option_get_int ("app", "cursorPollInterval"); + params.framePollInterval = option_get_int ("app", "framePollInterval" ); params.windowTitle = option_get_string("win", "title" ); params.autoResize = option_get_bool ("win", "autoResize" ); diff --git a/client/src/main.c b/client/src/main.c index 8d02dd0f..48bd8742 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -171,8 +171,7 @@ static int cursorThread(void * unused) { if (!state.running) return 0; - - usleep(1); + usleep(params.cursorPollInterval); continue; } @@ -285,7 +284,7 @@ static int frameThread(void * unused) if (!state.running) break; - usleep(1); + usleep(params.framePollInterval); continue; } diff --git a/client/src/main.h b/client/src/main.h index 11319e82..f908c0c0 100644 --- a/client/src/main.h +++ b/client/src/main.h @@ -96,6 +96,9 @@ struct AppParams SDL_Scancode escapeKey; bool showAlerts; + unsigned int cursorPollInterval; + unsigned int framePollInterval; + bool forceRenderer; unsigned int forceRendererIndex;