Commit bb7b3778 authored by sletz's avatar sletz
Browse files

Implement jack_client_real_time_priority and jack_client_max_real_time_priority API.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@3232 0c269be4-1314-0410-8aa9-9f06e86f4224
parent c2a484cd
......@@ -26,6 +26,7 @@ Michael Voigt
2009-01-05 Stephane Letz <letz@grame.fr>
* 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>
......
......@@ -209,6 +209,8 @@ extern "C"
EXPORT void jack_set_transport_info (jack_client_t *client,
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_client_create_thread (jack_client_t* client,
pthread_t *thread,
......@@ -218,8 +220,8 @@ extern "C"
void *arg);
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,
jack_intclient_t intclient);
......@@ -1717,6 +1719,36 @@ EXPORT void jack_reset_max_delayed_usecs(jack_client_t* ext_client)
}
// 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)
{
JackEngineControl* control = GetEngineControl();
......
......@@ -344,7 +344,7 @@ int JackClient::StartThread()
}
if (GetEngineControl()->fRealTime) {
if (fThread.AcquireRealTime(GetEngineControl()->fPriority - 1) < 0) {
if (fThread.AcquireRealTime(GetEngineControl()->fClientPriority) < 0) {
jack_error("AcquireRealTime error");
}
}
......
......@@ -53,7 +53,9 @@ struct SERVER_EXPORT JackEngineControl : public JackShmMem
float fXrunDelayedUsecs;
bool fTimeOut;
bool fRealTime;
int fPriority;
int fServerPriority;
int fClientPriority;
int fMaxClientPriority;
char fServerName[64];
JackTransportEngine fTransport;
bool fVerbose;
......@@ -87,7 +89,9 @@ struct SERVER_EXPORT JackEngineControl : public JackShmMem
fTimeOut = (timeout > 0);
fTimeOutUsecs = timeout * 1000;
fRealTime = rt;
fPriority = priority;
fServerPriority = priority;
fClientPriority = (rt) ? priority - 5 : 0;
fMaxClientPriority = (rt) ? priority - 1 : 0;
fVerbose = verbose;
fPrevCycleTime = 0;
fCurCycleTime = 0;
......
......@@ -216,7 +216,7 @@ namespace Jack
SetAdaptedBufferSize ( fParams.fPeriodSize );
SetAdaptedSampleRate ( fParams.fSampleRate );
if (fThread.AcquireRealTime ( JackServer::fInstance->GetEngineControl()->fPriority - 1 ) < 0) {
if (fThread.AcquireRealTime ( JackServer::fInstance->GetEngineControl()->fClientPriority ) < 0) {
jack_error("AcquireRealTime error");
} else {
set_threaded_log_function();
......
......@@ -210,7 +210,7 @@ bool JackThreadedDriver::Init()
jack_log("JackThreadedDriver::Init IsRealTime");
// Will do "something" on OSX only...
fThread.SetParams(GetEngineControl()->fPeriod, GetEngineControl()->fComputation, GetEngineControl()->fConstraint);
if (fThread.AcquireRealTime(GetEngineControl()->fPriority) < 0) {
if (fThread.AcquireRealTime(GetEngineControl()->fServerPriority) < 0) {
jack_error("AcquireRealTime error");
} else {
set_threaded_log_function();
......
......@@ -47,7 +47,7 @@ bool JackWaitThreadedDriver::Execute()
jack_log("JackWaitThreadedDriver::Init IsRealTime");
// Will do "something" on OSX only...
fThread.SetParams(GetEngineControl()->fPeriod, GetEngineControl()->fComputation, GetEngineControl()->fConstraint);
if (fThread.AcquireRealTime(GetEngineControl()->fPriority) < 0) {
if (fThread.AcquireRealTime(GetEngineControl()->fServerPriority) < 0) {
jack_error("AcquireRealTime error");
} else {
set_threaded_log_function();
......
......@@ -462,7 +462,7 @@ int JackFFADODriver::Attach()
/* packetizer thread options */
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;
if (driver->device_options.packetizer_priority > 98) {
driver->device_options.packetizer_priority = 98;
......
......@@ -682,7 +682,7 @@ int JackFreebobDriver::Attach()
/* packetizer thread options */
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;
if (driver->device_options.packetizer_priority > 98) {
driver->device_options.packetizer_priority = 98;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment