| @@ -46,7 +46,7 @@ JackMMCSS::JackMMCSS() | |||||
| 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()) { | if (fHandleTable.find(thread) != fHandleTable.end()) { | ||||
| return 0; | return 0; | ||||
| @@ -57,7 +57,7 @@ int JackMMCSS::MMCSSAcquireRealTime(jack_native_thread_t thread) | |||||
| HANDLE task = ffMMCSSFun1("Pro Audio", &dummy); | HANDLE task = ffMMCSSFun1("Pro Audio", &dummy); | ||||
| if (task == NULL) { | if (task == NULL) { | ||||
| jack_error("AvSetMmThreadCharacteristics error : %d", GetLastError()); | jack_error("AvSetMmThreadCharacteristics error : %d", GetLastError()); | ||||
| } else if (ffMMCSSFun2(task, AVRT_PRIORITY_CRITICAL)) { | |||||
| } else if (ffMMCSSFun2(task, priority - BASE_REALTIME_PRIORITY)) { | |||||
| fHandleTable[thread] = task; | fHandleTable[thread] = task; | ||||
| jack_log("AvSetMmThreadPriority success"); | jack_log("AvSetMmThreadPriority success"); | ||||
| return 0; | return 0; | ||||
| @@ -36,8 +36,10 @@ typedef enum _AVRT_PRIORITY { | |||||
| AVRT_PRIORITY_HIGH, /* 1 */ | AVRT_PRIORITY_HIGH, /* 1 */ | ||||
| AVRT_PRIORITY_CRITICAL /* 2 */ | AVRT_PRIORITY_CRITICAL /* 2 */ | ||||
| } AVRT_PRIORITY, *PAVRT_PRIORITY; | } 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 *avRevertMmThreadCharacteristics)(HANDLE); | ||||
| typedef BOOL (WINAPI *avSetMmThreadPriority)(HANDLE, AVRT_PRIORITY); | typedef BOOL (WINAPI *avSetMmThreadPriority)(HANDLE, AVRT_PRIORITY); | ||||
| @@ -61,7 +63,7 @@ class SERVER_EXPORT JackMMCSS | |||||
| JackMMCSS(); | 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); | static int MMCSSDropRealTime(jack_native_thread_t thread); | ||||
| }; | }; | ||||
| @@ -202,7 +202,7 @@ int JackWinThread::AcquireRealTimeImp(jack_native_thread_t thread, int priority) | |||||
| { | { | ||||
| jack_log("JackWinThread::AcquireRealTimeImp priority = %d", 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"); | jack_log("MMCSS API used to acquire RT for thread"); | ||||
| return 0; | return 0; | ||||
| } else { | } else { | ||||