Commit 606609f9 authored by nedko's avatar nedko
Browse files

range constraint for realtime-priority engine parameter

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@3011 0c269be4-1314-0410-8aa9-9f06e86f4224
parent ce793234
......@@ -591,6 +591,29 @@ jackctl_wait_signals(sigset_t signals)
}
#endif
static
jack_driver_param_constraint_desc_t *
get_realtime_priority_constraint()
{
jack_driver_param_constraint_desc_t * constraint_ptr;
int min, max;
if (!jack_get_thread_realtime_priority_range(&min, &max))
{
return NULL;
}
//jack_info("realtime priority range is (%d,%d)", min, max);
constraint_ptr = (jack_driver_param_constraint_desc_t *)calloc(1, sizeof(jack_driver_param_value_enum_t));
constraint_ptr->flags = JACK_CONSTRAINT_FLAG_RANGE;
constraint_ptr->constraint.range.min.i = min;
constraint_ptr->constraint.range.max.i = max;
return constraint_ptr;
}
EXPORT jackctl_server_t * jackctl_server_create()
{
struct jackctl_server * server_ptr;
......@@ -645,7 +668,8 @@ EXPORT jackctl_server_t * jackctl_server_create()
JackParamInt,
&server_ptr->realtime_priority,
&server_ptr->default_realtime_priority,
value) == NULL)
value,
get_realtime_priority_constraint()) == NULL)
{
goto fail_free_parameters;
}
......
......@@ -114,6 +114,8 @@ class SERVER_EXPORT JackThreadInterface
} // end of namespace
bool jack_get_thread_realtime_priority_range(int * min_ptr, int * max_ptr);
bool jack_tls_allocate_key(jack_tls_key *key_ptr);
bool jack_tls_free_key(jack_tls_key key);
......
......@@ -22,6 +22,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "JackError.h"
#include "JackTime.h"
#include <string.h> // for memset
#include <unistd.h> // for _POSIX_PRIORITY_SCHEDULING check
#define JACK_SCHED_POLICY SCHED_RR
//#define JACK_SCHED_POLICY SCHED_FIFO
namespace Jack
{
......@@ -114,8 +118,7 @@ int JackPosixThread::StartImp(pthread_t* thread, int priority, int realtime, voi
return -1;
}
//if ((res = pthread_attr_setschedpolicy(&attributes, SCHED_FIFO))) {
if ((res = pthread_attr_setschedpolicy(&attributes, SCHED_RR))) {
if ((res = pthread_attr_setschedpolicy(&attributes, JACK_SCHED_POLICY))) {
jack_error("Cannot set RR scheduling class for RT thread res = %d err = %s", res, strerror(errno));
return -1;
}
......@@ -216,9 +219,7 @@ int JackPosixThread::AcquireRealTimeImp(pthread_t thread, int priority)
memset(&rtparam, 0, sizeof(rtparam));
rtparam.sched_priority = priority;
//if ((res = pthread_setschedparam(fThread, SCHED_FIFO, &rtparam)) != 0) {
if ((res = pthread_setschedparam(thread, SCHED_RR, &rtparam)) != 0) {
if ((res = pthread_setschedparam(thread, JACK_SCHED_POLICY, &rtparam)) != 0) {
jack_error("Cannot use real-time scheduling (RR/%d) "
"(%d: %s)", rtparam.sched_priority, res,
strerror(res));
......@@ -265,6 +266,34 @@ SERVER_EXPORT void ThreadExit()
} // end of namespace
bool jack_get_thread_realtime_priority_range(int * min_ptr, int * max_ptr)
{
#if defined(_POSIX_PRIORITY_SCHEDULING) && !defined(__APPLE__)
int min, max;
min = sched_get_priority_min(JACK_SCHED_POLICY);
if (min == -1)
{
jack_error("sched_get_priority_min() failed.");
return false;
}
max = sched_get_priority_max(JACK_SCHED_POLICY);
if (max == -1)
{
jack_error("sched_get_priority_max() failed.");
return false;
}
*min_ptr = min;
*max_ptr = max;
return true;
#else
return false;
#endif
}
bool jack_tls_allocate_key(jack_tls_key *key_ptr)
{
int ret;
......
......@@ -232,6 +232,11 @@ SERVER_EXPORT void ThreadExit()
} // end of namespace
bool jack_get_thread_realtime_priority_range(int * min_ptr, int * max_ptr)
{
return false;
}
bool jack_tls_allocate_key(jack_tls_key *key_ptr)
{
DWORD key;
......
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