diff --git a/host/platform/Windows/CMakeLists.txt b/host/platform/Windows/CMakeLists.txt index 8ef3a05a..4ef39053 100644 --- a/host/platform/Windows/CMakeLists.txt +++ b/host/platform/Windows/CMakeLists.txt @@ -27,6 +27,7 @@ target_link_libraries(platform_Windows shlwapi powrprof rpcrt4 + avrt ) target_include_directories(platform_Windows diff --git a/host/platform/Windows/src/platform.c b/host/platform/Windows/src/platform.c index 9023ca99..fbd43d2b 100644 --- a/host/platform/Windows/src/platform.c +++ b/host/platform/Windows/src/platform.c @@ -32,6 +32,7 @@ #include #include #include +#include #include "interface/platform.h" #include "common/debug.h" @@ -60,6 +61,7 @@ struct AppState UINT trayRestartMsg; HMENU trayMenu; HANDLE exitWait; + HANDLE taskHandle; }; static struct AppState app = {0}; @@ -450,6 +452,9 @@ finish: free(app.argv[i]); free(app.argv); + if (app.taskHandle) + AvRevertMmThreadCharacteristics(app.taskHandle); + return result; } @@ -479,7 +484,15 @@ void boostPriority(void) DEBUG_INFO("looking-glass-host.exe InstallService"); } - DwmEnableMMCSS(true); + DWORD taskIndex = 0; + app.taskHandle = + AvSetMmThreadCharacteristicsA("Capture", &taskIndex); + + if (!app.taskHandle) + DEBUG_WINERROR("AvSetMmThreadCharacteristicsA failed", GetLastError()); + + if (!AvSetMmThreadPriority(app.taskHandle, AVRT_PRIORITY_CRITICAL)) + DEBUG_WINERROR("Failed to set thread priority", GetLastError()); } void CALLBACK exitEventCallback(PVOID opaque, BOOLEAN timedOut)