Browse Source

Merge 6ac25a305a into ab2e7363ca

pull/71/merge
yuri@FreeBSD GitHub 3 years ago
parent
commit
be12fe959c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 6 deletions
  1. +11
    -6
      libjack/thread.c

+ 11
- 6
libjack/thread.c View File

@@ -279,7 +279,12 @@ jack_process_already_has_real_time_scheduling (int priority)
int res;
struct rtprio rtp;
res = rtprio(RTP_LOOKUP, getpid(), &rtp);
if (res == 0 && rtp.type == RTP_PRIO_REALTIME && rtp.prio <= priority) {
if (res) {
jack_error("failed to read realtime priority of the process (error=%d: %s)",
res, strerror (res));
return 0; // act like priority isn't sufficient
}
if (rtp.type == RTP_PRIO_REALTIME && rtp.prio <= priority) {
jack_info("process already runs at sufficient realtime priority %u (<=%d)",
(unsigned)rtp.prio,
priority);
@@ -296,8 +301,8 @@ jack_drop_real_time_scheduling (pthread_t thread)
int x, policy;

if ((x = pthread_getschedparam (thread, &policy, &rtparam)) != 0) {
jack_error ("cannot read thread scheduling priority(%s)\n",
strerror (errno));
jack_error ("cannot read thread scheduling priority (error=%d: %s)\n",
x, strerror (x));
return -1;
}
if (policy == SCHED_OTHER) {
@@ -307,8 +312,8 @@ jack_drop_real_time_scheduling (pthread_t thread)
memset (&rtparam, 0, sizeof(rtparam));

if ((x = pthread_setschedparam (thread, SCHED_OTHER, &rtparam)) != 0) {
jack_error ("cannot switch to normal scheduling priority(%s)\n",
strerror (errno));
jack_error ("cannot switch to normal scheduling priority (error=%d: %s)\n",
x, strerror (x));
return -1;
}

@@ -330,7 +335,7 @@ jack_acquire_real_time_scheduling (pthread_t thread, int priority)

if ((x = pthread_setschedparam (thread, SCHED_FIFO, &rtparam)) != 0) {
jack_error ("cannot use real-time scheduling (FIFO at priority %d) "
"[for thread %d, from thread %d] (%d: %s)",
"[for thread %d, from thread %d] (error=%d: %s)",
rtparam.sched_priority,
thread, pthread_self (),
x, strerror (x));


Loading…
Cancel
Save