ALSA rt-thread priority fixes

This commit is contained in:
Robin Gareus 2014-06-06 20:37:00 +02:00
parent b68d2e25b2
commit c452cd9be2
3 changed files with 12 additions and 10 deletions

View file

@ -491,7 +491,7 @@ AlsaAudioBackend::_start (bool for_latency_measurement)
_run = true; _run = true;
_port_change_flag = false; _port_change_flag = false;
if (_realtime_pthread_create (SCHED_FIFO, -20, if (_realtime_pthread_create (SCHED_FIFO, -20, 100000,
&_main_thread, pthread_process, this)) &_main_thread, pthread_process, this))
{ {
if (pthread_create (&_main_thread, NULL, 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; pthread_attr_t attr;
size_t stacksize = 100000; size_t stacksize = 100000;
pthread_attr_init (&attr);
pthread_attr_setstacksize (&attr, stacksize);
ThreadData* td = new ThreadData (this, func, stacksize); ThreadData* td = new ThreadData (this, func, stacksize);
if (pthread_create (&thread_id, &attr, alsa_process_thread, td)) { if (_realtime_pthread_create (SCHED_FIFO, -21, stacksize,
PBD::error << _("AudioEngine: cannot create process thread.") << endmsg; &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); pthread_attr_destroy (&attr);
return -1;
} }
pthread_attr_destroy (&attr);
_threads.push_back (thread_id); _threads.push_back (thread_id);
return 0; return 0;

View file

@ -134,7 +134,7 @@ static void * pthread_process (void *arg)
int int
AlsaRawMidiIO::start () AlsaRawMidiIO::start ()
{ {
if (_realtime_pthread_create (SCHED_FIFO, -19, if (_realtime_pthread_create (SCHED_FIFO, -21, 100000,
&_main_thread, pthread_process, this)) &_main_thread, pthread_process, this))
{ {
if (pthread_create (&_main_thread, NULL, pthread_process, this)) { if (pthread_create (&_main_thread, NULL, pthread_process, this)) {

View file

@ -24,7 +24,7 @@
static int static int
_realtime_pthread_create ( _realtime_pthread_create (
int policy, int priority, const int policy, int priority, const size_t stacksize,
pthread_t *thread, pthread_t *thread,
void *(*start_routine) (void *), void *(*start_routine) (void *),
void *arg) void *arg)
@ -33,7 +33,6 @@ _realtime_pthread_create (
pthread_attr_t attr; pthread_attr_t attr;
struct sched_param parm; struct sched_param parm;
const size_t stacksize = 100000;
const int p_min = sched_get_priority_min (policy); const int p_min = sched_get_priority_min (policy);
const int p_max = sched_get_priority_max (policy); const int p_max = sched_get_priority_max (policy);