Skip to content

Commit f617868

Browse files
xtfoRytoEX
authored andcommitted
Prevent Windows 11 timer resolution throttling to fix audio distortion
Fixes audio distortion when using the "Control audio via OBS" setting. According to the SetProcessInformation API documentation: "By default in Windows 11 if a window owning process becomes fully occluded, minimized, or otherwise non-visible to the end user, and non-audible, Windows may automatically ignore the timer resolution request and thus does not guarantee a higher resolution than the default system resolution." Opt out of this behavior. Fixes #406
1 parent 0b13eb9 commit f617868

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

obs-browser-page/obs-browser-page-main.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@ static void shutdown_check_thread(DWORD parent_pid, DWORD main_thread_id)
7474

7575
int CALLBACK WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
7676
{
77+
PROCESS_POWER_THROTTLING_STATE PowerThrottling;
78+
PowerThrottling.Version = PROCESS_POWER_THROTTLING_CURRENT_VERSION;
79+
PowerThrottling.ControlMask = PROCESS_POWER_THROTTLING_IGNORE_TIMER_RESOLUTION;
80+
PowerThrottling.StateMask = 0;
81+
82+
SetProcessInformation(GetCurrentProcess(), ProcessPowerThrottling, &PowerThrottling, sizeof(PowerThrottling));
83+
7784
std::thread shutdown_check;
7885

7986
CefMainArgs mainArgs(nullptr);

0 commit comments

Comments
 (0)