ALSA rt-thread priority fixes
authorRobin Gareus <robin@gareus.org>
Fri, 6 Jun 2014 18:37:00 +0000 (20:37 +0200)
committerRobin Gareus <robin@gareus.org>
Sat, 7 Jun 2014 15:28:46 +0000 (17:28 +0200)
libs/backends/alsa/alsa_audiobackend.cc
libs/backends/alsa/alsa_rawmidi.cc
libs/backends/alsa/rt_thread.h

index e5b38760c4688b58728e00d008af1f7436bb9a04..cec72418a4ce2352260037a8c5003e00ab542a8c 100644 (file)
@@ -491,7 +491,7 @@ AlsaAudioBackend::_start (bool for_latency_measurement)
        _run = true;
        _port_change_flag = false;
 
-       if (_realtime_pthread_create (SCHED_FIFO, -20,
+       if (_realtime_pthread_create (SCHED_FIFO, -20, 100000,
                                &_main_thread, pthread_process, this))
        {
                if (pthread_create (&_main_thread, NULL, pthread_process, this))
@@ -620,16 +620,19 @@ AlsaAudioBackend::create_process_thread (boost::function<void()> func)
        pthread_attr_t attr;
        size_t stacksize = 100000;
 
-       pthread_attr_init (&attr);
-       pthread_attr_setstacksize (&attr, stacksize);
        ThreadData* td = new ThreadData (this, func, stacksize);
 
-       if (pthread_create (&thread_id, &attr, alsa_process_thread, td)) {
-               PBD::error << _("AudioEngine: cannot create process thread.") << endmsg;
+       if (_realtime_pthread_create (SCHED_FIFO, -21, stacksize,
+                               &thread_id, alsa_process_thread, td)) {
+               pthread_attr_init (&attr);
+               pthread_attr_setstacksize (&attr, stacksize);
+               if (pthread_create (&thread_id, &attr, alsa_process_thread, td)) {
+                       PBD::error << _("AudioEngine: cannot create process thread.") << endmsg;
+                       pthread_attr_destroy (&attr);
+                       return -1;
+               }
                pthread_attr_destroy (&attr);
-               return -1;
        }
-       pthread_attr_destroy (&attr);
 
        _threads.push_back (thread_id);
        return 0;
index 035860c259540ea19de243a0ced765663f7523a6..00fc39a4cf5f8fa14c12d268f8b99badcb1bf887 100644 (file)
@@ -134,7 +134,7 @@ static void * pthread_process (void *arg)
 int
 AlsaRawMidiIO::start ()
 {
-       if (_realtime_pthread_create (SCHED_FIFO, -19,
+       if (_realtime_pthread_create (SCHED_FIFO, -21, 100000,
                                &_main_thread, pthread_process, this))
        {
                if (pthread_create (&_main_thread, NULL, pthread_process, this)) {
index 68749ab7c3ef01cc1033827c26c000e6e89a38dc..3d2efe2063ee9183470aaf84e927943701c2b693 100644 (file)
@@ -24,7 +24,7 @@
 
 static int
 _realtime_pthread_create (
-               int policy, int priority,
+               const int policy, int priority, const size_t stacksize,
                pthread_t *thread,
                void *(*start_routine) (void *),
                void *arg)
@@ -33,7 +33,6 @@ _realtime_pthread_create (
 
        pthread_attr_t attr;
        struct sched_param parm;
-       const size_t stacksize = 100000;
 
        const int p_min = sched_get_priority_min (policy);
        const int p_max = sched_get_priority_max (policy);