All pastes #1759890 Raw Edit

Mine

public text v1 · immutable
#1759890 ·published 2010-01-21 07:26 UTC
rendered paste body
=== modified file 'mixxx/src/sounddeviceportaudio.cpp'
--- mixxx/src/sounddeviceportaudio.cpp	2010-01-20 21:14:02 +0000
+++ mixxx/src/sounddeviceportaudio.cpp	2010-01-20 22:21:39 +0000
@@ -19,6 +19,8 @@
 #include <QtCore>
 #include <portaudio.h>
 #include <assert.h>
+#include <sched.h>
+#include <pthread.h>
 #include "controlobjectthreadmain.h"
 #include "soundmanager.h"
 #include "sounddevice.h"
@@ -307,8 +309,35 @@
     // Turn on TimeCritical priority for the callback thread. If we are running
     // in Linux userland, for example, this will have no effect.
     if(!m_bSetThreadPriority) {
+        int sched_policy;
+        sched_param param;
+        if (pthread_getschedparam(pthread_self(), &sched_policy, &param) != 0) {
+            // failed to get the scheduling policy, don't bother setting
+            // the priority
+            qWarning("QThread::setPriority: Cannot get scheduler parameters");
+        }
+        int prio_min = sched_get_priority_min(sched_policy);
+        int prio_max = sched_get_priority_max(sched_policy);
+        qDebug() << "sched_policy" << sched_policy
+                 << "priority" << param.sched_priority
+                 << "priomin" << prio_min
+                 << "priomax" << prio_max;
+
         QThread::currentThread()->setPriority(QThread::TimeCriticalPriority);
         m_bSetThreadPriority = true;
+
+        if (pthread_getschedparam(pthread_self(), &sched_policy, &param) != 0) {
+            // failed to get the scheduling policy, don't bother setting
+            // the priority
+            qWarning("QThread::setPriority: Cannot get scheduler parameters");
+        }
+        prio_min = sched_get_priority_min(sched_policy);
+        prio_max = sched_get_priority_max(sched_policy);
+        qDebug() << "sched_policy" << sched_policy
+                 << "priority" << param.sched_priority
+                 << "priomin" << prio_min
+                 << "priomax" << prio_max;
+
     }
 
     //Send audio from the soundcard's input off to the SoundManager...