git-svn-id: svn+ssh://jackaudio.org/trunk/jack@893 0c269be4-1314-0410-8aa9-9f06e86f4224tags/0.109.0
@@ -15,7 +15,7 @@ dnl changes are made | |||||
dnl --- | dnl --- | ||||
JACK_MAJOR_VERSION=0 | JACK_MAJOR_VERSION=0 | ||||
JACK_MINOR_VERSION=99 | JACK_MINOR_VERSION=99 | ||||
JACK_MICRO_VERSION=60 | |||||
JACK_MICRO_VERSION=61 | |||||
dnl --- | dnl --- | ||||
dnl HOWTO: updating the jack protocol version | dnl HOWTO: updating the jack protocol version | ||||
@@ -655,12 +655,12 @@ static int oss_driver_start (oss_driver_t *driver) | |||||
driver->threads = 0; | driver->threads = 0; | ||||
if (infd >= 0) | if (infd >= 0) | ||||
{ | { | ||||
if (jack_create_thread(NULL, &driver->thread_in, | |||||
if (jack_client_create_thread(NULL, &driver->thread_in, | |||||
driver->engine->rtpriority, | driver->engine->rtpriority, | ||||
driver->engine->control->real_time, | driver->engine->control->real_time, | ||||
io_thread, driver) < 0) | io_thread, driver) < 0) | ||||
{ | { | ||||
jack_error("OSS: jack_create_thread() failed: %s@%i", | |||||
jack_error("OSS: jack_client_create_thread() failed: %s@%i", | |||||
__FILE__, __LINE__); | __FILE__, __LINE__); | ||||
return -1; | return -1; | ||||
} | } | ||||
@@ -669,12 +669,12 @@ static int oss_driver_start (oss_driver_t *driver) | |||||
# ifdef USE_BARRIER | # ifdef USE_BARRIER | ||||
if (outfd >= 0) | if (outfd >= 0) | ||||
{ | { | ||||
if (jack_create_thread(NULL, &driver->thread_out, | |||||
if (jack_client_create_thread(NULL, &driver->thread_out, | |||||
driver->engine->rtpriority, | driver->engine->rtpriority, | ||||
driver->engine->control->real_time, | driver->engine->control->real_time, | ||||
io_thread, driver) < 0) | io_thread, driver) < 0) | ||||
{ | { | ||||
jack_error("OSS: jack_create_thread() failed: %s@%i", | |||||
jack_error("OSS: jack_client_create_thread() failed: %s@%i", | |||||
__FILE__, __LINE__); | __FILE__, __LINE__); | ||||
return -1; | return -1; | ||||
} | } | ||||
@@ -62,12 +62,12 @@ int jack_acquire_real_time_scheduling (pthread_t thread, int priority); | |||||
* | * | ||||
* @returns 0, if successful; otherwise some error number. | * @returns 0, if successful; otherwise some error number. | ||||
*/ | */ | ||||
int jack_create_thread (jack_client_t* client, | |||||
pthread_t *thread, | |||||
int priority, | |||||
int realtime, /* boolean */ | |||||
void *(*start_routine)(void*), | |||||
void *arg); | |||||
int jack_client_create_thread (jack_client_t* client, | |||||
pthread_t *thread, | |||||
int priority, | |||||
int realtime, /* boolean */ | |||||
void *(*start_routine)(void*), | |||||
void *arg); | |||||
/** | /** | ||||
* Drop realtime scheduling for a thread. | * Drop realtime scheduling for a thread. | ||||
@@ -930,8 +930,8 @@ jack_start_watchdog (jack_engine_t *engine) | |||||
(max_priority < watchdog_priority)) | (max_priority < watchdog_priority)) | ||||
watchdog_priority = max_priority; | watchdog_priority = max_priority; | ||||
if (jack_create_thread (NULL, &engine->watchdog_thread, watchdog_priority, | |||||
TRUE, jack_watchdog_thread, engine)) { | |||||
if (jack_client_create_thread (NULL, &engine->watchdog_thread, watchdog_priority, | |||||
TRUE, jack_watchdog_thread, engine)) { | |||||
jack_error ("cannot start watchdog thread"); | jack_error ("cannot start watchdog thread"); | ||||
return -1; | return -1; | ||||
} | } | ||||
@@ -1475,8 +1475,7 @@ jack_server_thread (void *arg) | |||||
&client_addrlen)) < 0) { | &client_addrlen)) < 0) { | ||||
jack_error ("cannot accept new connection (%s)", | jack_error ("cannot accept new connection (%s)", | ||||
strerror (errno)); | strerror (errno)); | ||||
} else if (jack_client_create (engine, client_socket) | |||||
< 0) { | |||||
} else if (jack_client_create (engine, client_socket) < 0) { | |||||
jack_error ("cannot complete client " | jack_error ("cannot complete client " | ||||
"connection process"); | "connection process"); | ||||
close (client_socket); | close (client_socket); | ||||
@@ -1742,8 +1741,8 @@ jack_engine_new (int realtime, int rtpriority, int do_mlock, int do_unlock, | |||||
(void) jack_get_fifo_fd (engine, 0); | (void) jack_get_fifo_fd (engine, 0); | ||||
jack_create_thread (NULL, &engine->server_thread, 0, FALSE, | |||||
&jack_server_thread, engine); | |||||
jack_client_create_thread (NULL, &engine->server_thread, 0, FALSE, | |||||
&jack_server_thread, engine); | |||||
return engine; | return engine; | ||||
} | } | ||||
@@ -1855,8 +1854,8 @@ jack_start_freewheeling (jack_engine_t* engine) | |||||
event.type = StartFreewheel; | event.type = StartFreewheel; | ||||
jack_deliver_event_to_all (engine, &event); | jack_deliver_event_to_all (engine, &event); | ||||
if (jack_create_thread (NULL, &engine->freewheel_thread, 0, FALSE, | |||||
jack_engine_freewheel, engine)) { | |||||
if (jack_client_create_thread (NULL, &engine->freewheel_thread, 0, FALSE, | |||||
jack_engine_freewheel, engine)) { | |||||
jack_error ("could not start create freewheel thread"); | jack_error ("could not start create freewheel thread"); | ||||
return -1; | return -1; | ||||
} | } | ||||
@@ -1,3 +1,12 @@ | |||||
2005-04-15 Paul Davis <paul> | |||||
* change the way threads get RT scheduling. it is now requested by | |||||
the thread rather than assigned by the thread's parent. in cases | |||||
where capabilities are used, the child is also given capabilities | |||||
so that it can release + re-acquire RT scheduling as needed. | |||||
* prevent watchdog from killing anything is JACK is freewheeling. | |||||
2004-12-31 Jack O'Quin <joq@io.com> | 2004-12-31 Jack O'Quin <joq@io.com> | ||||
* new header file: <jack/statistics.h> | * new header file: <jack/statistics.h> | ||||
@@ -1478,15 +1478,15 @@ jack_start_thread (jack_client_t *client) | |||||
/* Stephane Letz : letz@grame.fr | /* Stephane Letz : letz@grame.fr | ||||
On MacOSX, the normal thread does not need to be real-time. | On MacOSX, the normal thread does not need to be real-time. | ||||
*/ | */ | ||||
if (jack_create_thread (client, | |||||
&client->thread, | |||||
client->engine->client_priority, | |||||
FALSE, | |||||
jack_client_thread, client)) { | |||||
if (jack_client_create_thread (client, | |||||
&client->thread, | |||||
client->engine->client_priority, | |||||
FALSE, | |||||
jack_client_thread, client)) { | |||||
return -1; | return -1; | ||||
} | } | ||||
#else | #else | ||||
if (jack_create_thread (client, | |||||
if (jack_client_create_thread (client, | |||||
&client->thread, | &client->thread, | ||||
client->engine->client_priority, | client->engine->client_priority, | ||||
client->engine->real_time, | client->engine->real_time, | ||||
@@ -1508,11 +1508,11 @@ jack_start_thread (jack_client_t *client) | |||||
*/ | */ | ||||
if (jack_create_thread(client, | |||||
&client->process_thread, | |||||
client->engine->client_priority, | |||||
client->engine->real_time, | |||||
jack_client_process_thread, client)) { | |||||
if (jack_client_create_thread(client, | |||||
&client->process_thread, | |||||
client->engine->client_priority, | |||||
client->engine->real_time, | |||||
jack_client_process_thread, client)) { | |||||
return -1; | return -1; | ||||
} | } | ||||
#endif /* JACK_USE_MACH_THREADS */ | #endif /* JACK_USE_MACH_THREADS */ | ||||
@@ -148,11 +148,11 @@ jack_driver_nt_start (jack_driver_nt_t * driver) | |||||
pthread_mutex_lock (&driver->nt_run_lock); | pthread_mutex_lock (&driver->nt_run_lock); | ||||
driver->nt_run = DRIVER_NT_RUN; | driver->nt_run = DRIVER_NT_RUN; | ||||
if ((err = jack_create_thread (NULL, | |||||
&driver->nt_thread, | |||||
driver->engine->rtpriority, | |||||
driver->engine->control->real_time, | |||||
jack_driver_nt_thread, driver)) != 0) { | |||||
if ((err = jack_client_create_thread (NULL, | |||||
&driver->nt_thread, | |||||
driver->engine->rtpriority, | |||||
driver->engine->control->real_time, | |||||
jack_driver_nt_thread, driver)) != 0) { | |||||
jack_error ("DRIVER NT: could not start driver thread!"); | jack_error ("DRIVER NT: could not start driver thread!"); | ||||
driver->nt_stop (driver); | driver->nt_stop (driver); | ||||
return err; | return err; | ||||
@@ -45,77 +45,62 @@ log_result (char *msg, int res) | |||||
{ | { | ||||
char outbuf[500]; | char outbuf[500]; | ||||
snprintf(outbuf, sizeof(outbuf), | snprintf(outbuf, sizeof(outbuf), | ||||
"jack_create_thread: error %d %s: %s", | |||||
"jack_client_create_thread: error %d %s: %s", | |||||
res, msg, strerror(res)); | res, msg, strerror(res)); | ||||
jack_error(outbuf); | jack_error(outbuf); | ||||
} | } | ||||
static void* | |||||
jack_thread_proxy (jack_thread_arg_t* arg) | |||||
static void | |||||
maybe_get_capabilities (jack_client_t* client) | |||||
{ | { | ||||
void* (*work)(void*); | |||||
void* warg; | |||||
jack_client_t* client = arg->client; | |||||
int try_rt = 0; | |||||
if (arg->realtime) { | |||||
#ifdef USE_CAPABILITIES | #ifdef USE_CAPABILITIES | ||||
if (client == 0) { | |||||
/* we're creating a thread within jackd itself, don't | |||||
bother trying to acquire capabilities because either | |||||
jackd has them or it doesn't. | |||||
if (client != 0) { | |||||
jack_request_t req; | |||||
if (client->engine->has_capabilities != 0) { | |||||
/* we need to ask the engine for realtime capabilities | |||||
before trying to run the thread work function | |||||
*/ | */ | ||||
try_rt = 1; | |||||
} else { | |||||
jack_request_t req; | |||||
if (client->engine->has_capabilities != 0 && | |||||
client->control->pid != 0 && | |||||
client->engine->real_time != 0) { | |||||
req.type = SetClientCapabilities; | |||||
req.x.cap_pid = getpid(); | |||||
jack_client_deliver_request (client, &req); | |||||
if (req.status) { | |||||
/* we need to ask the engine for realtime capabilities | |||||
before trying to run the thread work function | |||||
/* what to do? engine is running realtime, it | |||||
is using capabilities and has them | |||||
(otherwise we would not get an error | |||||
return) but for some reason it could not | |||||
give the client the required capabilities. | |||||
for now, allow the client to run, albeit | |||||
non-realtime. | |||||
*/ | */ | ||||
req.type = SetClientCapabilities; | |||||
req.x.cap_pid = getpid(); | |||||
jack_client_deliver_request (client, &req); | |||||
jack_error ("could not receive realtime capabilities, " | |||||
"client will run non-realtime"); | |||||
if (req.status) { | |||||
/* what to do? engine is running realtime, it | |||||
is using capabilities and has them | |||||
(otherwise we would not get an error | |||||
return) but for some reason it could not | |||||
give the client the required capabilities. | |||||
for now, allow the client to run, albeit | |||||
non-realtime. | |||||
*/ | |||||
jack_error ("could not receive realtime capabilities, " | |||||
"client will run non-realtime"); | |||||
} else { | |||||
try_rt = 1; | |||||
} | |||||
} | } | ||||
} | } | ||||
#else /* !USE_CAPABILITIES */ | |||||
} | |||||
#endif /* USE_CAPABILITIES */ | |||||
} | |||||
try_rt = 1; | |||||
static void* | |||||
jack_thread_proxy (void* varg) | |||||
{ | |||||
jack_thread_arg_t* arg = (jack_thread_arg_t*) varg; | |||||
void* (*work)(void*); | |||||
void* warg; | |||||
jack_client_t* client = arg->client; | |||||
#endif /* USE_CAPABILITIES */ | |||||
if (try_rt) { | |||||
jack_acquire_real_time_scheduling (pthread_self(), arg->priority); | |||||
} | |||||
if (arg->realtime) { | |||||
maybe_get_capabilities (client); | |||||
jack_acquire_real_time_scheduling (pthread_self(), arg->priority); | |||||
} | } | ||||
warg = arg->arg; | warg = arg->arg; | ||||
@@ -127,19 +112,15 @@ jack_thread_proxy (jack_thread_arg_t* arg) | |||||
} | } | ||||
int | int | ||||
jack_create_thread (jack_client_t* client, | |||||
pthread_t* thread, | |||||
int priority, | |||||
int realtime, | |||||
void*(*start_routine)(void*), | |||||
void* arg) | |||||
jack_client_create_thread (jack_client_t* client, | |||||
pthread_t* thread, | |||||
int priority, | |||||
int realtime, | |||||
void*(*start_routine)(void*), | |||||
void* arg) | |||||
{ | { | ||||
#ifndef JACK_USE_MACH_THREADS | #ifndef JACK_USE_MACH_THREADS | ||||
pthread_attr_t attr; | pthread_attr_t attr; | ||||
int policy; | |||||
struct sched_param param; | |||||
int actual_policy; | |||||
struct sched_param actual_param; | |||||
jack_thread_arg_t* thread_args; | jack_thread_arg_t* thread_args; | ||||
#endif /* !JACK_USE_MACH_THREADS */ | #endif /* !JACK_USE_MACH_THREADS */ | ||||