Browse Source

More debug code in JackMMCSS class.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4480 0c269be4-1314-0410-8aa9-9f06e86f4224
tags/1.9.8
sletz 14 years ago
parent
commit
0969f6317d
2 changed files with 48 additions and 41 deletions
  1. +47
    -40
      windows/JackMMCSS.cpp
  2. +1
    -1
      windows/JackWinThread.cpp

+ 47
- 40
windows/JackMMCSS.cpp View File

@@ -1,29 +1,29 @@
/*
Copyright (C) 2004-2008 Grame
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "JackMMCSS.h"
#include "JackError.h"
/*
Copyright (C) 2004-2008 Grame
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "JackMMCSS.h"
#include "JackError.h"
#include <assert.h>
#include <stdio.h>
namespace Jack
{
#include <stdio.h>
namespace Jack
{
avSetMmThreadCharacteristics JackMMCSS::ffMMCSSFun1 = NULL;
avSetMmThreadPriority JackMMCSS::ffMMCSSFun2 = NULL;
@@ -31,21 +31,21 @@ avRevertMmThreadCharacteristics JackMMCSS::ffMMCSSFun3 = NULL;
JACK_HANDLE JackMMCSS::fAvrtDll;
std::map<jack_native_thread_t, HANDLE> JackMMCSS::fHandleTable;
JackMMCSS::JackMMCSS()
{
JackMMCSS::JackMMCSS()
{
fAvrtDll = LoadJackModule("avrt.dll");
if (fAvrtDll != NULL) {
ffMMCSSFun1 = (avSetMmThreadCharacteristics)GetJackProc(fAvrtDll, "AvSetMmThreadCharacteristicsA");
ffMMCSSFun1 = (avSetMmThreadCharacteristics)GetJackProc(fAvrtDll, "AvSetMmThreadCharacteristicsA");
ffMMCSSFun2 = (avSetMmThreadPriority)GetJackProc(fAvrtDll, "AvSetMmThreadPriority");
ffMMCSSFun3 = (avRevertMmThreadCharacteristics)GetJackProc(fAvrtDll, "AvRevertMmThreadCharacteristics");
}
}
JackMMCSS::~JackMMCSS()
{}
}
}
JackMMCSS::~JackMMCSS()
{}
int JackMMCSS::MMCSSAcquireRealTime(jack_native_thread_t thread)
{
if (fHandleTable.find(thread) != fHandleTable.end()) {
@@ -54,23 +54,30 @@ int JackMMCSS::MMCSSAcquireRealTime(jack_native_thread_t thread)
if (ffMMCSSFun1) {
DWORD dummy = 0;
HANDLE task = ffMMCSSFun1("Pro Audio", &dummy);
if (task == NULL) {
jack_error("Cannot use MMCSS %d", GetLastError());
HANDLE task = ffMMCSSFun1("Pro Audio", &dummy);
if (task == NULL) {
jack_error("AvSetMmThreadCharacteristics error : %d", GetLastError());
} else if (ffMMCSSFun2(task, AVRT_PRIORITY_CRITICAL)) {
fHandleTable[thread] = task;
jack_log("AvSetMmThreadPriority success");
return 0;
} else {
jack_error("AvSetMmThreadPriority error : %d", GetLastError());
}
}
return -1;
}
}
int JackMMCSS::MMCSSDropRealTime(jack_native_thread_t thread)
{
if (fHandleTable.find(thread) != fHandleTable.end()) {
HANDLE task = fHandleTable[thread];
ffMMCSSFun3(task);
if (ffMMCSSFun3(task) == 0) {
jack_error("AvRevertMmThreadCharacteristics error : %d", GetLastError());
} else {
jack_log("AvRevertMmThreadCharacteristics success");
}
return 0;
} else {
return -1;


+ 1
- 1
windows/JackWinThread.cpp View File

@@ -200,7 +200,7 @@ int JackWinThread::AcquireSelfRealTime(int priority)

int JackWinThread::AcquireRealTimeImp(jack_native_thread_t thread, int priority)
{
jack_log("JackWinThread::AcquireRealTimeImp priority = %d", THREAD_PRIORITY_TIME_CRITICAL);
jack_log("JackWinThread::AcquireRealTimeImp priority = %d", priority);

if (priority >= 90 && MMCSSAcquireRealTime(thread) == 0) {
jack_info("MMCSS API used to acquire RT for thread");


Loading…
Cancel
Save