diff --git a/windows/JackMMCSS.cpp b/windows/JackMMCSS.cpp index dc8897df..09bfb0e3 100644 --- a/windows/JackMMCSS.cpp +++ b/windows/JackMMCSS.cpp @@ -46,7 +46,7 @@ JackMMCSS::JackMMCSS() JackMMCSS::~JackMMCSS() {} -int JackMMCSS::MMCSSAcquireRealTime(jack_native_thread_t thread) +int JackMMCSS::MMCSSAcquireRealTime(jack_native_thread_t thread, int priority) { if (fHandleTable.find(thread) != fHandleTable.end()) { return 0; @@ -57,7 +57,7 @@ int JackMMCSS::MMCSSAcquireRealTime(jack_native_thread_t thread) HANDLE task = ffMMCSSFun1("Pro Audio", &dummy); if (task == NULL) { jack_error("AvSetMmThreadCharacteristics error : %d", GetLastError()); - } else if (ffMMCSSFun2(task, AVRT_PRIORITY_CRITICAL)) { + } else if (ffMMCSSFun2(task, priority - BASE_REALTIME_PRIORITY)) { fHandleTable[thread] = task; jack_log("AvSetMmThreadPriority success"); return 0; diff --git a/windows/JackMMCSS.h b/windows/JackMMCSS.h index 39d89a6a..faf33188 100644 --- a/windows/JackMMCSS.h +++ b/windows/JackMMCSS.h @@ -36,8 +36,10 @@ typedef enum _AVRT_PRIORITY { AVRT_PRIORITY_HIGH, /* 1 */ AVRT_PRIORITY_CRITICAL /* 2 */ } AVRT_PRIORITY, *PAVRT_PRIORITY; - -typedef HANDLE (WINAPI *avSetMmThreadCharacteristics)(LPCTSTR, LPDWORD); + +#define BASE_REALTIME_PRIORITY 90 + +typedef HANDLE (WINAPI *avSetMmThreadCharacteristics)(LPCTSTR, LPDWORD); typedef BOOL (WINAPI *avRevertMmThreadCharacteristics)(HANDLE); typedef BOOL (WINAPI *avSetMmThreadPriority)(HANDLE, AVRT_PRIORITY); @@ -61,7 +63,7 @@ class SERVER_EXPORT JackMMCSS JackMMCSS(); ~JackMMCSS(); - static int MMCSSAcquireRealTime(jack_native_thread_t thread); + static int MMCSSAcquireRealTime(jack_native_thread_t thread, int priority); static int MMCSSDropRealTime(jack_native_thread_t thread); }; diff --git a/windows/JackWinThread.cpp b/windows/JackWinThread.cpp index f1ce3358..d586f964 100644 --- a/windows/JackWinThread.cpp +++ b/windows/JackWinThread.cpp @@ -202,7 +202,7 @@ int JackWinThread::AcquireRealTimeImp(jack_native_thread_t thread, int priority) { jack_log("JackWinThread::AcquireRealTimeImp priority = %d", priority); - if (priority >= 90 && MMCSSAcquireRealTime(thread) == 0) { + if (priority >= (BASE_REALTIME_PRIORITY - 1) && MMCSSAcquireRealTime(thread, priority) == 0) { jack_log("MMCSS API used to acquire RT for thread"); return 0; } else {