From 40e0202f5954c475c9c48155b95bc4dc67433242 Mon Sep 17 00:00:00 2001 From: yum Date: Tue, 27 Jun 2023 01:04:44 -0700 Subject: Limit priority of transcription process Seems to help reduce impact on time-sensitive apps like OBS. --- GUI/GUI/GUI/PythonWrapper.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/GUI/GUI/GUI/PythonWrapper.cpp b/GUI/GUI/GUI/PythonWrapper.cpp index 037d961..9855b00 100644 --- a/GUI/GUI/GUI/PythonWrapper.cpp +++ b/GUI/GUI/GUI/PythonWrapper.cpp @@ -281,6 +281,15 @@ bool PythonWrapper::InvokeCommandWithArgs(const std::string& cmd, CloseHandle(pi.hThread); }); + // Set spawned process priority to low, to avoid lagging things like OBS. + if (!SetPriorityClass(pi.hProcess, BELOW_NORMAL_PRIORITY_CLASS)) { + std::ostringstream err_oss; + err_oss << "Error while executing python command \"" << cmd_oss.str() + << "\": Failed to reduce priority class: " << GetWin32ErrMsg(); + out_cb("", err_oss.str()); + return false; + } + // While the process is running, drain output and send input every 10 ms. DWORD timeout_ms = 10; DWORD ret = WAIT_TIMEOUT; -- cgit v1.2.3