mirror of
				https://github.com/gnif/LookingGlass.git
				synced 2025-11-03 22:22:08 +00:00 
			
		
		
		
	[host] windows: fix usage of MCSS and try to get priority "Capture"
This commit is contained in:
		@@ -27,6 +27,7 @@ target_link_libraries(platform_Windows
 | 
			
		||||
	shlwapi
 | 
			
		||||
	powrprof
 | 
			
		||||
	rpcrt4
 | 
			
		||||
	avrt
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
target_include_directories(platform_Windows
 | 
			
		||||
 
 | 
			
		||||
@@ -32,6 +32,7 @@
 | 
			
		||||
#include <userenv.h>
 | 
			
		||||
#include <winternl.h>
 | 
			
		||||
#include <dwmapi.h>
 | 
			
		||||
#include <avrt.h>
 | 
			
		||||
 | 
			
		||||
#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)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user