Browse Source

Fix JackPosixThread::StartImp and JackWinThread::StartImp.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@2236 0c269be4-1314-0410-8aa9-9f06e86f4224
tags/1.90
sletz 17 years ago
parent
commit
a888803871
3 changed files with 52 additions and 68 deletions
  1. +5
    -1
      ChangeLog
  2. +37
    -48
      common/JackPosixThread.cpp
  3. +10
    -19
      windows/JackWinThread.cpp

+ 5
- 1
ChangeLog View File

@@ -20,10 +20,14 @@ Fernando Lopez-Lezcano
Jackdmp changes log
---------------------------

2008-05-06 Stephane Letz <letz@grame.fr>

* Fix JackPosixThread::StartImp and JackWinThread::StartImp.

2008-05-05 Stephane Letz <letz@grame.fr>

* Fix JackClient::Close : notification channel is stopped first to avoid receiving notifications while closing and Close is again a synchronous call.
* No more client close in JackEngine::Close().
* No more remaining client close in JackEngine::Close().

2008-05-01 Stephane Letz <letz@grame.fr>



+ 37
- 48
common/JackPosixThread.cpp View File

@@ -69,69 +69,58 @@ int JackPosixThread::Start()

int JackPosixThread::StartImp(pthread_t* thread, int priority, int realtime, void*(*start_routine)(void*), void* arg)
{
pthread_attr_t attributes;
struct sched_param rt_param;
pthread_attr_init(&attributes);
int res;

if (realtime) {

jack_log("Create RT thread");

/* Get the client thread to run as an RT-FIFO
scheduled thread of appropriate priority.
*/
pthread_attr_t attributes;
struct sched_param rt_param;
pthread_attr_init(&attributes);

if ((res = pthread_attr_setinheritsched(&attributes, PTHREAD_EXPLICIT_SCHED))) {
jack_error("Cannot request explicit scheduling for RT thread %d %s", res, strerror(errno));
return -1;
}
if ((res = pthread_attr_setinheritsched(&attributes, PTHREAD_EXPLICIT_SCHED))) {
jack_error("Cannot request explicit scheduling for RT thread %d %s", res, strerror(errno));
return -1;
}

if ((res = pthread_attr_setdetachstate(&attributes, PTHREAD_CREATE_JOINABLE))) {
jack_error("Cannot request joinable thread creation for RT thread %d %s", res, strerror(errno));
return -1;
}
if ((res = pthread_attr_setdetachstate(&attributes, PTHREAD_CREATE_JOINABLE))) {
jack_error("Cannot request joinable thread creation for RT thread %d %s", res, strerror(errno));
return -1;
}

if ((res = pthread_attr_setscope(&attributes, PTHREAD_SCOPE_SYSTEM))) {
jack_error("Cannot set scheduling scope for RT thread %d %s", res, strerror(errno));
return -1;
}
if ((res = pthread_attr_setscope(&attributes, PTHREAD_SCOPE_SYSTEM))) {
jack_error("Cannot set scheduling scope for RT thread %d %s", res, strerror(errno));
return -1;
}

if (realtime) {
jack_log("Create RT thread");
//if ((res = pthread_attr_setschedpolicy(&attributes, SCHED_FIFO))) {

if ((res = pthread_attr_setschedpolicy(&attributes, SCHED_RR))) {
jack_error("Cannot set RR scheduling class for RT thread %d %s", res, strerror(errno));
return -1;
}
} else {
jack_log("Create non RT thread");
}

memset(&rt_param, 0, sizeof(rt_param));
rt_param.sched_priority = priority;

if ((res = pthread_attr_setschedparam(&attributes, &rt_param))) {
jack_error("Cannot set scheduling priority for RT thread %d %s", res, strerror(errno));
return -1;
}

if ((res = pthread_attr_setstacksize(&attributes, THREAD_STACK))) {
jack_error("setting thread stack size%d %s", res, strerror(errno));
return -1;
}
memset(&rt_param, 0, sizeof(rt_param));
rt_param.sched_priority = priority;

if ((res = pthread_create(thread, &attributes, start_routine, arg))) {
jack_error("Cannot set create thread %d %s", res, strerror(errno));
return -1;
}
if ((res = pthread_attr_setschedparam(&attributes, &rt_param))) {
jack_error("Cannot set scheduling priority for RT thread %d %s", res, strerror(errno));
return -1;
}

return 0;
} else {
jack_log("Create non RT thread");
if ((res = pthread_attr_setstacksize(&attributes, THREAD_STACK))) {
jack_error("setting thread stack size%d %s", res, strerror(errno));
return -1;
}

if ((res = pthread_create(thread, 0, start_routine, arg))) {
jack_error("Cannot set create thread %d %s", res, strerror(errno));
return -1;
}
return 0;
if ((res = pthread_create(thread, &attributes, start_routine, arg))) {
jack_error("Cannot set create thread %d %s", res, strerror(errno));
return -1;
}

return 0;
}

int JackPosixThread::StartSync()


+ 10
- 19
windows/JackWinThread.cpp View File

@@ -93,36 +93,27 @@ int JackWinThread::Start()
int JackWinThread::StartImp(pthread_t* thread, int priority, int realtime, ThreadCallback start_routine, void* arg)
{
DWORD id;
*thread = CreateThread(NULL, 0, start_routine, arg, 0, &id);

if (realtime) {
if (*thread == NULL) {
jack_error("Cannot create thread error = %d", GetLastError());
return -1;
}

if (realtime) {
jack_log("Create RT thread");
*thread = CreateThread(NULL, 0, start_routine, arg, 0, &id);

if (*thread == NULL) {
jack_error("Cannot create thread error = %d", GetLastError());
return -1;
}

if (!SetThreadPriority(*thread, THREAD_PRIORITY_TIME_CRITICAL)) {
jack_error("Cannot set priority class = %d", GetLastError());
return -1;
}

return 0;

} else {

jack_log("Create non RT thread");
*thread = CreateThread(NULL, 0, start_routine, arg, 0, &id);

if (thread == NULL) {
jack_error("Cannot create thread error = %d", GetLastError());
return -1;
}

return 0;
}
return 0;
}

int JackWinThread::StartSync()


Loading…
Cancel
Save