git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@3232 0c269be4-1314-0410-8aa9-9f06e86f4224tags/1.9.1
@@ -26,6 +26,7 @@ Michael Voigt | |||||
2009-01-05 Stephane Letz <letz@grame.fr> | 2009-01-05 Stephane Letz <letz@grame.fr> | ||||
* Synchronize jack2 public headers with jack1 ones. | * Synchronize jack2 public headers with jack1 ones. | ||||
* Implement jack_client_real_time_priority and jack_client_max_real_time_priority API. | |||||
2008-12-18 Stephane Letz <letz@grame.fr> | 2008-12-18 Stephane Letz <letz@grame.fr> | ||||
@@ -209,6 +209,8 @@ extern "C" | |||||
EXPORT void jack_set_transport_info (jack_client_t *client, | EXPORT void jack_set_transport_info (jack_client_t *client, | ||||
jack_transport_info_t *tinfo); | jack_transport_info_t *tinfo); | ||||
EXPORT int jack_client_real_time_priority (jack_client_t*); | |||||
EXPORT int jack_client_max_real_time_priority (jack_client_t*); | |||||
EXPORT int jack_acquire_real_time_scheduling (pthread_t thread, int priority); | EXPORT int jack_acquire_real_time_scheduling (pthread_t thread, int priority); | ||||
EXPORT int jack_client_create_thread (jack_client_t* client, | EXPORT int jack_client_create_thread (jack_client_t* client, | ||||
pthread_t *thread, | pthread_t *thread, | ||||
@@ -218,8 +220,8 @@ extern "C" | |||||
void *arg); | void *arg); | ||||
EXPORT int jack_drop_real_time_scheduling (pthread_t thread); | EXPORT int jack_drop_real_time_scheduling (pthread_t thread); | ||||
EXPORT int jack_client_stop_thread(jack_client_t* client, pthread_t thread); | |||||
EXPORT int jack_client_kill_thread(jack_client_t* client, pthread_t thread); | |||||
EXPORT int jack_client_stop_thread (jack_client_t* client, pthread_t thread); | |||||
EXPORT int jack_client_kill_thread (jack_client_t* client, pthread_t thread); | |||||
EXPORT char * jack_get_internal_client_name (jack_client_t *client, | EXPORT char * jack_get_internal_client_name (jack_client_t *client, | ||||
jack_intclient_t intclient); | jack_intclient_t intclient); | ||||
@@ -1717,6 +1719,36 @@ EXPORT void jack_reset_max_delayed_usecs(jack_client_t* ext_client) | |||||
} | } | ||||
// thread.h | // thread.h | ||||
EXPORT int jack_client_real_time_priority(jack_client_t* ext_client) | |||||
{ | |||||
#ifdef __CLIENTDEBUG__ | |||||
JackLibGlobals::CheckContext(); | |||||
#endif | |||||
JackClient* client = (JackClient*)ext_client; | |||||
if (client == NULL) { | |||||
jack_error("jack_client_real_time_priority called with a NULL client"); | |||||
return -1; | |||||
} else { | |||||
JackEngineControl* control = GetEngineControl(); | |||||
return (control->fRealTime) ? control->fClientPriority : -1; | |||||
} | |||||
} | |||||
EXPORT int jack_client_max_real_time_priority(jack_client_t* ext_client) | |||||
{ | |||||
#ifdef __CLIENTDEBUG__ | |||||
JackLibGlobals::CheckContext(); | |||||
#endif | |||||
JackClient* client = (JackClient*)ext_client; | |||||
if (client == NULL) { | |||||
jack_error("jack_client_max_real_time_priority called with a NULL client"); | |||||
return -1; | |||||
} else { | |||||
JackEngineControl* control = GetEngineControl(); | |||||
return (control->fRealTime) ? control->fMaxClientPriority : -1; | |||||
} | |||||
} | |||||
EXPORT int jack_acquire_real_time_scheduling(pthread_t thread, int priority) | EXPORT int jack_acquire_real_time_scheduling(pthread_t thread, int priority) | ||||
{ | { | ||||
JackEngineControl* control = GetEngineControl(); | JackEngineControl* control = GetEngineControl(); | ||||
@@ -344,7 +344,7 @@ int JackClient::StartThread() | |||||
} | } | ||||
if (GetEngineControl()->fRealTime) { | if (GetEngineControl()->fRealTime) { | ||||
if (fThread.AcquireRealTime(GetEngineControl()->fPriority - 1) < 0) { | |||||
if (fThread.AcquireRealTime(GetEngineControl()->fClientPriority) < 0) { | |||||
jack_error("AcquireRealTime error"); | jack_error("AcquireRealTime error"); | ||||
} | } | ||||
} | } | ||||
@@ -53,7 +53,9 @@ struct SERVER_EXPORT JackEngineControl : public JackShmMem | |||||
float fXrunDelayedUsecs; | float fXrunDelayedUsecs; | ||||
bool fTimeOut; | bool fTimeOut; | ||||
bool fRealTime; | bool fRealTime; | ||||
int fPriority; | |||||
int fServerPriority; | |||||
int fClientPriority; | |||||
int fMaxClientPriority; | |||||
char fServerName[64]; | char fServerName[64]; | ||||
JackTransportEngine fTransport; | JackTransportEngine fTransport; | ||||
bool fVerbose; | bool fVerbose; | ||||
@@ -87,7 +89,9 @@ struct SERVER_EXPORT JackEngineControl : public JackShmMem | |||||
fTimeOut = (timeout > 0); | fTimeOut = (timeout > 0); | ||||
fTimeOutUsecs = timeout * 1000; | fTimeOutUsecs = timeout * 1000; | ||||
fRealTime = rt; | fRealTime = rt; | ||||
fPriority = priority; | |||||
fServerPriority = priority; | |||||
fClientPriority = (rt) ? priority - 5 : 0; | |||||
fMaxClientPriority = (rt) ? priority - 1 : 0; | |||||
fVerbose = verbose; | fVerbose = verbose; | ||||
fPrevCycleTime = 0; | fPrevCycleTime = 0; | ||||
fCurCycleTime = 0; | fCurCycleTime = 0; | ||||
@@ -216,7 +216,7 @@ namespace Jack | |||||
SetAdaptedBufferSize ( fParams.fPeriodSize ); | SetAdaptedBufferSize ( fParams.fPeriodSize ); | ||||
SetAdaptedSampleRate ( fParams.fSampleRate ); | SetAdaptedSampleRate ( fParams.fSampleRate ); | ||||
if (fThread.AcquireRealTime ( JackServer::fInstance->GetEngineControl()->fPriority - 1 ) < 0) { | |||||
if (fThread.AcquireRealTime ( JackServer::fInstance->GetEngineControl()->fClientPriority ) < 0) { | |||||
jack_error("AcquireRealTime error"); | jack_error("AcquireRealTime error"); | ||||
} else { | } else { | ||||
set_threaded_log_function(); | set_threaded_log_function(); | ||||
@@ -210,7 +210,7 @@ bool JackThreadedDriver::Init() | |||||
jack_log("JackThreadedDriver::Init IsRealTime"); | jack_log("JackThreadedDriver::Init IsRealTime"); | ||||
// Will do "something" on OSX only... | // Will do "something" on OSX only... | ||||
fThread.SetParams(GetEngineControl()->fPeriod, GetEngineControl()->fComputation, GetEngineControl()->fConstraint); | fThread.SetParams(GetEngineControl()->fPeriod, GetEngineControl()->fComputation, GetEngineControl()->fConstraint); | ||||
if (fThread.AcquireRealTime(GetEngineControl()->fPriority) < 0) { | |||||
if (fThread.AcquireRealTime(GetEngineControl()->fServerPriority) < 0) { | |||||
jack_error("AcquireRealTime error"); | jack_error("AcquireRealTime error"); | ||||
} else { | } else { | ||||
set_threaded_log_function(); | set_threaded_log_function(); | ||||
@@ -47,7 +47,7 @@ bool JackWaitThreadedDriver::Execute() | |||||
jack_log("JackWaitThreadedDriver::Init IsRealTime"); | jack_log("JackWaitThreadedDriver::Init IsRealTime"); | ||||
// Will do "something" on OSX only... | // Will do "something" on OSX only... | ||||
fThread.SetParams(GetEngineControl()->fPeriod, GetEngineControl()->fComputation, GetEngineControl()->fConstraint); | fThread.SetParams(GetEngineControl()->fPeriod, GetEngineControl()->fComputation, GetEngineControl()->fConstraint); | ||||
if (fThread.AcquireRealTime(GetEngineControl()->fPriority) < 0) { | |||||
if (fThread.AcquireRealTime(GetEngineControl()->fServerPriority) < 0) { | |||||
jack_error("AcquireRealTime error"); | jack_error("AcquireRealTime error"); | ||||
} else { | } else { | ||||
set_threaded_log_function(); | set_threaded_log_function(); | ||||
@@ -462,7 +462,7 @@ int JackFFADODriver::Attach() | |||||
/* packetizer thread options */ | /* packetizer thread options */ | ||||
driver->device_options.realtime = (fEngineControl->fRealTime ? 1 : 0); | driver->device_options.realtime = (fEngineControl->fRealTime ? 1 : 0); | ||||
driver->device_options.packetizer_priority = fEngineControl->fPriority + | |||||
driver->device_options.packetizer_priority = fEngineControl->fServerPriority + | |||||
FFADO_RT_PRIORITY_PACKETIZER_RELATIVE; | FFADO_RT_PRIORITY_PACKETIZER_RELATIVE; | ||||
if (driver->device_options.packetizer_priority > 98) { | if (driver->device_options.packetizer_priority > 98) { | ||||
driver->device_options.packetizer_priority = 98; | driver->device_options.packetizer_priority = 98; | ||||
@@ -682,7 +682,7 @@ int JackFreebobDriver::Attach() | |||||
/* packetizer thread options */ | /* packetizer thread options */ | ||||
driver->device_options.realtime = (fEngineControl->fRealTime ? 1 : 0); | driver->device_options.realtime = (fEngineControl->fRealTime ? 1 : 0); | ||||
driver->device_options.packetizer_priority = fEngineControl->fPriority + | |||||
driver->device_options.packetizer_priority = fEngineControl->fServerPriority + | |||||
FREEBOB_RT_PRIORITY_PACKETIZER_RELATIVE; | FREEBOB_RT_PRIORITY_PACKETIZER_RELATIVE; | ||||
if (driver->device_options.packetizer_priority > 98) { | if (driver->device_options.packetizer_priority > 98) { | ||||
driver->device_options.packetizer_priority = 98; | driver->device_options.packetizer_priority = 98; | ||||