M17: realtime FX mượt — MMCSS Pro Audio + HIGH_PRIORITY_CLASS (JuceFxLoop), GUI tick cadence động 30/200ms (guiBusy), worklet CAP 32->48, track FX gửi input NGAY như master
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#include <mmsystem.h>
|
||||
#include <avrt.h>
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
@@ -229,6 +230,18 @@ int run_juce_fx_loop(const std::string& jobPath, const std::string& shmName,
|
||||
#ifdef _WIN32
|
||||
timeBeginPeriod(1);
|
||||
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST);
|
||||
// MMCSS "Pro Audio": Windows đảm bảo quantum + ưu tiên cho thread này khi
|
||||
// CPU cạnh tranh — chống spike deschedule (loopMax 430ms / 5756ms ở log).
|
||||
// AvSetMmThreadCharacteristicsW (Avrt.lib). Process HIGH_PRIORITY_CLASS —
|
||||
// không cần admin (REALTIME_PRIORITY_CLASS cần SeIncreaseBasePriorityPrivilege).
|
||||
DWORD mmTaskIndex = 0;
|
||||
HANDLE hMm = AvSetMmThreadCharacteristicsW(L"Pro Audio", &mmTaskIndex);
|
||||
if (hMm) {
|
||||
SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
|
||||
std::cerr << "[JuceFxLoop] MMCSS Pro Audio ok" << std::endl;
|
||||
} else {
|
||||
std::cerr << "[JuceFxLoop] MMCSS unavailable err=" << GetLastError() << std::endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Engine: prepare graph (chain theo fx_chain). sr/block từ job; header là
|
||||
@@ -501,6 +514,7 @@ int run_juce_fx_loop(const std::string& jobPath, const std::string& shmName,
|
||||
guiHost.stop(); // M2: đóng editor (GUI thread) + dừng GUI thread + join
|
||||
fxshm::closeShm(v);
|
||||
#ifdef _WIN32
|
||||
if (hMm) AvRevertMmThreadCharacteristics(hMm);
|
||||
timeEndPeriod(1);
|
||||
#endif
|
||||
std::cerr << "[JuceFxLoop] exit processed=" << processed << std::endl;
|
||||
|
||||
Reference in New Issue
Block a user