git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@1909 0c269be4-1314-0410-8aa9-9f06e86f4224tags/0.71
@@ -31,11 +31,11 @@ extern "C" | |||||
{ | { | ||||
#endif | #endif | ||||
EXPORT jack_client_t * jack_client_open (const char *client_name, | |||||
EXPORT jack_client_t * jack_client_open (const char *client_name, | |||||
jack_options_t options, | jack_options_t options, | ||||
jack_status_t *status, ...); | jack_status_t *status, ...); | ||||
EXPORT jack_client_t * jack_client_new (const char *client_name); | EXPORT jack_client_t * jack_client_new (const char *client_name); | ||||
EXPORT int jack_client_name_size (void); | |||||
EXPORT int jack_client_name_size (void); | |||||
EXPORT char* jack_get_client_name (jack_client_t *client); | EXPORT char* jack_get_client_name (jack_client_t *client); | ||||
EXPORT int jack_internal_client_new (const char *client_name, | EXPORT int jack_internal_client_new (const char *client_name, | ||||
const char *load_name, | const char *load_name, | ||||
@@ -47,13 +47,13 @@ extern "C" | |||||
EXPORT int jack_set_process_callback (jack_client_t *client, | EXPORT int jack_set_process_callback (jack_client_t *client, | ||||
JackProcessCallback process_callback, | JackProcessCallback process_callback, | ||||
void *arg); | void *arg); | ||||
// | |||||
EXPORT jack_nframes_t jack_thread_wait(jack_client_t *client, int status); | |||||
// new | |||||
EXPORT jack_nframes_t jack_cycle_wait (jack_client_t*); | |||||
EXPORT void jack_cycle_signal (jack_client_t*, int status); | |||||
EXPORT int jack_set_process_thread(jack_client_t* client, JackThreadCallback fun, void *arg); | |||||
// | |||||
EXPORT jack_nframes_t jack_thread_wait(jack_client_t *client, int status); | |||||
// new | |||||
EXPORT jack_nframes_t jack_cycle_wait (jack_client_t*); | |||||
EXPORT void jack_cycle_signal (jack_client_t*, int status); | |||||
EXPORT int jack_set_process_thread(jack_client_t* client, JackThreadCallback fun, void *arg); | |||||
EXPORT int jack_set_thread_init_callback (jack_client_t *client, | EXPORT int jack_set_thread_init_callback (jack_client_t *client, | ||||
JackThreadInitCallback thread_init_callback, | JackThreadInitCallback thread_init_callback, | ||||
void *arg); | void *arg); | ||||
@@ -68,18 +68,18 @@ extern "C" | |||||
EXPORT int jack_set_sample_rate_callback (jack_client_t *client, | EXPORT int jack_set_sample_rate_callback (jack_client_t *client, | ||||
JackSampleRateCallback srate_callback, | JackSampleRateCallback srate_callback, | ||||
void *arg); | void *arg); | ||||
// | |||||
EXPORT int jack_set_client_registration_callback (jack_client_t *, | |||||
JackClientRegistrationCallback | |||||
registration_callback, void *arg); | |||||
EXPORT int jack_set_port_registration_callback (jack_client_t *, | |||||
// | |||||
EXPORT int jack_set_client_registration_callback (jack_client_t *, | |||||
JackClientRegistrationCallback | |||||
registration_callback, void *arg); | |||||
EXPORT int jack_set_port_registration_callback (jack_client_t *, | |||||
JackPortRegistrationCallback | JackPortRegistrationCallback | ||||
registration_callback, void *arg); | registration_callback, void *arg); | ||||
// | |||||
EXPORT int jack_set_port_connect_callback (jack_client_t *, | |||||
JackPortConnectCallback | |||||
connect_callback, void *arg); | |||||
// | |||||
EXPORT int jack_set_port_connect_callback (jack_client_t *, | |||||
JackPortConnectCallback | |||||
connect_callback, void *arg); | |||||
EXPORT int jack_set_graph_order_callback (jack_client_t *, | EXPORT int jack_set_graph_order_callback (jack_client_t *, | ||||
JackGraphOrderCallback graph_callback, | JackGraphOrderCallback graph_callback, | ||||
void *); | void *); | ||||
@@ -111,14 +111,14 @@ extern "C" | |||||
EXPORT jack_nframes_t jack_port_get_total_latency (jack_client_t *, | EXPORT jack_nframes_t jack_port_get_total_latency (jack_client_t *, | ||||
jack_port_t *port); | jack_port_t *port); | ||||
EXPORT void jack_port_set_latency (jack_port_t *, jack_nframes_t); | EXPORT void jack_port_set_latency (jack_port_t *, jack_nframes_t); | ||||
// | |||||
// | |||||
EXPORT int jack_recompute_total_latency (jack_client_t*, jack_port_t* port); | EXPORT int jack_recompute_total_latency (jack_client_t*, jack_port_t* port); | ||||
EXPORT int jack_recompute_total_latencies (jack_client_t*); | EXPORT int jack_recompute_total_latencies (jack_client_t*); | ||||
EXPORT int jack_port_set_name (jack_port_t *port, const char *port_name); | EXPORT int jack_port_set_name (jack_port_t *port, const char *port_name); | ||||
// | |||||
EXPORT int jack_port_set_alias (jack_port_t *port, const char *alias); | |||||
EXPORT int jack_port_unset_alias (jack_port_t *port, const char *alias); | |||||
EXPORT int jack_port_get_aliases (const jack_port_t *port, char* const aliases[2]); | |||||
// | |||||
EXPORT int jack_port_set_alias (jack_port_t *port, const char *alias); | |||||
EXPORT int jack_port_unset_alias (jack_port_t *port, const char *alias); | |||||
EXPORT int jack_port_get_aliases (const jack_port_t *port, char* const aliases[2]); | |||||
EXPORT int jack_port_request_monitor (jack_port_t *port, int onoff); | EXPORT int jack_port_request_monitor (jack_port_t *port, int onoff); | ||||
EXPORT int jack_port_request_monitor_by_name (jack_client_t *client, | EXPORT int jack_port_request_monitor_by_name (jack_client_t *client, | ||||
const char *port_name, int onoff); | const char *port_name, int onoff); | ||||
@@ -144,11 +144,11 @@ extern "C" | |||||
jack_port_id_t port_id); | jack_port_id_t port_id); | ||||
EXPORT int jack_engine_takeover_timebase (jack_client_t *); | EXPORT int jack_engine_takeover_timebase (jack_client_t *); | ||||
EXPORT jack_nframes_t jack_frames_since_cycle_start (const jack_client_t *); | EXPORT jack_nframes_t jack_frames_since_cycle_start (const jack_client_t *); | ||||
// | |||||
EXPORT jack_time_t jack_get_time(); | |||||
// | |||||
EXPORT jack_time_t jack_get_time(); | |||||
EXPORT jack_nframes_t jack_time_to_frames(const jack_client_t *client, jack_time_t time); | EXPORT jack_nframes_t jack_time_to_frames(const jack_client_t *client, jack_time_t time); | ||||
EXPORT jack_time_t jack_frames_to_time(const jack_client_t *client, jack_nframes_t frames); | EXPORT jack_time_t jack_frames_to_time(const jack_client_t *client, jack_nframes_t frames); | ||||
EXPORT jack_nframes_t jack_frame_time (const jack_client_t *); | EXPORT jack_nframes_t jack_frame_time (const jack_client_t *); | ||||
EXPORT jack_nframes_t jack_last_frame_time (const jack_client_t *client); | EXPORT jack_nframes_t jack_last_frame_time (const jack_client_t *client); | ||||
EXPORT float jack_cpu_load (jack_client_t *client); | EXPORT float jack_cpu_load (jack_client_t *client); | ||||
@@ -203,8 +203,8 @@ extern "C" | |||||
jack_status_t *status, ...); | jack_status_t *status, ...); | ||||
EXPORT jack_status_t jack_internal_client_unload (jack_client_t *client, | EXPORT jack_status_t jack_internal_client_unload (jack_client_t *client, | ||||
jack_intclient_t intclient); | jack_intclient_t intclient); | ||||
EXPORT jack_client_t * jack_client_open (const char *client_name, | |||||
EXPORT jack_client_t * jack_client_open (const char *client_name, | |||||
jack_options_t options, | jack_options_t options, | ||||
jack_status_t *status, ...); | jack_status_t *status, ...); | ||||
EXPORT jack_client_t * jack_client_new (const char *client_name); | EXPORT jack_client_t * jack_client_new (const char *client_name); | ||||
@@ -220,7 +220,7 @@ typedef void* (*jack_port_get_buffer_fun_def)(jack_port_t* port, jack_nframes_t | |||||
static jack_port_get_buffer_fun_def jack_port_get_buffer_fun = 0; | static jack_port_get_buffer_fun_def jack_port_get_buffer_fun = 0; | ||||
EXPORT void* jack_port_get_buffer(jack_port_t* port, jack_nframes_t frames) | EXPORT void* jack_port_get_buffer(jack_port_t* port, jack_nframes_t frames) | ||||
{ | { | ||||
return (*jack_port_get_buffer_fun)(port, frames); | |||||
return (*jack_port_get_buffer_fun)(port, frames); | |||||
} | } | ||||
typedef const char* (*jack_port_name_fun_def)(const jack_port_t* port); | typedef const char* (*jack_port_name_fun_def)(const jack_port_t* port); | ||||
@@ -283,7 +283,7 @@ typedef jack_nframes_t (*jack_port_get_latency_fun_def)(jack_port_t* port); | |||||
static jack_port_get_latency_fun_def jack_port_get_latency_fun = 0; | static jack_port_get_latency_fun_def jack_port_get_latency_fun = 0; | ||||
EXPORT jack_nframes_t jack_port_get_latency(jack_port_t* port) | EXPORT jack_nframes_t jack_port_get_latency(jack_port_t* port) | ||||
{ | { | ||||
return (*jack_port_get_latency)(port); | |||||
return (*jack_port_get_latency)(port); | |||||
} | } | ||||
typedef void (*jack_port_set_latency_fun_def)(jack_port_t* port, jack_nframes_t frames); | typedef void (*jack_port_set_latency_fun_def)(jack_port_t* port, jack_nframes_t frames); | ||||
@@ -297,14 +297,14 @@ typedef int (*jack_recompute_total_latency_fun_def)(jack_client_t* ext_client, j | |||||
static jack_recompute_total_latency_fun_def jack_recompute_total_latency_fun = 0; | static jack_recompute_total_latency_fun_def jack_recompute_total_latency_fun = 0; | ||||
EXPORT int jack_recompute_total_latency(jack_client_t* ext_client, jack_port_t* port) | EXPORT int jack_recompute_total_latency(jack_client_t* ext_client, jack_port_t* port) | ||||
{ | { | ||||
return (*jack_recompute_total_latency_fun)(ext_client, port); | |||||
return (*jack_recompute_total_latency_fun)(ext_client, port); | |||||
} | } | ||||
typedef int (*jack_recompute_total_latencies_fun_def)(jack_client_t* ext_client); | typedef int (*jack_recompute_total_latencies_fun_def)(jack_client_t* ext_client); | ||||
static jack_recompute_total_latencies_fun_def jack_recompute_total_latencies_fun = 0; | static jack_recompute_total_latencies_fun_def jack_recompute_total_latencies_fun = 0; | ||||
EXPORT int jack_recompute_total_latencies(jack_client_t* ext_client) | EXPORT int jack_recompute_total_latencies(jack_client_t* ext_client) | ||||
{ | { | ||||
return (*jack_recompute_total_latencies_fun)(ext_client); | |||||
return (*jack_recompute_total_latencies_fun)(ext_client); | |||||
} | } | ||||
typedef int (*jack_port_set_name_fun_def)(jack_port_t* port, const char* name); | typedef int (*jack_port_set_name_fun_def)(jack_port_t* port, const char* name); | ||||
@@ -537,7 +537,7 @@ typedef jack_nframes_t (*jack_get_buffer_size_fun_def)(jack_client_t* ext_client | |||||
static jack_get_buffer_size_fun_def jack_get_buffer_size_fun = 0; | static jack_get_buffer_size_fun_def jack_get_buffer_size_fun = 0; | ||||
EXPORT jack_nframes_t jack_get_buffer_size(jack_client_t* ext_client) | EXPORT jack_nframes_t jack_get_buffer_size(jack_client_t* ext_client) | ||||
{ | { | ||||
return (*jack_get_buffer_size_fun)(ext_client); | |||||
return (*jack_get_buffer_size_fun)(ext_client); | |||||
} | } | ||||
typedef const char** (*jack_get_ports_fun_def)(jack_client_t* ext_client, const char* port_name_pattern, const char* type_name_pattern, unsigned long flags); | typedef const char** (*jack_get_ports_fun_def)(jack_client_t* ext_client, const char* port_name_pattern, const char* type_name_pattern, unsigned long flags); | ||||
@@ -707,7 +707,7 @@ typedef void (*jack_transport_stop_fun_def)(jack_client_t* ext_client); | |||||
static jack_transport_stop_fun_def jack_transport_stop_fun = 0; | static jack_transport_stop_fun_def jack_transport_stop_fun = 0; | ||||
EXPORT void jack_transport_stop(jack_client_t* ext_client) | EXPORT void jack_transport_stop(jack_client_t* ext_client) | ||||
{ | { | ||||
return (*jack_transport_stop_fun)(ext_client); | |||||
return (*jack_transport_stop_fun)(ext_client); | |||||
} | } | ||||
// deprecated | // deprecated | ||||
@@ -760,16 +760,16 @@ EXPORT int jack_acquire_real_time_scheduling(pthread_t thread, int priority) | |||||
typedef void *(*start_routine)(void*); | typedef void *(*start_routine)(void*); | ||||
typedef int (*jack_client_create_thread_fun_def)(jack_client_t* client, | typedef int (*jack_client_create_thread_fun_def)(jack_client_t* client, | ||||
pthread_t *thread, | |||||
int priority, | |||||
int realtime, // boolean | |||||
start_routine callback, | |||||
void *arg); | |||||
pthread_t *thread, | |||||
int priority, | |||||
int realtime, // boolean | |||||
start_routine callback, | |||||
void *arg); | |||||
static jack_client_create_thread_fun_def jack_client_create_thread_fun = 0; | static jack_client_create_thread_fun_def jack_client_create_thread_fun = 0; | ||||
EXPORT int jack_client_create_thread(jack_client_t* client, | EXPORT int jack_client_create_thread(jack_client_t* client, | ||||
pthread_t *thread, | pthread_t *thread, | ||||
int priority, | int priority, | ||||
int realtime, // boolean | |||||
int realtime, // boolean | |||||
start_routine callback, | start_routine callback, | ||||
void *arg) | void *arg) | ||||
{ | { | ||||
@@ -803,11 +803,11 @@ typedef jack_intclient_t (*jack_internal_client_load_fun_def)(jack_client_t* ext | |||||
static jack_internal_client_load_fun_def jack_internal_client_load_fun = 0; | static jack_internal_client_load_fun_def jack_internal_client_load_fun = 0; | ||||
EXPORT jack_intclient_t jack_internal_client_load(jack_client_t* ext_client, const char* client_name, jack_options_t options, jack_status_t* status, ...) | EXPORT jack_intclient_t jack_internal_client_load(jack_client_t* ext_client, const char* client_name, jack_options_t options, jack_status_t* status, ...) | ||||
{ | { | ||||
va_list ap; | |||||
va_start(ap, status); | |||||
jack_intclient_t res = (*jack_internal_client_load_fun)(ext_client, client_name, options, status, ap); | |||||
va_end(ap); | |||||
return res; | |||||
va_list ap; | |||||
va_start(ap, status); | |||||
jack_intclient_t res = (*jack_internal_client_load_fun)(ext_client, client_name, options, status, ap); | |||||
va_end(ap); | |||||
return res; | |||||
} | } | ||||
typedef jack_status_t (*jack_internal_client_unload_fun_def)(jack_client_t* ext_client, jack_intclient_t intclient); | typedef jack_status_t (*jack_internal_client_unload_fun_def)(jack_client_t* ext_client, jack_intclient_t intclient); | ||||
@@ -828,223 +828,223 @@ typedef jack_client_t * (*jack_client_open_fun_def)(const char *client_name, jac | |||||
static jack_client_open_fun_def jack_client_open_fun = 0; | static jack_client_open_fun_def jack_client_open_fun = 0; | ||||
EXPORT jack_client_t * jack_client_open(const char *client_name, jack_options_t options, jack_status_t *status, ...) | EXPORT jack_client_t * jack_client_open(const char *client_name, jack_options_t options, jack_status_t *status, ...) | ||||
{ | { | ||||
// Library check... | |||||
if (!open_library()) | |||||
return 0; | |||||
va_list ap; | |||||
va_start(ap, status); | |||||
jack_client_t* res = (*jack_client_open_fun)(client_name, options, status, ap); | |||||
va_end(ap); | |||||
return res; | |||||
// Library check... | |||||
if (!open_library()) | |||||
return 0; | |||||
va_list ap; | |||||
va_start(ap, status); | |||||
jack_client_t* res = (*jack_client_open_fun)(client_name, options, status, ap); | |||||
va_end(ap); | |||||
return res; | |||||
} | } | ||||
typedef jack_client_t * (*jack_client_new_fun_def)(const char *client_name); | typedef jack_client_t * (*jack_client_new_fun_def)(const char *client_name); | ||||
static jack_client_new_fun_def jack_client_new_fun = 0; | static jack_client_new_fun_def jack_client_new_fun = 0; | ||||
EXPORT jack_client_t * jack_client_new(const char *client_name) | EXPORT jack_client_t * jack_client_new(const char *client_name) | ||||
{ | { | ||||
// Library check... | |||||
if (!open_library()) | |||||
return 0; | |||||
return (*jack_client_new_fun)(client_name); | |||||
// Library check... | |||||
if (!open_library()) | |||||
return 0; | |||||
return (*jack_client_new_fun)(client_name); | |||||
} | } | ||||
typedef int (*jack_client_close_fun_def)(jack_client_t *client); | typedef int (*jack_client_close_fun_def)(jack_client_t *client); | ||||
static jack_client_close_fun_def jack_client_close_fun = 0; | static jack_client_close_fun_def jack_client_close_fun = 0; | ||||
EXPORT int jack_client_close(jack_client_t *client) | EXPORT int jack_client_close(jack_client_t *client) | ||||
{ | |||||
int res = (*jack_client_close_fun)(client); | |||||
close_library(); | |||||
return res; | |||||
{ | |||||
int res = (*jack_client_close_fun)(client); | |||||
close_library(); | |||||
return res; | |||||
} | } | ||||
// Library loader | // Library loader | ||||
static bool get_jack_library_in_directory(const char* dir_name, char* library_name) | static bool get_jack_library_in_directory(const char* dir_name, char* library_name) | ||||
{ | { | ||||
struct dirent * dir_entry; | |||||
DIR * dir_stream = opendir(dir_name); | |||||
if (!dir_stream) | |||||
return false; | |||||
while ((dir_entry = readdir(dir_stream))) { | |||||
if (strncmp("libjack.so", dir_entry->d_name, 10) == 0) { | |||||
struct dirent * dir_entry; | |||||
DIR * dir_stream = opendir(dir_name); | |||||
if (!dir_stream) | |||||
return false; | |||||
while ((dir_entry = readdir(dir_stream))) { | |||||
if (strncmp("libjack.so", dir_entry->d_name, 10) == 0) { | |||||
strcpy(library_name, dir_entry->d_name); | strcpy(library_name, dir_entry->d_name); | ||||
closedir(dir_stream); | |||||
return true; | |||||
closedir(dir_stream); | |||||
return true; | |||||
} | } | ||||
} | |||||
closedir(dir_stream); | |||||
return false; | |||||
} | |||||
closedir(dir_stream); | |||||
return false; | |||||
} | } | ||||
static bool get_jack_library(char* library_name) | static bool get_jack_library(char* library_name) | ||||
{ | { | ||||
if (get_jack_library_in_directory("/usr/lib", library_name)) | |||||
return true; | |||||
if (get_jack_library_in_directory("/usr/local/lib", library_name)) | |||||
return true; | |||||
return false; | |||||
if (get_jack_library_in_directory("/usr/lib", library_name)) | |||||
return true; | |||||
if (get_jack_library_in_directory("/usr/local/lib", library_name)) | |||||
return true; | |||||
return false; | |||||
} | } | ||||
static bool open_library() | static bool open_library() | ||||
{ | { | ||||
if (gClientCount++ == 0) { | |||||
return init_library(); | |||||
} else { | |||||
return true; | |||||
} | |||||
if (gClientCount++ == 0) { | |||||
return init_library(); | |||||
} else { | |||||
return true; | |||||
} | |||||
} | } | ||||
static void close_library() | static void close_library() | ||||
{ | { | ||||
if (--gClientCount == 0) { | |||||
dlclose(gLibrary); | |||||
} | |||||
if (--gClientCount == 0) { | |||||
dlclose(gLibrary); | |||||
} | |||||
} | } | ||||
static bool check_client(void* library) | static bool check_client(void* library) | ||||
{ | { | ||||
jack_client_t* client = 0; | |||||
jack_client_t* client = 0; | |||||
// Get "new", "open" and "close" entry points... | |||||
jack_client_new_fun = (jack_client_new_fun_def)dlsym(library, "jack_client_new"); | |||||
jack_client_close_fun = (jack_client_close_fun_def)dlsym(library, "jack_client_close"); | |||||
jack_client_open_fun = (jack_client_open_fun_def)dlsym(gLibrary, "jack_client_open"); | |||||
// Get "new", "open" and "close" entry points... | |||||
jack_client_new_fun = (jack_client_new_fun_def)dlsym(library, "jack_client_new"); | |||||
jack_client_close_fun = (jack_client_close_fun_def)dlsym(library, "jack_client_close"); | |||||
jack_client_open_fun = (jack_client_open_fun_def)dlsym(gLibrary, "jack_client_open"); | |||||
// Try opening a client... | |||||
if ((client = (*jack_client_new_fun)("dummy"))) { // jackd server is running.... | |||||
(*jack_client_close_fun)(client); | |||||
return true; | |||||
} else { | |||||
return false; | |||||
} | |||||
// Try opening a client... | |||||
if ((client = (*jack_client_new_fun)("dummy"))) { // jackd server is running.... | |||||
(*jack_client_close_fun)(client); | |||||
return true; | |||||
} else { | |||||
return false; | |||||
} | |||||
} | } | ||||
static bool init_library() | static bool init_library() | ||||
{ | { | ||||
char library_name[64]; | |||||
void* jackLibrary = (get_jack_library(library_name)) ? dlopen(library_name, RTLD_LAZY) : 0; | |||||
void* jackmpLibrary = dlopen("libjackmp.so", RTLD_LAZY); | |||||
if (jackLibrary) { | |||||
if (check_client(jackLibrary)) { // jackd is running... | |||||
gLibrary = jackLibrary; | |||||
if (jackmpLibrary) dlclose(jackmpLibrary); | |||||
} else if (check_client(jackmpLibrary)) { // jackdmp is running... | |||||
gLibrary = jackmpLibrary; | |||||
if (jackLibrary) dlclose(jackLibrary); | |||||
} else { | |||||
goto error; | |||||
} | |||||
} else if (jackmpLibrary) { | |||||
if (check_client(jackmpLibrary)) { // jackd is running... | |||||
gLibrary = jackmpLibrary; | |||||
} else { | |||||
goto error; | |||||
} | |||||
} else { | |||||
printf("Jack libraries not found, failure...\n"); | |||||
goto error; | |||||
} | |||||
// Load entry points... | |||||
jack_port_get_buffer_fun = (jack_port_get_buffer_fun_def)dlsym(gLibrary, "jack_port_get_buffer"); | |||||
jack_port_name_fun = (jack_port_name_fun_def)dlsym(gLibrary, "jack_port_name"); | |||||
jack_port_short_name_fun = (jack_port_short_name_fun_def)dlsym(gLibrary, "jack_port_short_name"); | |||||
jack_port_flags_fun = (jack_port_flags_fun_def)dlsym(gLibrary, "jack_port_flags"); | |||||
jack_port_type_fun = (jack_port_type_fun_def)dlsym(gLibrary, "jack_port_type"); | |||||
jack_port_connected_fun = (jack_port_connected_fun_def)dlsym(gLibrary, "jack_port_connected"); | |||||
jack_port_connected_to_fun = (jack_port_connected_to_fun_def)dlsym(gLibrary, "jack_port_connected_to"); | |||||
jack_port_tie_fun = (jack_port_tie_fun_def)dlsym(gLibrary, "jack_port_tie"); | |||||
jack_port_untie_fun = (jack_port_untie_fun_def)dlsym(gLibrary, "jack_port_untie"); | |||||
jack_port_get_latency_fun = (jack_port_get_latency_fun_def)dlsym(gLibrary, "jack_port_get_latency"); | |||||
jack_port_set_latency_fun = (jack_port_set_latency_fun_def)dlsym(gLibrary, "jack_port_set_latency"); | |||||
jack_recompute_total_latency_fun = (jack_recompute_total_latency_fun_def)dlsym(gLibrary, "jack_recompute_total_latency"); | |||||
jack_recompute_total_latencies_fun = (jack_recompute_total_latencies_fun_def)dlsym(gLibrary, "jack_recompute_total_latencies"); | |||||
jack_port_set_name_fun = (jack_port_set_name_fun_def)dlsym(gLibrary, "jack_port_set_name"); | |||||
jack_port_request_monitor_fun = (jack_port_request_monitor_fun_def)dlsym(gLibrary, "jack_port_request_monitor"); | |||||
jack_port_request_monitor_by_name_fun = (jack_port_request_monitor_by_name_fun_def)dlsym(gLibrary, "jack_port_request_monitor_by_name"); | |||||
jack_port_ensure_monitor_fun = (jack_port_ensure_monitor_fun_def)dlsym(gLibrary, "jack_port_ensure_monitor"); | |||||
jack_port_monitoring_input_fun = (jack_port_monitoring_input_fun_def)dlsym(gLibrary, "jack_port_monitoring_input_fun"); | |||||
jack_is_realtime_fun = (jack_is_realtime_fun_def)dlsym(gLibrary, "jack_is_realtime"); | |||||
jack_on_shutdown_fun = (jack_on_shutdown_fun_def)dlsym(gLibrary, "jack_on_shutdown"); | |||||
jack_set_process_callback_fun = (jack_set_process_callback_fun_def)dlsym(gLibrary, "jack_set_process_callback"); | |||||
jack_set_freewheel_callback_fun = (jack_set_freewheel_callback_fun_def)dlsym(gLibrary, "jack_set_freewheel_callback"); | |||||
jack_set_freewheel_fun = (jack_set_freewheel_fun_def)dlsym(gLibrary, "jack_set_freewheel"); | |||||
jack_set_buffer_size_fun = (jack_set_buffer_size_fun_def)dlsym(gLibrary, "jack_set_buffer_size"); | |||||
jack_set_buffer_size_callback_fun = (jack_set_buffer_size_callback_fun_def)dlsym(gLibrary, "jack_set_buffer_size_callback"); | |||||
jack_set_sample_rate_callback_fun = (jack_set_sample_rate_callback_fun_def)dlsym(gLibrary, "jack_set_sample_rate_callback"); | |||||
jack_set_client_registration_callback_fun = (jack_set_client_registration_callback_fun_def)dlsym(gLibrary, "jack_set_client_registration_callback"); | |||||
jack_set_port_registration_callback_fun = (jack_set_port_registration_callback_fun_def)dlsym(gLibrary, "jack_set_port_registration_callback"); | |||||
jack_set_port_connect_callback_fun = (jack_set_port_connect_callback_fun_def)dlsym(gLibrary, "jack_set_port_connect_callback"); | |||||
jack_set_graph_order_callback_fun = (jack_set_graph_order_callback_fun_def)dlsym(gLibrary, "jack_set_graph_order_callback"); | |||||
jack_set_xrun_callback_fun = (jack_set_xrun_callback_fun_def)dlsym(gLibrary, "jack_set_xrun_callback"); | |||||
jack_set_thread_init_callback_fun = (jack_set_thread_init_callback_fun_def)dlsym(gLibrary, "jack_set_thread_init_callback"); | |||||
jack_activate_fun = (jack_activate_fun_def)dlsym(gLibrary, "jack_activate"); | |||||
jack_deactivate_fun = (jack_deactivate_fun_def)dlsym(gLibrary, "jack_deactivate"); | |||||
jack_port_register_fun = (jack_port_register_fun_def)dlsym(gLibrary, "jack_port_register"); | |||||
jack_port_unregister_fun = (jack_port_unregister_fun_def)dlsym(gLibrary, "jack_port_unregister"); | |||||
jack_port_is_mine_fun = (jack_port_is_mine_fun_def)dlsym(gLibrary, "jack_port_is_mine"); | |||||
jack_port_get_connections_fun = (jack_port_get_connections_fun_def)dlsym(gLibrary, "jack_port_get_connections"); | |||||
jack_port_get_all_connections_fun = (jack_port_get_all_connections_fun_def)dlsym(gLibrary, "jack_port_get_all_connections_fun"); | |||||
jack_port_get_total_latency_fun = (jack_port_get_total_latency_fun_def)dlsym(gLibrary, "jack_port_get_total_latency"); | |||||
jack_connect_fun = (jack_connect_fun_def)dlsym(gLibrary, "jack_connect"); | |||||
jack_disconnect_fun = (jack_disconnect_fun_def)dlsym(gLibrary, "jack_disconnect"); | |||||
jack_port_connect_fun = (jack_port_connect_fun_def)dlsym(gLibrary, "jack_port_connect"); | |||||
jack_port_disconnect_fun = (jack_port_disconnect_fun_def)dlsym(gLibrary, "jack_port_disconnect"); | |||||
jack_get_sample_rate_fun = (jack_get_sample_rate_fun_def)dlsym(gLibrary, "jack_get_sample_rate"); | |||||
jack_get_buffer_size_fun = (jack_get_buffer_size_fun_def)dlsym(gLibrary, "jack_get_buffer_size"); | |||||
jack_get_ports_fun = (jack_get_ports_fun_def)dlsym(gLibrary, "jack_get_ports"); | |||||
jack_port_by_name_fun = (jack_port_by_name_fun_def)dlsym(gLibrary, "jack_port_by_name"); | |||||
jack_port_by_id_fun = (jack_port_by_id_fun_def)dlsym(gLibrary, "jack_port_by_id"); | |||||
jack_engine_takeover_timebase_fun = (jack_engine_takeover_timebase_fun_def)dlsym(gLibrary, "jack_engine_takeover_timebase"); | |||||
jack_frames_since_cycle_start_fun = (jack_frames_since_cycle_start_fun_def)dlsym(gLibrary, "jack_frames_since_cycle_start"); | |||||
jack_get_time_fun = (jack_get_time_fun_def)dlsym(gLibrary, "jack_get_time"); | |||||
jack_time_to_frames_fun = (jack_time_to_frames_fun_def)dlsym(gLibrary, "jack_time_to_frames"); | |||||
jack_frame_time_fun = (jack_frame_time_fun_def)dlsym(gLibrary, "jack_frame_time"); | |||||
jack_last_frame_time_fun = (jack_last_frame_time_fun_def)dlsym(gLibrary, "jack_last_frame_time"); | |||||
jack_cpu_load_fun = (jack_cpu_load_fun_def)dlsym(gLibrary, "jack_cpu_load"); | |||||
jack_client_thread_id_fun = (jack_client_thread_id_fun_def)dlsym(gLibrary, "jack_client_thread_id"); | |||||
jack_get_client_name_fun = (jack_get_client_name_fun_def)dlsym(gLibrary, "jack_get_client_name"); | |||||
jack_port_name_size_fun = (jack_port_name_size_fun_def)dlsym(gLibrary, "jack_port_name_size"); | |||||
jack_client_name_size_fun = (jack_client_name_size_fun_def)dlsym(gLibrary, "jack_client_name_size"); | |||||
jack_release_timebase_fun = (jack_release_timebase_fun_def)dlsym(gLibrary, "jack_release_timebase"); | |||||
jack_set_sync_callback_fun = (jack_set_sync_callback_fun_def)dlsym(gLibrary, "jack_set_sync_callback"); | |||||
jack_set_sync_timeout_fun = (jack_set_sync_timeout_fun_def)dlsym(gLibrary, "jack_set_sync_timeout"); | |||||
jack_set_timebase_callback_fun = (jack_set_timebase_callback_fun_def)dlsym(gLibrary, "jack_set_timebase_callback"); | |||||
jack_transport_locate_fun = (jack_transport_locate_fun_def)dlsym(gLibrary, "jack_transport_locate_fun"); | |||||
jack_transport_query_fun = (jack_transport_query_fun_def)dlsym(gLibrary, "jack_transport_query"); | |||||
jack_get_current_transport_frame_fun = (jack_get_current_transport_frame_fun_def)dlsym(gLibrary, "jack_get_current_transport_frame"); | |||||
jack_transport_reposition_fun = (jack_transport_reposition_fun_def)dlsym(gLibrary, "jack_transport_reposition"); | |||||
jack_transport_start_fun = (jack_transport_start_fun_def)dlsym(gLibrary, "jack_transport_start"); | |||||
jack_transport_stop_fun = (jack_transport_stop_fun_def)dlsym(gLibrary, "jack_transport_stop"); | |||||
jack_get_transport_info_fun = (jack_get_transport_info_fun_def)dlsym(gLibrary, "jack_get_transport_info"); | |||||
jack_set_transport_info_fun = (jack_set_transport_info_fun_def)dlsym(gLibrary, "jack_set_transport_info"); | |||||
jack_get_max_delayed_usecs_fun = (jack_get_max_delayed_usecs_fun_def)dlsym(gLibrary, "jack_get_max_delayed_usecs"); | |||||
jack_get_xrun_delayed_usecs_fun = (jack_get_xrun_delayed_usecs_fun_def)dlsym(gLibrary, "jack_get_xrun_delayed_usecs"); | |||||
jack_reset_max_delayed_usecs_fun = (jack_reset_max_delayed_usecs_fun_def)dlsym(gLibrary, "jack_reset_max_delayed_usecs"); | |||||
jack_acquire_real_time_scheduling_fun = (jack_acquire_real_time_scheduling_fun_def)dlsym(gLibrary, "jack_acquire_real_time_scheduling"); | |||||
jack_client_create_thread_fun = (jack_client_create_thread_fun_def)dlsym(gLibrary, "jack_client_create_thread"); | |||||
jack_drop_real_time_scheduling_fun = (jack_drop_real_time_scheduling_fun_def)dlsym(gLibrary, "jack_drop_real_time_scheduling"); | |||||
jack_get_internal_client_name_fun = (jack_get_internal_client_name_fun_def)dlsym(gLibrary, "jack_get_internal_client_name"); | |||||
jack_internal_client_handle_fun = (jack_internal_client_handle_fun_def)dlsym(gLibrary, "jack_internal_client_handle"); | |||||
jack_internal_client_load_fun = (jack_internal_client_load_fun_def)dlsym(gLibrary, "jack_internal_client_load"); | |||||
jack_internal_client_unload_fun = (jack_internal_client_unload_fun_def)dlsym(gLibrary, "jack_internal_client_unload"); | |||||
jack_client_open_fun = (jack_client_open_fun_def)dlsym(gLibrary, "jack_client_open"); | |||||
jack_client_new_fun = (jack_client_new_fun_def)dlsym(gLibrary, "jack_client_new"); | |||||
jack_client_close_fun = (jack_client_close_fun_def)dlsym(gLibrary, "jack_client_close"); | |||||
return true; | |||||
char library_name[64]; | |||||
void* jackLibrary = (get_jack_library(library_name)) ? dlopen(library_name, RTLD_LAZY) : 0; | |||||
void* jackmpLibrary = dlopen("libjackmp.so", RTLD_LAZY); | |||||
if (jackLibrary) { | |||||
if (check_client(jackLibrary)) { // jackd is running... | |||||
gLibrary = jackLibrary; | |||||
if (jackmpLibrary) dlclose(jackmpLibrary); | |||||
} else if (check_client(jackmpLibrary)) { // jackdmp is running... | |||||
gLibrary = jackmpLibrary; | |||||
if (jackLibrary) dlclose(jackLibrary); | |||||
} else { | |||||
goto error; | |||||
} | |||||
} else if (jackmpLibrary) { | |||||
if (check_client(jackmpLibrary)) { // jackd is running... | |||||
gLibrary = jackmpLibrary; | |||||
} else { | |||||
goto error; | |||||
} | |||||
} else { | |||||
printf("Jack libraries not found, failure...\n"); | |||||
goto error; | |||||
} | |||||
// Load entry points... | |||||
jack_port_get_buffer_fun = (jack_port_get_buffer_fun_def)dlsym(gLibrary, "jack_port_get_buffer"); | |||||
jack_port_name_fun = (jack_port_name_fun_def)dlsym(gLibrary, "jack_port_name"); | |||||
jack_port_short_name_fun = (jack_port_short_name_fun_def)dlsym(gLibrary, "jack_port_short_name"); | |||||
jack_port_flags_fun = (jack_port_flags_fun_def)dlsym(gLibrary, "jack_port_flags"); | |||||
jack_port_type_fun = (jack_port_type_fun_def)dlsym(gLibrary, "jack_port_type"); | |||||
jack_port_connected_fun = (jack_port_connected_fun_def)dlsym(gLibrary, "jack_port_connected"); | |||||
jack_port_connected_to_fun = (jack_port_connected_to_fun_def)dlsym(gLibrary, "jack_port_connected_to"); | |||||
jack_port_tie_fun = (jack_port_tie_fun_def)dlsym(gLibrary, "jack_port_tie"); | |||||
jack_port_untie_fun = (jack_port_untie_fun_def)dlsym(gLibrary, "jack_port_untie"); | |||||
jack_port_get_latency_fun = (jack_port_get_latency_fun_def)dlsym(gLibrary, "jack_port_get_latency"); | |||||
jack_port_set_latency_fun = (jack_port_set_latency_fun_def)dlsym(gLibrary, "jack_port_set_latency"); | |||||
jack_recompute_total_latency_fun = (jack_recompute_total_latency_fun_def)dlsym(gLibrary, "jack_recompute_total_latency"); | |||||
jack_recompute_total_latencies_fun = (jack_recompute_total_latencies_fun_def)dlsym(gLibrary, "jack_recompute_total_latencies"); | |||||
jack_port_set_name_fun = (jack_port_set_name_fun_def)dlsym(gLibrary, "jack_port_set_name"); | |||||
jack_port_request_monitor_fun = (jack_port_request_monitor_fun_def)dlsym(gLibrary, "jack_port_request_monitor"); | |||||
jack_port_request_monitor_by_name_fun = (jack_port_request_monitor_by_name_fun_def)dlsym(gLibrary, "jack_port_request_monitor_by_name"); | |||||
jack_port_ensure_monitor_fun = (jack_port_ensure_monitor_fun_def)dlsym(gLibrary, "jack_port_ensure_monitor"); | |||||
jack_port_monitoring_input_fun = (jack_port_monitoring_input_fun_def)dlsym(gLibrary, "jack_port_monitoring_input_fun"); | |||||
jack_is_realtime_fun = (jack_is_realtime_fun_def)dlsym(gLibrary, "jack_is_realtime"); | |||||
jack_on_shutdown_fun = (jack_on_shutdown_fun_def)dlsym(gLibrary, "jack_on_shutdown"); | |||||
jack_set_process_callback_fun = (jack_set_process_callback_fun_def)dlsym(gLibrary, "jack_set_process_callback"); | |||||
jack_set_freewheel_callback_fun = (jack_set_freewheel_callback_fun_def)dlsym(gLibrary, "jack_set_freewheel_callback"); | |||||
jack_set_freewheel_fun = (jack_set_freewheel_fun_def)dlsym(gLibrary, "jack_set_freewheel"); | |||||
jack_set_buffer_size_fun = (jack_set_buffer_size_fun_def)dlsym(gLibrary, "jack_set_buffer_size"); | |||||
jack_set_buffer_size_callback_fun = (jack_set_buffer_size_callback_fun_def)dlsym(gLibrary, "jack_set_buffer_size_callback"); | |||||
jack_set_sample_rate_callback_fun = (jack_set_sample_rate_callback_fun_def)dlsym(gLibrary, "jack_set_sample_rate_callback"); | |||||
jack_set_client_registration_callback_fun = (jack_set_client_registration_callback_fun_def)dlsym(gLibrary, "jack_set_client_registration_callback"); | |||||
jack_set_port_registration_callback_fun = (jack_set_port_registration_callback_fun_def)dlsym(gLibrary, "jack_set_port_registration_callback"); | |||||
jack_set_port_connect_callback_fun = (jack_set_port_connect_callback_fun_def)dlsym(gLibrary, "jack_set_port_connect_callback"); | |||||
jack_set_graph_order_callback_fun = (jack_set_graph_order_callback_fun_def)dlsym(gLibrary, "jack_set_graph_order_callback"); | |||||
jack_set_xrun_callback_fun = (jack_set_xrun_callback_fun_def)dlsym(gLibrary, "jack_set_xrun_callback"); | |||||
jack_set_thread_init_callback_fun = (jack_set_thread_init_callback_fun_def)dlsym(gLibrary, "jack_set_thread_init_callback"); | |||||
jack_activate_fun = (jack_activate_fun_def)dlsym(gLibrary, "jack_activate"); | |||||
jack_deactivate_fun = (jack_deactivate_fun_def)dlsym(gLibrary, "jack_deactivate"); | |||||
jack_port_register_fun = (jack_port_register_fun_def)dlsym(gLibrary, "jack_port_register"); | |||||
jack_port_unregister_fun = (jack_port_unregister_fun_def)dlsym(gLibrary, "jack_port_unregister"); | |||||
jack_port_is_mine_fun = (jack_port_is_mine_fun_def)dlsym(gLibrary, "jack_port_is_mine"); | |||||
jack_port_get_connections_fun = (jack_port_get_connections_fun_def)dlsym(gLibrary, "jack_port_get_connections"); | |||||
jack_port_get_all_connections_fun = (jack_port_get_all_connections_fun_def)dlsym(gLibrary, "jack_port_get_all_connections_fun"); | |||||
jack_port_get_total_latency_fun = (jack_port_get_total_latency_fun_def)dlsym(gLibrary, "jack_port_get_total_latency"); | |||||
jack_connect_fun = (jack_connect_fun_def)dlsym(gLibrary, "jack_connect"); | |||||
jack_disconnect_fun = (jack_disconnect_fun_def)dlsym(gLibrary, "jack_disconnect"); | |||||
jack_port_connect_fun = (jack_port_connect_fun_def)dlsym(gLibrary, "jack_port_connect"); | |||||
jack_port_disconnect_fun = (jack_port_disconnect_fun_def)dlsym(gLibrary, "jack_port_disconnect"); | |||||
jack_get_sample_rate_fun = (jack_get_sample_rate_fun_def)dlsym(gLibrary, "jack_get_sample_rate"); | |||||
jack_get_buffer_size_fun = (jack_get_buffer_size_fun_def)dlsym(gLibrary, "jack_get_buffer_size"); | |||||
jack_get_ports_fun = (jack_get_ports_fun_def)dlsym(gLibrary, "jack_get_ports"); | |||||
jack_port_by_name_fun = (jack_port_by_name_fun_def)dlsym(gLibrary, "jack_port_by_name"); | |||||
jack_port_by_id_fun = (jack_port_by_id_fun_def)dlsym(gLibrary, "jack_port_by_id"); | |||||
jack_engine_takeover_timebase_fun = (jack_engine_takeover_timebase_fun_def)dlsym(gLibrary, "jack_engine_takeover_timebase"); | |||||
jack_frames_since_cycle_start_fun = (jack_frames_since_cycle_start_fun_def)dlsym(gLibrary, "jack_frames_since_cycle_start"); | |||||
jack_get_time_fun = (jack_get_time_fun_def)dlsym(gLibrary, "jack_get_time"); | |||||
jack_time_to_frames_fun = (jack_time_to_frames_fun_def)dlsym(gLibrary, "jack_time_to_frames"); | |||||
jack_frame_time_fun = (jack_frame_time_fun_def)dlsym(gLibrary, "jack_frame_time"); | |||||
jack_last_frame_time_fun = (jack_last_frame_time_fun_def)dlsym(gLibrary, "jack_last_frame_time"); | |||||
jack_cpu_load_fun = (jack_cpu_load_fun_def)dlsym(gLibrary, "jack_cpu_load"); | |||||
jack_client_thread_id_fun = (jack_client_thread_id_fun_def)dlsym(gLibrary, "jack_client_thread_id"); | |||||
jack_get_client_name_fun = (jack_get_client_name_fun_def)dlsym(gLibrary, "jack_get_client_name"); | |||||
jack_port_name_size_fun = (jack_port_name_size_fun_def)dlsym(gLibrary, "jack_port_name_size"); | |||||
jack_client_name_size_fun = (jack_client_name_size_fun_def)dlsym(gLibrary, "jack_client_name_size"); | |||||
jack_release_timebase_fun = (jack_release_timebase_fun_def)dlsym(gLibrary, "jack_release_timebase"); | |||||
jack_set_sync_callback_fun = (jack_set_sync_callback_fun_def)dlsym(gLibrary, "jack_set_sync_callback"); | |||||
jack_set_sync_timeout_fun = (jack_set_sync_timeout_fun_def)dlsym(gLibrary, "jack_set_sync_timeout"); | |||||
jack_set_timebase_callback_fun = (jack_set_timebase_callback_fun_def)dlsym(gLibrary, "jack_set_timebase_callback"); | |||||
jack_transport_locate_fun = (jack_transport_locate_fun_def)dlsym(gLibrary, "jack_transport_locate_fun"); | |||||
jack_transport_query_fun = (jack_transport_query_fun_def)dlsym(gLibrary, "jack_transport_query"); | |||||
jack_get_current_transport_frame_fun = (jack_get_current_transport_frame_fun_def)dlsym(gLibrary, "jack_get_current_transport_frame"); | |||||
jack_transport_reposition_fun = (jack_transport_reposition_fun_def)dlsym(gLibrary, "jack_transport_reposition"); | |||||
jack_transport_start_fun = (jack_transport_start_fun_def)dlsym(gLibrary, "jack_transport_start"); | |||||
jack_transport_stop_fun = (jack_transport_stop_fun_def)dlsym(gLibrary, "jack_transport_stop"); | |||||
jack_get_transport_info_fun = (jack_get_transport_info_fun_def)dlsym(gLibrary, "jack_get_transport_info"); | |||||
jack_set_transport_info_fun = (jack_set_transport_info_fun_def)dlsym(gLibrary, "jack_set_transport_info"); | |||||
jack_get_max_delayed_usecs_fun = (jack_get_max_delayed_usecs_fun_def)dlsym(gLibrary, "jack_get_max_delayed_usecs"); | |||||
jack_get_xrun_delayed_usecs_fun = (jack_get_xrun_delayed_usecs_fun_def)dlsym(gLibrary, "jack_get_xrun_delayed_usecs"); | |||||
jack_reset_max_delayed_usecs_fun = (jack_reset_max_delayed_usecs_fun_def)dlsym(gLibrary, "jack_reset_max_delayed_usecs"); | |||||
jack_acquire_real_time_scheduling_fun = (jack_acquire_real_time_scheduling_fun_def)dlsym(gLibrary, "jack_acquire_real_time_scheduling"); | |||||
jack_client_create_thread_fun = (jack_client_create_thread_fun_def)dlsym(gLibrary, "jack_client_create_thread"); | |||||
jack_drop_real_time_scheduling_fun = (jack_drop_real_time_scheduling_fun_def)dlsym(gLibrary, "jack_drop_real_time_scheduling"); | |||||
jack_get_internal_client_name_fun = (jack_get_internal_client_name_fun_def)dlsym(gLibrary, "jack_get_internal_client_name"); | |||||
jack_internal_client_handle_fun = (jack_internal_client_handle_fun_def)dlsym(gLibrary, "jack_internal_client_handle"); | |||||
jack_internal_client_load_fun = (jack_internal_client_load_fun_def)dlsym(gLibrary, "jack_internal_client_load"); | |||||
jack_internal_client_unload_fun = (jack_internal_client_unload_fun_def)dlsym(gLibrary, "jack_internal_client_unload"); | |||||
jack_client_open_fun = (jack_client_open_fun_def)dlsym(gLibrary, "jack_client_open"); | |||||
jack_client_new_fun = (jack_client_new_fun_def)dlsym(gLibrary, "jack_client_new"); | |||||
jack_client_close_fun = (jack_client_close_fun_def)dlsym(gLibrary, "jack_client_close"); | |||||
return true; | |||||
error: | error: | ||||
if (jackLibrary) | |||||
dlclose(jackLibrary); | |||||
if (jackmpLibrary) | |||||
dlclose(jackmpLibrary); | |||||
return false; | |||||
if (jackLibrary) | |||||
dlclose(jackLibrary); | |||||
if (jackmpLibrary) | |||||
dlclose(jackmpLibrary); | |||||
return false; | |||||
} | } |
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2004-2008 Grame | |||||
Copyright (C) 2004-2008 Grame | |||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
it under the terms of the GNU General Public License as published by | it under the terms of the GNU General Public License as published by | ||||
@@ -29,11 +29,11 @@ namespace Jack | |||||
bool JackActivationCount::Signal(JackSynchro* synchro, JackClientControl* control) | bool JackActivationCount::Signal(JackSynchro* synchro, JackClientControl* control) | ||||
{ | { | ||||
if (fValue == 0) { | if (fValue == 0) { | ||||
// Transfer activation to next clients | |||||
// Transfer activation to next clients | |||||
jack_error("JackActivationCount::Signal value = 0 ref = %ld", control->fRefNum); | jack_error("JackActivationCount::Signal value = 0 ref = %ld", control->fRefNum); | ||||
return synchro->Signal(); | return synchro->Signal(); | ||||
} else if (DEC_ATOMIC(&fValue) == 1) { | } else if (DEC_ATOMIC(&fValue) == 1) { | ||||
return synchro->Signal(); | |||||
return synchro->Signal(); | |||||
} else { | } else { | ||||
return true; | return true; | ||||
} | } | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2004-2008 Grame | |||||
Copyright (C) 2004-2008 Grame | |||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
it under the terms of the GNU General Public License as published by | it under the terms of the GNU General Public License as published by | ||||
@@ -38,12 +38,12 @@ class JackActivationCount | |||||
private: | private: | ||||
SInt32 fValue; | |||||
SInt32 fValue; | |||||
SInt32 fCount; | SInt32 fCount; | ||||
public: | public: | ||||
JackActivationCount(): fValue(0), fCount(0) | |||||
JackActivationCount(): fValue(0), fCount(0) | |||||
{} | {} | ||||
virtual ~JackActivationCount() | virtual ~JackActivationCount() | ||||
{} | {} | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2004-2008 Grame | |||||
Copyright (C) 2004-2008 Grame | |||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
it under the terms of the GNU General Public License as published by | it under the terms of the GNU General Public License as published by | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2004-2006 Grame | |||||
Copyright (C) 2004-2006 Grame | |||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
it under the terms of the GNU General Public License as published by | it under the terms of the GNU General Public License as published by | ||||
@@ -28,7 +28,7 @@ namespace Jack | |||||
{ | { | ||||
/*! | /*! | ||||
\brief Counter for CAS | |||||
\brief Counter for CAS | |||||
*/ | */ | ||||
struct AtomicArrayCounter | struct AtomicArrayCounter | ||||
@@ -56,33 +56,33 @@ struct AtomicArrayCounter | |||||
/*! | /*! | ||||
\brief A class to handle several states in a lock-free manner | \brief A class to handle several states in a lock-free manner | ||||
Requirement: | Requirement: | ||||
- a "current" state | - a "current" state | ||||
- several possible "pending" state | - several possible "pending" state | ||||
- an TrySwitchState(int state) operation to atomically switch a "pending" to the "current" state (the pending becomes the current). | |||||
- an TrySwitchState(int state) operation to atomically switch a "pending" to the "current" state (the pending becomes the current). | |||||
The TrySwitchState operation returns a "current" state (either the same if switch fails or the new one, one can know if the switch has succeeded) | The TrySwitchState operation returns a "current" state (either the same if switch fails or the new one, one can know if the switch has succeeded) | ||||
- a WriteNextStartState(int state) returns a "pending" state to be written into | - a WriteNextStartState(int state) returns a "pending" state to be written into | ||||
- a WriteNextStartStop(int state) make the written "pending" state become "switchable" | - a WriteNextStartStop(int state) make the written "pending" state become "switchable" | ||||
Different pending states can be written independantly and concurrently. | Different pending states can be written independantly and concurrently. | ||||
GetCurrentIndex() *must* return an increasing value to be able to check reading current state coherency | GetCurrentIndex() *must* return an increasing value to be able to check reading current state coherency | ||||
The fCounter is an array of indexes to access the current and 3 different "pending" states. | The fCounter is an array of indexes to access the current and 3 different "pending" states. | ||||
ÂĄ WriteNextStateStart(int index) must return a valid state to be written into, and must invalidate state "index" ==> cur state switch. | ÂĄ WriteNextStateStart(int index) must return a valid state to be written into, and must invalidate state "index" ==> cur state switch. | ||||
ÂĄ WriteNextStateStop(int index) makes the "index" state become "switchable" with the current state. | ÂĄ WriteNextStateStop(int index) makes the "index" state become "switchable" with the current state. | ||||
ÂĄ TrySwitchState(int index) must detect that pending state is a new state, and does the switch | ÂĄ TrySwitchState(int index) must detect that pending state is a new state, and does the switch | ||||
ÂĄ ReadCurrentState() must return the state | |||||
ÂĄ ReadCurrentState() must return the state | |||||
ÂĄ GetCurrentIndex() must return an index increased each new switch. | ÂĄ GetCurrentIndex() must return an index increased each new switch. | ||||
ÂĄ WriteNextStateStart(int index1) and WriteNextStateStart(int index2) can be interleaved | ÂĄ WriteNextStateStart(int index1) and WriteNextStateStart(int index2) can be interleaved | ||||
[switch counter][index state][index state][cur index] | [switch counter][index state][index state][cur index] | ||||
*/ | */ | ||||
// CHECK livelock | // CHECK livelock | ||||
@@ -162,8 +162,8 @@ class JackAtomicArrayState | |||||
} | } | ||||
/*! | /*! | ||||
\brief Tries to switch to the next state and returns the new current state (either the same as before if case of switch failure or the new one) | |||||
*/ | |||||
\brief Tries to switch to the next state and returns the new current state (either the same as before if case of switch failure or the new one) | |||||
*/ | |||||
T* TrySwitchState(int state) | T* TrySwitchState(int state) | ||||
{ | { | ||||
@@ -202,8 +202,8 @@ class JackAtomicArrayState | |||||
} | } | ||||
/*! | /*! | ||||
\brief Start write operation : setup and returns the next state to update, check for recursive write calls. | |||||
*/ | |||||
\brief Start write operation : setup and returns the next state to update, check for recursive write calls. | |||||
*/ | |||||
T* WriteNextStateStart(int state) | T* WriteNextStateStart(int state) | ||||
{ | { | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2004-2008 Grame | |||||
Copyright (C) 2004-2008 Grame | |||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
it under the terms of the GNU General Public License as published by | it under the terms of the GNU General Public License as published by | ||||
@@ -27,7 +27,7 @@ namespace Jack | |||||
{ | { | ||||
/*! | /*! | ||||
\brief Counter for CAS | |||||
\brief Counter for CAS | |||||
*/ | */ | ||||
struct AtomicCounter | struct AtomicCounter | ||||
@@ -132,8 +132,8 @@ class JackAtomicState | |||||
} | } | ||||
/*! | /*! | ||||
\brief Tries to switch to the next state and returns the new current state (either the same as before if case of switch failure or the new one) | |||||
*/ | |||||
\brief Tries to switch to the next state and returns the new current state (either the same as before if case of switch failure or the new one) | |||||
*/ | |||||
T* TrySwitchState() | T* TrySwitchState() | ||||
{ | { | ||||
AtomicCounter old_val; | AtomicCounter old_val; | ||||
@@ -218,15 +218,15 @@ class JackAtomicState | |||||
{ | { | ||||
T* state; | T* state; | ||||
UInt16 cur_index; | UInt16 cur_index; | ||||
UInt16 next_index = GetCurrentIndex(); | |||||
UInt16 next_index = GetCurrentIndex(); | |||||
do { | do { | ||||
cur_index = next_index; | |||||
cur_index = next_index; | |||||
state = ReadCurrentState(); | state = ReadCurrentState(); | ||||
...... | ...... | ||||
...... | ...... | ||||
next_index = GetCurrentIndex(); | |||||
next_index = GetCurrentIndex(); | |||||
} while (cur_index != next_index); | } while (cur_index != next_index); | ||||
} | } | ||||
*/ | */ | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2004-2008 Grame | Copyright (C) 2004-2008 Grame | ||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
@@ -18,7 +18,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||||
*/ | */ | ||||
#ifdef WIN32 | |||||
#ifdef WIN32 | |||||
#pragma warning (disable : 4786) | #pragma warning (disable : 4786) | ||||
#endif | #endif | ||||
@@ -48,19 +48,19 @@ JackAudioDriver::~JackAudioDriver() | |||||
int JackAudioDriver::SetBufferSize(jack_nframes_t buffer_size) | int JackAudioDriver::SetBufferSize(jack_nframes_t buffer_size) | ||||
{ | { | ||||
fEngineControl->fBufferSize = buffer_size; | fEngineControl->fBufferSize = buffer_size; | ||||
fGraphManager->SetBufferSize(buffer_size); | |||||
fEngineControl->fPeriodUsecs = jack_time_t(1000000.f / fEngineControl->fSampleRate * fEngineControl->fBufferSize); // in microsec | |||||
if (!fEngineControl->fTimeOut) | |||||
fEngineControl->fTimeOutUsecs = jack_time_t(2.f * fEngineControl->fPeriodUsecs); | |||||
fGraphManager->SetBufferSize(buffer_size); | |||||
fEngineControl->fPeriodUsecs = jack_time_t(1000000.f / fEngineControl->fSampleRate * fEngineControl->fBufferSize); // in microsec | |||||
if (!fEngineControl->fTimeOut) | |||||
fEngineControl->fTimeOutUsecs = jack_time_t(2.f * fEngineControl->fPeriodUsecs); | |||||
return 0; | return 0; | ||||
} | } | ||||
int JackAudioDriver::SetSampleRate(jack_nframes_t sample_rate) | int JackAudioDriver::SetSampleRate(jack_nframes_t sample_rate) | ||||
{ | { | ||||
fEngineControl->fSampleRate = sample_rate; | fEngineControl->fSampleRate = sample_rate; | ||||
fEngineControl->fPeriodUsecs = jack_time_t(1000000.f / fEngineControl->fSampleRate * fEngineControl->fBufferSize); // in microsec | |||||
if (!fEngineControl->fTimeOut) | |||||
fEngineControl->fTimeOutUsecs = jack_time_t(2.f * fEngineControl->fPeriodUsecs); | |||||
fEngineControl->fPeriodUsecs = jack_time_t(1000000.f / fEngineControl->fSampleRate * fEngineControl->fBufferSize); // in microsec | |||||
if (!fEngineControl->fTimeOut) | |||||
fEngineControl->fTimeOutUsecs = jack_time_t(2.f * fEngineControl->fPeriodUsecs); | |||||
return 0; | return 0; | ||||
} | } | ||||
@@ -87,7 +87,7 @@ int JackAudioDriver::Attach() | |||||
JackPort* port; | JackPort* port; | ||||
jack_port_id_t port_index; | jack_port_id_t port_index; | ||||
char name[JACK_CLIENT_NAME_SIZE + JACK_PORT_NAME_SIZE]; | char name[JACK_CLIENT_NAME_SIZE + JACK_PORT_NAME_SIZE]; | ||||
char alias[JACK_CLIENT_NAME_SIZE + JACK_PORT_NAME_SIZE]; | |||||
char alias[JACK_CLIENT_NAME_SIZE + JACK_PORT_NAME_SIZE]; | |||||
unsigned long port_flags = JackPortIsOutput | JackPortIsPhysical | JackPortIsTerminal; | unsigned long port_flags = JackPortIsOutput | JackPortIsPhysical | JackPortIsTerminal; | ||||
int i; | int i; | ||||
@@ -95,13 +95,13 @@ int JackAudioDriver::Attach() | |||||
for (i = 0; i < fCaptureChannels; i++) { | for (i = 0; i < fCaptureChannels; i++) { | ||||
snprintf(alias, sizeof(alias) - 1, "%s:%s:out%d", fClientControl->fName, fCaptureDriverName, i + 1); | snprintf(alias, sizeof(alias) - 1, "%s:%s:out%d", fClientControl->fName, fCaptureDriverName, i + 1); | ||||
snprintf(name, sizeof(name) - 1, "system:capture_%d", i + 1); | |||||
snprintf(name, sizeof(name) - 1, "system:capture_%d", i + 1); | |||||
if ((port_index = fGraphManager->AllocatePort(fClientControl->fRefNum, name, JACK_DEFAULT_AUDIO_TYPE, (JackPortFlags)port_flags, fEngineControl->fBufferSize)) == NO_PORT) { | if ((port_index = fGraphManager->AllocatePort(fClientControl->fRefNum, name, JACK_DEFAULT_AUDIO_TYPE, (JackPortFlags)port_flags, fEngineControl->fBufferSize)) == NO_PORT) { | ||||
jack_error("driver: cannot register port for %s", name); | jack_error("driver: cannot register port for %s", name); | ||||
return -1; | return -1; | ||||
} | } | ||||
port = fGraphManager->GetPort(port_index); | |||||
port->SetAlias(alias); | |||||
port = fGraphManager->GetPort(port_index); | |||||
port->SetAlias(alias); | |||||
port->SetLatency(fEngineControl->fBufferSize + fCaptureLatency); | port->SetLatency(fEngineControl->fBufferSize + fCaptureLatency); | ||||
fCapturePortList[i] = port_index; | fCapturePortList[i] = port_index; | ||||
JackLog("JackAudioDriver::Attach fCapturePortList[i] port_index = %ld\n", port_index); | JackLog("JackAudioDriver::Attach fCapturePortList[i] port_index = %ld\n", port_index); | ||||
@@ -111,17 +111,17 @@ int JackAudioDriver::Attach() | |||||
for (i = 0; i < fPlaybackChannels; i++) { | for (i = 0; i < fPlaybackChannels; i++) { | ||||
snprintf(alias, sizeof(alias) - 1, "%s:%s:in%d", fClientControl->fName, fPlaybackDriverName, i + 1); | snprintf(alias, sizeof(alias) - 1, "%s:%s:in%d", fClientControl->fName, fPlaybackDriverName, i + 1); | ||||
snprintf(name, sizeof(name) - 1, "system:playback_%d", i + 1); | |||||
snprintf(name, sizeof(name) - 1, "system:playback_%d", i + 1); | |||||
if ((port_index = fGraphManager->AllocatePort(fClientControl->fRefNum, name, JACK_DEFAULT_AUDIO_TYPE, (JackPortFlags)port_flags, fEngineControl->fBufferSize)) == NO_PORT) { | if ((port_index = fGraphManager->AllocatePort(fClientControl->fRefNum, name, JACK_DEFAULT_AUDIO_TYPE, (JackPortFlags)port_flags, fEngineControl->fBufferSize)) == NO_PORT) { | ||||
jack_error("driver: cannot register port for %s", name); | jack_error("driver: cannot register port for %s", name); | ||||
return -1; | return -1; | ||||
} | } | ||||
port = fGraphManager->GetPort(port_index); | |||||
port->SetAlias(alias); | |||||
port = fGraphManager->GetPort(port_index); | |||||
port->SetAlias(alias); | |||||
port->SetLatency(fEngineControl->fBufferSize + fPlaybackLatency); | port->SetLatency(fEngineControl->fBufferSize + fPlaybackLatency); | ||||
fPlaybackPortList[i] = port_index; | fPlaybackPortList[i] = port_index; | ||||
JackLog("JackAudioDriver::Attach fPlaybackPortList[i] port_index = %ld\n", port_index); | JackLog("JackAudioDriver::Attach fPlaybackPortList[i] port_index = %ld\n", port_index); | ||||
// Monitor ports | // Monitor ports | ||||
if (fWithMonitorPorts) { | if (fWithMonitorPorts) { | ||||
JackLog("Create monitor port \n"); | JackLog("Create monitor port \n"); | ||||
@@ -162,7 +162,7 @@ int JackAudioDriver::Write() | |||||
{ | { | ||||
for (int i = 0; i < fPlaybackChannels; i++) { | for (int i = 0; i < fPlaybackChannels; i++) { | ||||
if (fGraphManager->GetConnectionsNum(fPlaybackPortList[i]) > 0) { | if (fGraphManager->GetConnectionsNum(fPlaybackPortList[i]) > 0) { | ||||
float* buffer = GetOutputBuffer(i); | |||||
float* buffer = GetOutputBuffer(i); | |||||
int size = sizeof(float) * fEngineControl->fBufferSize; | int size = sizeof(float) * fEngineControl->fBufferSize; | ||||
// Monitor ports | // Monitor ports | ||||
if (fWithMonitorPorts && fGraphManager->GetConnectionsNum(fMonitorPortList[i]) > 0) | if (fWithMonitorPorts && fGraphManager->GetConnectionsNum(fMonitorPortList[i]) > 0) | ||||
@@ -196,11 +196,11 @@ int JackAudioDriver::ProcessAsync() | |||||
if (fIsMaster) { | if (fIsMaster) { | ||||
if (!fEngine->Process(fLastWaitUst)) // fLastWaitUst is set in the "low level" layer | if (!fEngine->Process(fLastWaitUst)) // fLastWaitUst is set in the "low level" layer | ||||
jack_error("JackAudioDriver::ProcessAsync Process error"); | |||||
jack_error("JackAudioDriver::ProcessAsync Process error"); | |||||
fGraphManager->ResumeRefNum(fClientControl, fSynchroTable); | fGraphManager->ResumeRefNum(fClientControl, fSynchroTable); | ||||
if (ProcessSlaves() < 0) | |||||
jack_error("JackAudioDriver::ProcessAsync ProcessSlaves error"); | |||||
} else { | |||||
if (ProcessSlaves() < 0) | |||||
jack_error("JackAudioDriver::ProcessAsync ProcessSlaves error"); | |||||
} else { | |||||
fGraphManager->ResumeRefNum(fClientControl, fSynchroTable); | fGraphManager->ResumeRefNum(fClientControl, fSynchroTable); | ||||
} | } | ||||
return 0; | return 0; | ||||
@@ -221,17 +221,17 @@ int JackAudioDriver::ProcessSync() | |||||
if (fIsMaster) { | if (fIsMaster) { | ||||
if (fEngine->Process(fLastWaitUst)) { // fLastWaitUst is set in the "low level" layer | if (fEngine->Process(fLastWaitUst)) { // fLastWaitUst is set in the "low level" layer | ||||
fGraphManager->ResumeRefNum(fClientControl, fSynchroTable); | |||||
if (ProcessSlaves() < 0) | |||||
jack_error("JackAudioDriver::ProcessSync ProcessSlaves error, engine may now behave abnormally!!"); | |||||
if (fGraphManager->SuspendRefNum(fClientControl, fSynchroTable, fEngineControl->fTimeOutUsecs) < 0) | |||||
jack_error("JackAudioDriver::ProcessSync SuspendRefNum error, engine may now behave abnormally!!"); | |||||
} else { // Graph not finished: do not activate it | |||||
jack_error("ProcessSync: error"); | |||||
} | |||||
if (Write() < 0) // Write output buffers for the current cycle | |||||
jack_error("ProcessSync: write error"); | |||||
fGraphManager->ResumeRefNum(fClientControl, fSynchroTable); | |||||
if (ProcessSlaves() < 0) | |||||
jack_error("JackAudioDriver::ProcessSync ProcessSlaves error, engine may now behave abnormally!!"); | |||||
if (fGraphManager->SuspendRefNum(fClientControl, fSynchroTable, fEngineControl->fTimeOutUsecs) < 0) | |||||
jack_error("JackAudioDriver::ProcessSync SuspendRefNum error, engine may now behave abnormally!!"); | |||||
} else { // Graph not finished: do not activate it | |||||
jack_error("ProcessSync: error"); | |||||
} | |||||
if (Write() < 0) // Write output buffers for the current cycle | |||||
jack_error("ProcessSync: write error"); | |||||
} else { | } else { | ||||
fGraphManager->ResumeRefNum(fClientControl, fSynchroTable); | fGraphManager->ResumeRefNum(fClientControl, fSynchroTable); | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2004-2008 Grame | Copyright (C) 2004-2008 Grame | ||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
@@ -78,8 +78,8 @@ class EXPORT JackAudioDriver : public JackDriver | |||||
virtual int Detach(); | virtual int Detach(); | ||||
virtual int Write(); | virtual int Write(); | ||||
virtual int SetBufferSize(jack_nframes_t buffer_size); | |||||
virtual int SetSampleRate(jack_nframes_t sample_rate); | |||||
virtual int SetBufferSize(jack_nframes_t buffer_size); | |||||
virtual int SetSampleRate(jack_nframes_t sample_rate); | |||||
virtual void NotifyXRun(jack_time_t callback_usecs); // XRun notification sent by the driver | virtual void NotifyXRun(jack_time_t callback_usecs); // XRun notification sent by the driver | ||||
@@ -22,9 +22,9 @@ This program is free software; you can redistribute it and/or modify | |||||
#include <string.h> | #include <string.h> | ||||
#if defined (__APPLE__) | #if defined (__APPLE__) | ||||
#include <Accelerate/Accelerate.h> | |||||
#include <Accelerate/Accelerate.h> | |||||
#elif defined (__SSE__) | #elif defined (__SSE__) | ||||
#include <xmmintrin.h> | |||||
#include <xmmintrin.h> | |||||
#endif | #endif | ||||
namespace Jack | namespace Jack | ||||
@@ -38,9 +38,9 @@ static void AudioBufferInit(void* buffer, size_t buffer_size, jack_nframes_t) | |||||
static inline void MixAudioBuffer(float* mixbuffer, float* buffer, jack_nframes_t frames) | static inline void MixAudioBuffer(float* mixbuffer, float* buffer, jack_nframes_t frames) | ||||
{ | { | ||||
#ifdef __APPLE__ | #ifdef __APPLE__ | ||||
// It seems that a vector mult only operation does not exist... | |||||
float gain = 1.0f; | |||||
vDSP_vsma(buffer, 1, &gain, mixbuffer, 1, mixbuffer, 1, frames); | |||||
// It seems that a vector mult only operation does not exist... | |||||
float gain = 1.0f; | |||||
vDSP_vsma(buffer, 1, &gain, mixbuffer, 1, mixbuffer, 1, frames); | |||||
#else | #else | ||||
jack_nframes_t frames_group = frames / 4; | jack_nframes_t frames_group = frames / 4; | ||||
frames = frames % 4; | frames = frames % 4; | ||||
@@ -54,29 +54,29 @@ static inline void MixAudioBuffer(float* mixbuffer, float* buffer, jack_nframes_ | |||||
buffer += 4; | buffer += 4; | ||||
frames_group--; | frames_group--; | ||||
#else | #else | ||||
register float mixFloat1 = *mixbuffer; | |||||
register float sourceFloat1 = *buffer; | |||||
register float mixFloat2 = *(mixbuffer + 1); | |||||
register float sourceFloat2 = *(buffer + 1); | |||||
register float mixFloat3 = *(mixbuffer + 2); | |||||
register float sourceFloat3 = *(buffer + 2); | |||||
register float mixFloat4 = *(mixbuffer + 3); | |||||
register float sourceFloat4 = *(buffer + 3); | |||||
buffer += 4; | |||||
frames_group--; | |||||
mixFloat1 += sourceFloat1; | |||||
mixFloat2 += sourceFloat2; | |||||
mixFloat3 += sourceFloat3; | |||||
mixFloat4 += sourceFloat4; | |||||
*mixbuffer = mixFloat1; | |||||
*(mixbuffer + 1) = mixFloat2; | |||||
*(mixbuffer + 2) = mixFloat3; | |||||
*(mixbuffer + 3) = mixFloat4; | |||||
mixbuffer += 4; | |||||
register float mixFloat1 = *mixbuffer; | |||||
register float sourceFloat1 = *buffer; | |||||
register float mixFloat2 = *(mixbuffer + 1); | |||||
register float sourceFloat2 = *(buffer + 1); | |||||
register float mixFloat3 = *(mixbuffer + 2); | |||||
register float sourceFloat3 = *(buffer + 2); | |||||
register float mixFloat4 = *(mixbuffer + 3); | |||||
register float sourceFloat4 = *(buffer + 3); | |||||
buffer += 4; | |||||
frames_group--; | |||||
mixFloat1 += sourceFloat1; | |||||
mixFloat2 += sourceFloat2; | |||||
mixFloat3 += sourceFloat3; | |||||
mixFloat4 += sourceFloat4; | |||||
*mixbuffer = mixFloat1; | |||||
*(mixbuffer + 1) = mixFloat2; | |||||
*(mixbuffer + 2) = mixFloat3; | |||||
*(mixbuffer + 3) = mixFloat4; | |||||
mixbuffer += 4; | |||||
#endif | #endif | ||||
} | } | ||||
@@ -99,18 +99,19 @@ static void AudioBufferMixdown(void* mixbuffer, void** src_buffers, int src_coun | |||||
// Copy first buffer | // Copy first buffer | ||||
memcpy(mixbuffer, src_buffers[0], nframes * sizeof(float)); | memcpy(mixbuffer, src_buffers[0], nframes * sizeof(float)); | ||||
// Mix remaining buffers | |||||
// Mix remaining buffers | |||||
for (int i = 1; i < src_count; ++i) { | for (int i = 1; i < src_count; ++i) { | ||||
buffer = src_buffers[i]; | buffer = src_buffers[i]; | ||||
MixAudioBuffer(static_cast<float*>(mixbuffer), static_cast<float*>(buffer), nframes); | MixAudioBuffer(static_cast<float*>(mixbuffer), static_cast<float*>(buffer), nframes); | ||||
} | } | ||||
} | } | ||||
const JackPortType gAudioPortType = { | |||||
JACK_DEFAULT_AUDIO_TYPE, | |||||
AudioBufferInit, | |||||
AudioBufferMixdown | |||||
}; | |||||
const JackPortType gAudioPortType = | |||||
{ | |||||
JACK_DEFAULT_AUDIO_TYPE, | |||||
AudioBufferInit, | |||||
AudioBufferMixdown | |||||
}; | |||||
} // namespace Jack | } // namespace Jack | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2004-2008 Grame | |||||
Copyright (C) 2004-2008 Grame | |||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
it under the terms of the GNU General Public License as published by | it under the terms of the GNU General Public License as published by | ||||
@@ -65,13 +65,13 @@ class JackClientChannelInterface | |||||
// Stop listening for messages from the server | // Stop listening for messages from the server | ||||
virtual void Stop() | virtual void Stop() | ||||
{} | {} | ||||
virtual int ServerCheck(const char* server_name) | |||||
virtual int ServerCheck(const char* server_name) | |||||
{ | { | ||||
return -1; | |||||
} | |||||
virtual void ClientCheck(const char* name, char* name_res, int protocol, int options, int* status, int* result) | |||||
return -1; | |||||
} | |||||
virtual void ClientCheck(const char* name, char* name_res, int protocol, int options, int* status, int* result) | |||||
{} | {} | ||||
virtual void ClientOpen(const char* name, int* shared_engine, int* shared_client, int* shared_graph, int* result) | virtual void ClientOpen(const char* name, int* shared_engine, int* shared_client, int* shared_graph, int* result) | ||||
{} | {} | ||||
@@ -109,17 +109,17 @@ class JackClientChannelInterface | |||||
virtual void SetTimebaseCallback(int refnum, int conditional, int* result) | virtual void SetTimebaseCallback(int refnum, int conditional, int* result) | ||||
{} | {} | ||||
virtual void GetInternalClientName(int refnum, int int_ref, char* name_res, int* result) | |||||
virtual void GetInternalClientName(int refnum, int int_ref, char* name_res, int* result) | |||||
{} | {} | ||||
virtual void InternalClientHandle(int refnum, const char* client_name, int* status, int* int_ref, int* result) | |||||
virtual void InternalClientHandle(int refnum, const char* client_name, int* status, int* int_ref, int* result) | |||||
{} | {} | ||||
virtual void InternalClientLoad(int refnum, const char* client_name, const char* so_name, const char* objet_data, int options, int* status, int* int_ref, int* result) | |||||
virtual void InternalClientLoad(int refnum, const char* client_name, const char* so_name, const char* objet_data, int options, int* status, int* int_ref, int* result) | |||||
{} | {} | ||||
virtual void InternalClientUnload(int refnum, int int_ref, int* status, int* result) | |||||
virtual void InternalClientUnload(int refnum, int int_ref, int* status, int* result) | |||||
{} | {} | ||||
}; | }; | ||||
@@ -1,18 +1,18 @@ | |||||
/* | /* | ||||
Copyright (C) 2004-2006 Grame | |||||
Copyright (C) 2004-2006 Grame | |||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
it under the terms of the GNU Lesser General Public License as published by | it under the terms of the GNU Lesser General Public License as published by | ||||
the Free Software Foundation; either version 2.1 of the License, or | the Free Software Foundation; either version 2.1 of the License, or | ||||
(at your option) any later version. | (at your option) any later version. | ||||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | ||||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
GNU Lesser General Public License for more details. | GNU Lesser General Public License for more details. | ||||
You should have received a copy of the GNU Lesser General Public License | You should have received a copy of the GNU Lesser General Public License | ||||
along with this program; if not, write to the Free Software | |||||
along with this program; if not, write to the Free Software | |||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||||
*/ | */ | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2004-2008 Grame | Copyright (C) 2004-2008 Grame | ||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
@@ -49,10 +49,10 @@ JackClient::JackClient(JackSynchro** table) | |||||
fShutdown = NULL; | fShutdown = NULL; | ||||
fInit = NULL; | fInit = NULL; | ||||
fBufferSize = NULL; | fBufferSize = NULL; | ||||
fClientRegistration = NULL; | |||||
fClientRegistration = NULL; | |||||
fFreewheel = NULL; | fFreewheel = NULL; | ||||
fPortRegistration = NULL; | fPortRegistration = NULL; | ||||
fPortConnect = NULL; | |||||
fPortConnect = NULL; | |||||
fSync = NULL; | fSync = NULL; | ||||
fProcessArg = NULL; | fProcessArg = NULL; | ||||
fGraphOrderArg = NULL; | fGraphOrderArg = NULL; | ||||
@@ -63,10 +63,10 @@ JackClient::JackClient(JackSynchro** table) | |||||
fFreewheelArg = NULL; | fFreewheelArg = NULL; | ||||
fClientRegistrationArg = NULL; | fClientRegistrationArg = NULL; | ||||
fPortRegistrationArg = NULL; | fPortRegistrationArg = NULL; | ||||
fPortConnectArg = NULL; | |||||
fPortConnectArg = NULL; | |||||
fSyncArg = NULL; | fSyncArg = NULL; | ||||
fThreadFun = NULL; | |||||
fThreadFunArg = NULL; | |||||
fThreadFun = NULL; | |||||
fThreadFunArg = NULL; | |||||
fConditionnal = 0; // Temporary?? | fConditionnal = 0; // Temporary?? | ||||
} | } | ||||
@@ -106,12 +106,12 @@ void JackClient::SetupDriverSync(bool freewheel) | |||||
{ | { | ||||
if (!freewheel && !GetEngineControl()->fSyncMode) { | if (!freewheel && !GetEngineControl()->fSyncMode) { | ||||
JackLog("JackClient::SetupDriverSync driver sem in flush mode\n"); | JackLog("JackClient::SetupDriverSync driver sem in flush mode\n"); | ||||
fSynchroTable[AUDIO_DRIVER_REFNUM]->SetFlush(true); | |||||
fSynchroTable[AUDIO_DRIVER_REFNUM]->SetFlush(true); | |||||
fSynchroTable[FREEWHEEL_DRIVER_REFNUM]->SetFlush(true); | fSynchroTable[FREEWHEEL_DRIVER_REFNUM]->SetFlush(true); | ||||
fSynchroTable[LOOPBACK_DRIVER_REFNUM]->SetFlush(true); | fSynchroTable[LOOPBACK_DRIVER_REFNUM]->SetFlush(true); | ||||
} else { | } else { | ||||
JackLog("JackClient::SetupDriverSync driver sem in normal mode\n"); | JackLog("JackClient::SetupDriverSync driver sem in normal mode\n"); | ||||
fSynchroTable[AUDIO_DRIVER_REFNUM]->SetFlush(false); | |||||
fSynchroTable[AUDIO_DRIVER_REFNUM]->SetFlush(false); | |||||
fSynchroTable[FREEWHEEL_DRIVER_REFNUM]->SetFlush(false); | fSynchroTable[FREEWHEEL_DRIVER_REFNUM]->SetFlush(false); | ||||
fSynchroTable[LOOPBACK_DRIVER_REFNUM]->SetFlush(false); | fSynchroTable[LOOPBACK_DRIVER_REFNUM]->SetFlush(false); | ||||
} | } | ||||
@@ -123,7 +123,7 @@ void JackClient::SetupDriverSync(bool freewheel) | |||||
int JackClient::ClientNotifyImp(int refnum, const char* name, int notify, int sync, int value1, int value2) | int JackClient::ClientNotifyImp(int refnum, const char* name, int notify, int sync, int value1, int value2) | ||||
{ | { | ||||
return 0; | |||||
return 0; | |||||
} | } | ||||
int JackClient::ClientNotify(int refnum, const char* name, int notify, int sync, int value1, int value2) | int JackClient::ClientNotify(int refnum, const char* name, int notify, int sync, int value1, int value2) | ||||
@@ -135,17 +135,17 @@ int JackClient::ClientNotify(int refnum, const char* name, int notify, int sync, | |||||
case kAddClient: | case kAddClient: | ||||
res = ClientNotifyImp(refnum, name, notify, sync, value1, value2); | res = ClientNotifyImp(refnum, name, notify, sync, value1, value2); | ||||
break; | |||||
case kRemoveClient: | |||||
break; | |||||
case kRemoveClient: | |||||
res = ClientNotifyImp(refnum, name, notify, sync, value1, value2); | res = ClientNotifyImp(refnum, name, notify, sync, value1, value2); | ||||
break; | |||||
case kActivateClient: | |||||
JackLog("JackClient::kActivateClient name = %s ref = %ld \n", name, refnum); | |||||
Init(); | |||||
break; | |||||
} | |||||
break; | |||||
case kActivateClient: | |||||
JackLog("JackClient::kActivateClient name = %s ref = %ld \n", name, refnum); | |||||
Init(); | |||||
break; | |||||
} | |||||
/* | /* | ||||
The current semantic is that notifications can only be received when the client has been activated, | The current semantic is that notifications can only be received when the client has been activated, | ||||
@@ -154,18 +154,18 @@ int JackClient::ClientNotify(int refnum, const char* name, int notify, int sync, | |||||
if (IsActive()) { | if (IsActive()) { | ||||
switch (notify) { | switch (notify) { | ||||
case kAddClient: | |||||
JackLog("JackClient::kAddClient fName = %s name = %s\n", GetClientControl()->fName, name); | |||||
if (fClientRegistration && strcmp(GetClientControl()->fName, name) != 0) // Don't call the callback for the registering client itself | |||||
fClientRegistration(name, 1, fClientRegistrationArg); | |||||
break; | |||||
case kRemoveClient: | |||||
JackLog("JackClient::kRemoveClient fName = %s name = %s\n", GetClientControl()->fName, name); | |||||
if (fClientRegistration && strcmp(GetClientControl()->fName, name) != 0) // Don't call the callback for the registering client itself | |||||
fClientRegistration(name, 0, fClientRegistrationArg); | |||||
break; | |||||
case kAddClient: | |||||
JackLog("JackClient::kAddClient fName = %s name = %s\n", GetClientControl()->fName, name); | |||||
if (fClientRegistration && strcmp(GetClientControl()->fName, name) != 0) // Don't call the callback for the registering client itself | |||||
fClientRegistration(name, 1, fClientRegistrationArg); | |||||
break; | |||||
case kRemoveClient: | |||||
JackLog("JackClient::kRemoveClient fName = %s name = %s\n", GetClientControl()->fName, name); | |||||
if (fClientRegistration && strcmp(GetClientControl()->fName, name) != 0) // Don't call the callback for the registering client itself | |||||
fClientRegistration(name, 0, fClientRegistrationArg); | |||||
break; | |||||
case kBufferSizeCallback: | case kBufferSizeCallback: | ||||
JackLog("JackClient::kBufferSizeCallback buffer_size = %ld\n", value1); | JackLog("JackClient::kBufferSizeCallback buffer_size = %ld\n", value1); | ||||
@@ -206,14 +206,14 @@ int JackClient::ClientNotify(int refnum, const char* name, int notify, int sync, | |||||
if (fPortRegistration) | if (fPortRegistration) | ||||
fPortRegistration(value1, 0, fPortRegistrationArg); | fPortRegistration(value1, 0, fPortRegistrationArg); | ||||
break; | break; | ||||
case kPortConnectCallback: | |||||
case kPortConnectCallback: | |||||
JackLog("JackClient::kPortConnectCallback src = %ld dst = %ld\n", value1, value2); | JackLog("JackClient::kPortConnectCallback src = %ld dst = %ld\n", value1, value2); | ||||
if (fPortConnect) | if (fPortConnect) | ||||
fPortConnect(value1, value2, 1, fPortConnectArg); | fPortConnect(value1, value2, 1, fPortConnectArg); | ||||
break; | break; | ||||
case kPortDisconnectCallback: | |||||
case kPortDisconnectCallback: | |||||
JackLog("JackClient::kPortDisconnectCallback src = %ld dst = %ld\n", value1, value2); | JackLog("JackClient::kPortDisconnectCallback src = %ld dst = %ld\n", value1, value2); | ||||
if (fPortConnect) | if (fPortConnect) | ||||
fPortConnect(value1, value2, 0, fPortConnectArg); | fPortConnect(value1, value2, 0, fPortConnectArg); | ||||
@@ -224,14 +224,14 @@ int JackClient::ClientNotify(int refnum, const char* name, int notify, int sync, | |||||
if (fXrun) | if (fXrun) | ||||
res = fXrun(fXrunArg); | res = fXrun(fXrunArg); | ||||
break; | break; | ||||
} | |||||
} | |||||
} | } | ||||
return res; | return res; | ||||
} | } | ||||
/*! | /*! | ||||
\brief We need to start thread before activating in the server, otherwise the FW driver | |||||
\brief We need to start thread before activating in the server, otherwise the FW driver | |||||
connected to the client may not be activated. | connected to the client may not be activated. | ||||
*/ | */ | ||||
int JackClient::Activate() | int JackClient::Activate() | ||||
@@ -240,18 +240,18 @@ int JackClient::Activate() | |||||
if (IsActive()) | if (IsActive()) | ||||
return 0; | return 0; | ||||
/* TODO : solve WIN32 thread Kill issue | |||||
#ifdef WIN32 | |||||
// Done first so that the RT thread then access an allocated synchro | |||||
if (!fSynchroTable[GetClientControl()->fRefNum]->Connect(GetClientControl()->fName)) { | |||||
jack_error("Cannot ConnectSemaphore %s client", GetClientControl()->fName); | |||||
return -1; | |||||
} | |||||
#endif | |||||
*/ | |||||
/* TODO : solve WIN32 thread Kill issue | |||||
#ifdef WIN32 | |||||
// Done first so that the RT thread then access an allocated synchro | |||||
if (!fSynchroTable[GetClientControl()->fRefNum]->Connect(GetClientControl()->fName)) { | |||||
jack_error("Cannot ConnectSemaphore %s client", GetClientControl()->fName); | |||||
return -1; | |||||
} | |||||
#endif | |||||
*/ | |||||
if (StartThread() < 0) | |||||
return -1; | |||||
if (StartThread() < 0) | |||||
return -1; | |||||
int result = -1; | int result = -1; | ||||
fChannel->ClientActivate(GetClientControl()->fRefNum, &result); | fChannel->ClientActivate(GetClientControl()->fRefNum, &result); | ||||
@@ -284,15 +284,15 @@ int JackClient::Deactivate() | |||||
JackLog("JackClient::Deactivate res = %ld \n", result); | JackLog("JackClient::Deactivate res = %ld \n", result); | ||||
// We need to wait for the new engine cycle before stopping the RT thread, but this is done by ClientDeactivate | // We need to wait for the new engine cycle before stopping the RT thread, but this is done by ClientDeactivate | ||||
/* TODO : solve WIN32 thread Kill issue | |||||
#ifdef WIN32 | |||||
fSynchroTable[GetClientControl()->fRefNum]->Disconnect(); | |||||
fThread->Stop(); | |||||
#else | |||||
fThread->Kill(); | |||||
#endif | |||||
*/ | |||||
fThread->Kill(); | |||||
/* TODO : solve WIN32 thread Kill issue | |||||
#ifdef WIN32 | |||||
fSynchroTable[GetClientControl()->fRefNum]->Disconnect(); | |||||
fThread->Stop(); | |||||
#else | |||||
fThread->Kill(); | |||||
#endif | |||||
*/ | |||||
fThread->Kill(); | |||||
return result; | return result; | ||||
} | } | ||||
@@ -307,7 +307,7 @@ bool JackClient::Init() | |||||
{ | { | ||||
if (fInit) { | if (fInit) { | ||||
JackLog("JackClient::Init calling client thread init callback\n"); | JackLog("JackClient::Init calling client thread init callback\n"); | ||||
fInit(fInitArg); | |||||
fInit(fInitArg); | |||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
@@ -341,53 +341,53 @@ int JackClient::StartThread() | |||||
*/ | */ | ||||
bool JackClient::Execute() | bool JackClient::Execute() | ||||
{ | { | ||||
if (fThreadFun) { | |||||
fThreadFun(fThreadFunArg); | |||||
} else { | |||||
if (WaitFirstSync()) | |||||
ExecuteThread(); | |||||
} | |||||
return false; // Never reached | |||||
if (fThreadFun) { | |||||
fThreadFun(fThreadFunArg); | |||||
} else { | |||||
if (WaitFirstSync()) | |||||
ExecuteThread(); | |||||
} | |||||
return false; // Never reached | |||||
} | } | ||||
inline bool JackClient::WaitFirstSync() | inline bool JackClient::WaitFirstSync() | ||||
{ | { | ||||
while (true) { | |||||
// Start first cycle | |||||
WaitSync(); | |||||
if (IsActive()) { | |||||
CallSyncCallback(); | |||||
// Finish first cycle | |||||
if (Wait(CallProcessCallback()) != GetEngineControl()->fBufferSize) | |||||
return false; | |||||
return true; | |||||
} else { | |||||
JackLog("Process called for an inactive client\n"); | |||||
} | |||||
SignalSync(); | |||||
} | |||||
return false; // Never reached | |||||
while (true) { | |||||
// Start first cycle | |||||
WaitSync(); | |||||
if (IsActive()) { | |||||
CallSyncCallback(); | |||||
// Finish first cycle | |||||
if (Wait(CallProcessCallback()) != GetEngineControl()->fBufferSize) | |||||
return false; | |||||
return true; | |||||
} else { | |||||
JackLog("Process called for an inactive client\n"); | |||||
} | |||||
SignalSync(); | |||||
} | |||||
return false; // Never reached | |||||
} | } | ||||
inline void JackClient::ExecuteThread() | inline void JackClient::ExecuteThread() | ||||
{ | { | ||||
while (true) { | |||||
if (Wait(CallProcessCallback()) != GetEngineControl()->fBufferSize) | |||||
return; | |||||
} | |||||
while (true) { | |||||
if (Wait(CallProcessCallback()) != GetEngineControl()->fBufferSize) | |||||
return; | |||||
} | |||||
} | } | ||||
jack_nframes_t JackClient::Wait(int status) | jack_nframes_t JackClient::Wait(int status) | ||||
{ | { | ||||
if (status == 0) | |||||
CallTimebaseCallback(); | |||||
SignalSync(); | |||||
if (status != 0) | |||||
return End(); | |||||
if (!WaitSync()) | |||||
return Error(); | |||||
CallSyncCallback(); | |||||
return GetEngineControl()->fBufferSize; | |||||
if (status == 0) | |||||
CallTimebaseCallback(); | |||||
SignalSync(); | |||||
if (status != 0) | |||||
return End(); | |||||
if (!WaitSync()) | |||||
return Error(); | |||||
CallSyncCallback(); | |||||
return GetEngineControl()->fBufferSize; | |||||
} | } | ||||
/* | /* | ||||
@@ -400,19 +400,19 @@ jack_nframes_t JackClient::Wait(int status) | |||||
jack_nframes_t JackClient::CycleWait() | jack_nframes_t JackClient::CycleWait() | ||||
{ | { | ||||
if (!WaitSync()) | |||||
return Error(); | |||||
CallSyncCallback(); | |||||
return GetEngineControl()->fBufferSize; | |||||
if (!WaitSync()) | |||||
return Error(); | |||||
CallSyncCallback(); | |||||
return GetEngineControl()->fBufferSize; | |||||
} | } | ||||
int JackClient::SetProcessThread(JackThreadCallback fun, void *arg) | int JackClient::SetProcessThread(JackThreadCallback fun, void *arg) | ||||
{ | { | ||||
if (IsActive()) { | |||||
if (IsActive()) { | |||||
jack_error("You cannot set callbacks on an active client"); | jack_error("You cannot set callbacks on an active client"); | ||||
return -1; | return -1; | ||||
} else { | } else { | ||||
fThreadFun = fun; | |||||
fThreadFun = fun; | |||||
fThreadFunArg = arg; | fThreadFunArg = arg; | ||||
return 0; | return 0; | ||||
} | } | ||||
@@ -420,32 +420,32 @@ int JackClient::SetProcessThread(JackThreadCallback fun, void *arg) | |||||
void JackClient::CycleSignal(int status) | void JackClient::CycleSignal(int status) | ||||
{ | { | ||||
if (status == 0) | |||||
CallTimebaseCallback(); | |||||
SignalSync(); | |||||
if (status != 0) | |||||
End(); | |||||
if (status == 0) | |||||
CallTimebaseCallback(); | |||||
SignalSync(); | |||||
if (status != 0) | |||||
End(); | |||||
} | } | ||||
inline int JackClient::CallProcessCallback() | inline int JackClient::CallProcessCallback() | ||||
{ | { | ||||
return (fProcess != NULL) ? fProcess(GetEngineControl()->fBufferSize, fProcessArg) : 0; | |||||
return (fProcess != NULL) ? fProcess(GetEngineControl()->fBufferSize, fProcessArg) : 0; | |||||
} | } | ||||
inline bool JackClient::WaitSync() | inline bool JackClient::WaitSync() | ||||
{ | { | ||||
// Suspend itself: wait on the input synchro | |||||
// Suspend itself: wait on the input synchro | |||||
if (GetGraphManager()->SuspendRefNum(GetClientControl(), fSynchroTable, 0x7FFFFFFF) < 0) { | if (GetGraphManager()->SuspendRefNum(GetClientControl(), fSynchroTable, 0x7FFFFFFF) < 0) { | ||||
jack_error("SuspendRefNum error"); | |||||
return false; | |||||
} else { | |||||
return true; | |||||
} | |||||
jack_error("SuspendRefNum error"); | |||||
return false; | |||||
} else { | |||||
return true; | |||||
} | |||||
} | } | ||||
inline void JackClient::SignalSync() | inline void JackClient::SignalSync() | ||||
{ | { | ||||
// Resume: signal output clients connected to the running client | |||||
// Resume: signal output clients connected to the running client | |||||
if (GetGraphManager()->ResumeRefNum(GetClientControl(), fSynchroTable) < 0) { | if (GetGraphManager()->ResumeRefNum(GetClientControl(), fSynchroTable) < 0) { | ||||
jack_error("ResumeRefNum error"); | jack_error("ResumeRefNum error"); | ||||
} | } | ||||
@@ -453,27 +453,27 @@ inline void JackClient::SignalSync() | |||||
inline int JackClient::End() | inline int JackClient::End() | ||||
{ | { | ||||
JackLog("JackClient::Execute end name = %s\n", GetClientControl()->fName); | |||||
// Hum... not sure about this, the following "close" code is called in the RT thread... | |||||
int result; | |||||
fThread->DropRealTime(); | |||||
GetClientControl()->fActive = false; | |||||
fChannel->ClientDeactivate(GetClientControl()->fRefNum, &result); | |||||
JackLog("JackClient::Execute end name = %s\n", GetClientControl()->fName); | |||||
// Hum... not sure about this, the following "close" code is called in the RT thread... | |||||
int result; | |||||
fThread->DropRealTime(); | |||||
GetClientControl()->fActive = false; | |||||
fChannel->ClientDeactivate(GetClientControl()->fRefNum, &result); | |||||
fThread->Terminate(); | fThread->Terminate(); | ||||
return 0; // Never reached | |||||
return 0; // Never reached | |||||
} | } | ||||
inline int JackClient::Error() | inline int JackClient::Error() | ||||
{ | { | ||||
jack_error("JackClient::Execute error name = %s", GetClientControl()->fName); | |||||
// Hum... not sure about this, the following "close" code is called in the RT thread... | |||||
int result; | |||||
jack_error("JackClient::Execute error name = %s", GetClientControl()->fName); | |||||
// Hum... not sure about this, the following "close" code is called in the RT thread... | |||||
int result; | |||||
fThread->DropRealTime(); | fThread->DropRealTime(); | ||||
GetClientControl()->fActive = false; | |||||
fChannel->ClientDeactivate(GetClientControl()->fRefNum, &result); | |||||
GetClientControl()->fActive = false; | |||||
fChannel->ClientDeactivate(GetClientControl()->fRefNum, &result); | |||||
ShutDown(); | ShutDown(); | ||||
fThread->Terminate(); | |||||
return 0; // Never reached | |||||
fThread->Terminate(); | |||||
return 0; // Never reached | |||||
} | } | ||||
//----------------- | //----------------- | ||||
@@ -523,7 +523,7 @@ int JackClient::PortRegister(const char* port_name, const char* port_type, unsig | |||||
int JackClient::PortUnRegister(jack_port_id_t port_index) | int JackClient::PortUnRegister(jack_port_id_t port_index) | ||||
{ | { | ||||
JackLog("JackClient::PortUnRegister port_index = %ld\n", port_index); | JackLog("JackClient::PortUnRegister port_index = %ld\n", port_index); | ||||
list<jack_port_id_t>::iterator it = find(fPortList.begin(), fPortList.end(), port_index); | |||||
list<jack_port_id_t>::iterator it = find(fPortList.begin(), fPortList.end(), port_index); | |||||
if (it != fPortList.end()) { | if (it != fPortList.end()) { | ||||
fPortList.erase(it); | fPortList.erase(it); | ||||
@@ -824,7 +824,7 @@ int JackClient::SetXRunCallback(JackXRunCallback callback, void *arg) | |||||
jack_error("You cannot set callbacks on an active client"); | jack_error("You cannot set callbacks on an active client"); | ||||
return -1; | return -1; | ||||
} else { | } else { | ||||
GetClientControl()->fCallback[kXRunCallback] = (callback != NULL); | |||||
GetClientControl()->fCallback[kXRunCallback] = (callback != NULL); | |||||
fXrunArg = arg; | fXrunArg = arg; | ||||
fXrun = callback; | fXrun = callback; | ||||
return 0; | return 0; | ||||
@@ -851,7 +851,7 @@ int JackClient::SetGraphOrderCallback(JackGraphOrderCallback callback, void *arg | |||||
jack_error("You cannot set callbacks on an active client"); | jack_error("You cannot set callbacks on an active client"); | ||||
return -1; | return -1; | ||||
} else { | } else { | ||||
GetClientControl()->fCallback[kGraphOrderCallback] = (callback != NULL); | |||||
GetClientControl()->fCallback[kGraphOrderCallback] = (callback != NULL); | |||||
fGraphOrder = callback; | fGraphOrder = callback; | ||||
fGraphOrderArg = arg; | fGraphOrderArg = arg; | ||||
return 0; | return 0; | ||||
@@ -864,7 +864,7 @@ int JackClient::SetBufferSizeCallback(JackBufferSizeCallback callback, void *arg | |||||
jack_error("You cannot set callbacks on an active client"); | jack_error("You cannot set callbacks on an active client"); | ||||
return -1; | return -1; | ||||
} else { | } else { | ||||
GetClientControl()->fCallback[kBufferSizeCallback] = (callback != NULL); | |||||
GetClientControl()->fCallback[kBufferSizeCallback] = (callback != NULL); | |||||
fBufferSizeArg = arg; | fBufferSizeArg = arg; | ||||
fBufferSize = callback; | fBufferSize = callback; | ||||
return 0; | return 0; | ||||
@@ -877,8 +877,8 @@ int JackClient::SetClientRegistrationCallback(JackClientRegistrationCallback cal | |||||
jack_error("You cannot set callbacks on an active client"); | jack_error("You cannot set callbacks on an active client"); | ||||
return -1; | return -1; | ||||
} else { | } else { | ||||
// kAddClient and kRemoveClient notifications must be delivered by the server in any case | |||||
fClientRegistrationArg = arg; | |||||
// kAddClient and kRemoveClient notifications must be delivered by the server in any case | |||||
fClientRegistrationArg = arg; | |||||
fClientRegistration = callback; | fClientRegistration = callback; | ||||
return 0; | return 0; | ||||
} | } | ||||
@@ -890,8 +890,8 @@ int JackClient::SetFreewheelCallback(JackFreewheelCallback callback, void *arg) | |||||
jack_error("You cannot set callbacks on an active client"); | jack_error("You cannot set callbacks on an active client"); | ||||
return -1; | return -1; | ||||
} else { | } else { | ||||
GetClientControl()->fCallback[kStartFreewheelCallback] = (callback != NULL); | |||||
GetClientControl()->fCallback[kStopFreewheelCallback] = (callback != NULL); | |||||
GetClientControl()->fCallback[kStartFreewheelCallback] = (callback != NULL); | |||||
GetClientControl()->fCallback[kStopFreewheelCallback] = (callback != NULL); | |||||
fFreewheelArg = arg; | fFreewheelArg = arg; | ||||
fFreewheel = callback; | fFreewheel = callback; | ||||
return 0; | return 0; | ||||
@@ -904,8 +904,8 @@ int JackClient::SetPortRegistrationCallback(JackPortRegistrationCallback callbac | |||||
jack_error("You cannot set callbacks on an active client"); | jack_error("You cannot set callbacks on an active client"); | ||||
return -1; | return -1; | ||||
} else { | } else { | ||||
GetClientControl()->fCallback[kPortRegistrationOnCallback] = (callback != NULL); | |||||
GetClientControl()->fCallback[kPortRegistrationOffCallback] = (callback != NULL); | |||||
GetClientControl()->fCallback[kPortRegistrationOnCallback] = (callback != NULL); | |||||
GetClientControl()->fCallback[kPortRegistrationOffCallback] = (callback != NULL); | |||||
fPortRegistrationArg = arg; | fPortRegistrationArg = arg; | ||||
fPortRegistration = callback; | fPortRegistration = callback; | ||||
return 0; | return 0; | ||||
@@ -918,8 +918,8 @@ int JackClient::SetPortConnectCallback(JackPortConnectCallback callback, void *a | |||||
jack_error("You cannot set callbacks on an active client"); | jack_error("You cannot set callbacks on an active client"); | ||||
return -1; | return -1; | ||||
} else { | } else { | ||||
GetClientControl()->fCallback[kPortConnectCallback] = (callback != NULL); | |||||
GetClientControl()->fCallback[kPortDisconnectCallback] = (callback != NULL); | |||||
GetClientControl()->fCallback[kPortConnectCallback] = (callback != NULL); | |||||
GetClientControl()->fCallback[kPortDisconnectCallback] = (callback != NULL); | |||||
fPortConnectArg = arg; | fPortConnectArg = arg; | ||||
fPortConnect = callback; | fPortConnect = callback; | ||||
return 0; | return 0; | ||||
@@ -932,62 +932,62 @@ int JackClient::SetPortConnectCallback(JackPortConnectCallback callback, void *a | |||||
char* JackClient::GetInternalClientName(int ref) | char* JackClient::GetInternalClientName(int ref) | ||||
{ | { | ||||
char name_res[JACK_CLIENT_NAME_SIZE]; | |||||
int result = -1; | |||||
fChannel->GetInternalClientName(GetClientControl()->fRefNum, ref, name_res, &result); | |||||
if (result < 0) { | |||||
return NULL; | |||||
} else { | |||||
char* name = (char*)malloc(strlen(name_res)); | |||||
strcpy(name, name_res); | |||||
return name; | |||||
} | |||||
char name_res[JACK_CLIENT_NAME_SIZE]; | |||||
int result = -1; | |||||
fChannel->GetInternalClientName(GetClientControl()->fRefNum, ref, name_res, &result); | |||||
if (result < 0) { | |||||
return NULL; | |||||
} else { | |||||
char* name = (char*)malloc(strlen(name_res)); | |||||
strcpy(name, name_res); | |||||
return name; | |||||
} | |||||
} | } | ||||
int JackClient::InternalClientHandle(const char* client_name, jack_status_t* status) | int JackClient::InternalClientHandle(const char* client_name, jack_status_t* status) | ||||
{ | { | ||||
int int_ref, result = -1; | |||||
fChannel->InternalClientHandle(GetClientControl()->fRefNum, client_name, (int*)status, &int_ref, &result); | |||||
return int_ref; | |||||
int int_ref, result = -1; | |||||
fChannel->InternalClientHandle(GetClientControl()->fRefNum, client_name, (int*)status, &int_ref, &result); | |||||
return int_ref; | |||||
} | } | ||||
int JackClient::InternalClientLoad(const char* client_name, jack_options_t options, jack_status_t* status, jack_varargs_t* va) | int JackClient::InternalClientLoad(const char* client_name, jack_options_t options, jack_status_t* status, jack_varargs_t* va) | ||||
{ | { | ||||
if (strlen(client_name) >= JACK_CLIENT_NAME_SIZE) { | |||||
jack_error ("\"%s\" is too long for a JACK client name.\n" | |||||
"Please use %lu characters or less.", | |||||
client_name, JACK_CLIENT_NAME_SIZE); | |||||
return 0; | |||||
} | |||||
if (va->load_name && (strlen(va->load_name) >= PATH_MAX)) { | |||||
jack_error("\"%s\" is too long for a shared object name.\n" | |||||
"Please use %lu characters or less.", | |||||
va->load_name, PATH_MAX); | |||||
int my_status1 = *status | (JackFailure | JackInvalidOption); | |||||
*status = (jack_status_t)my_status1; | |||||
return 0; | |||||
} | |||||
if (va->load_init && (strlen(va->load_init) >= JACK_LOAD_INIT_LIMIT)) { | |||||
jack_error ("\"%s\" is too long for internal client init " | |||||
"string.\nPlease use %lu characters or less.", | |||||
va->load_init, JACK_LOAD_INIT_LIMIT); | |||||
int my_status1 = *status | (JackFailure | JackInvalidOption); | |||||
*status = (jack_status_t)my_status1; | |||||
return 0; | |||||
} | |||||
int int_ref, result = -1; | |||||
fChannel->InternalClientLoad(GetClientControl()->fRefNum, client_name, va->load_name, va->load_init, options, (int*)status, &int_ref, &result); | |||||
return int_ref; | |||||
if (strlen(client_name) >= JACK_CLIENT_NAME_SIZE) { | |||||
jack_error ("\"%s\" is too long for a JACK client name.\n" | |||||
"Please use %lu characters or less.", | |||||
client_name, JACK_CLIENT_NAME_SIZE); | |||||
return 0; | |||||
} | |||||
if (va->load_name && (strlen(va->load_name) >= PATH_MAX)) { | |||||
jack_error("\"%s\" is too long for a shared object name.\n" | |||||
"Please use %lu characters or less.", | |||||
va->load_name, PATH_MAX); | |||||
int my_status1 = *status | (JackFailure | JackInvalidOption); | |||||
*status = (jack_status_t)my_status1; | |||||
return 0; | |||||
} | |||||
if (va->load_init && (strlen(va->load_init) >= JACK_LOAD_INIT_LIMIT)) { | |||||
jack_error ("\"%s\" is too long for internal client init " | |||||
"string.\nPlease use %lu characters or less.", | |||||
va->load_init, JACK_LOAD_INIT_LIMIT); | |||||
int my_status1 = *status | (JackFailure | JackInvalidOption); | |||||
*status = (jack_status_t)my_status1; | |||||
return 0; | |||||
} | |||||
int int_ref, result = -1; | |||||
fChannel->InternalClientLoad(GetClientControl()->fRefNum, client_name, va->load_name, va->load_init, options, (int*)status, &int_ref, &result); | |||||
return int_ref; | |||||
} | } | ||||
void JackClient::InternalClientUnload(int ref, jack_status_t* status) | void JackClient::InternalClientUnload(int ref, jack_status_t* status) | ||||
{ | { | ||||
int result = -1; | |||||
fChannel->InternalClientUnload(GetClientControl()->fRefNum, ref, (int*)status, &result); | |||||
int result = -1; | |||||
fChannel->InternalClientUnload(GetClientControl()->fRefNum, ref, (int*)status, &result); | |||||
} | } | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2004-2008 Grame | Copyright (C) 2004-2008 Grame | ||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
@@ -50,8 +50,8 @@ typedef void (*JackShutdownCallback)(void *arg); | |||||
class JackClient : public JackClientInterface, public JackRunnableInterface | class JackClient : public JackClientInterface, public JackRunnableInterface | ||||
{ | { | ||||
friend class JackDebugClient; | |||||
friend class JackDebugClient; | |||||
protected: | protected: | ||||
JackProcessCallback fProcess; | JackProcessCallback fProcess; | ||||
@@ -60,29 +60,29 @@ class JackClient : public JackClientInterface, public JackRunnableInterface | |||||
JackShutdownCallback fShutdown; | JackShutdownCallback fShutdown; | ||||
JackThreadInitCallback fInit; | JackThreadInitCallback fInit; | ||||
JackBufferSizeCallback fBufferSize; | JackBufferSizeCallback fBufferSize; | ||||
JackClientRegistrationCallback fClientRegistration; | |||||
JackClientRegistrationCallback fClientRegistration; | |||||
JackFreewheelCallback fFreewheel; | JackFreewheelCallback fFreewheel; | ||||
JackPortRegistrationCallback fPortRegistration; | JackPortRegistrationCallback fPortRegistration; | ||||
JackPortConnectCallback fPortConnect; | |||||
JackPortConnectCallback fPortConnect; | |||||
JackTimebaseCallback fTimebase; | JackTimebaseCallback fTimebase; | ||||
JackSyncCallback fSync; | JackSyncCallback fSync; | ||||
JackThreadCallback fThreadFun; | |||||
JackThreadCallback fThreadFun; | |||||
void* fProcessArg; | void* fProcessArg; | ||||
void* fGraphOrderArg; | void* fGraphOrderArg; | ||||
void* fXrunArg; | void* fXrunArg; | ||||
void* fShutdownArg; | void* fShutdownArg; | ||||
void* fInitArg; | void* fInitArg; | ||||
void* fBufferSizeArg; | void* fBufferSizeArg; | ||||
void* fClientRegistrationArg; | |||||
void* fClientRegistrationArg; | |||||
void* fFreewheelArg; | void* fFreewheelArg; | ||||
void* fPortRegistrationArg; | void* fPortRegistrationArg; | ||||
void* fPortConnectArg; | |||||
void* fPortConnectArg; | |||||
void* fTimebaseArg; | void* fTimebaseArg; | ||||
void* fSyncArg; | void* fSyncArg; | ||||
void* fThreadFunArg; | |||||
void* fThreadFunArg; | |||||
int fConditionnal; | int fConditionnal; | ||||
char fServerName[64]; | |||||
char fServerName[64]; | |||||
JackThread* fThread; /*! Thread to execute the Process function */ | JackThread* fThread; /*! Thread to execute the Process function */ | ||||
JackClientChannelInterface* fChannel; | JackClientChannelInterface* fChannel; | ||||
@@ -98,15 +98,15 @@ class JackClient : public JackClientInterface, public JackRunnableInterface | |||||
int RequestNewPos(jack_position_t* pos); | int RequestNewPos(jack_position_t* pos); | ||||
virtual int ClientNotifyImp(int refnum, const char* name, int notify, int sync, int value1, int value); | virtual int ClientNotifyImp(int refnum, const char* name, int notify, int sync, int value1, int value); | ||||
// Fons Adriaensen thread model | |||||
inline bool WaitFirstSync(); | |||||
inline void ExecuteThread(); | |||||
inline bool WaitSync(); | |||||
inline void SignalSync(); | |||||
inline int CallProcessCallback(); | |||||
inline int End(); | |||||
inline int Error(); | |||||
// Fons Adriaensen thread model | |||||
inline bool WaitFirstSync(); | |||||
inline void ExecuteThread(); | |||||
inline bool WaitSync(); | |||||
inline void SignalSync(); | |||||
inline int CallProcessCallback(); | |||||
inline int End(); | |||||
inline int Error(); | |||||
public: | public: | ||||
@@ -162,23 +162,23 @@ class JackClient : public JackClientInterface, public JackRunnableInterface | |||||
virtual int SetInitCallback(JackThreadInitCallback callback, void* arg); | virtual int SetInitCallback(JackThreadInitCallback callback, void* arg); | ||||
virtual int SetGraphOrderCallback(JackGraphOrderCallback callback, void* arg); | virtual int SetGraphOrderCallback(JackGraphOrderCallback callback, void* arg); | ||||
virtual int SetBufferSizeCallback(JackBufferSizeCallback callback, void* arg); | virtual int SetBufferSizeCallback(JackBufferSizeCallback callback, void* arg); | ||||
virtual int SetClientRegistrationCallback(JackClientRegistrationCallback callback, void* arg); | |||||
virtual int SetClientRegistrationCallback(JackClientRegistrationCallback callback, void* arg); | |||||
virtual int SetFreewheelCallback(JackFreewheelCallback callback, void* arg); | virtual int SetFreewheelCallback(JackFreewheelCallback callback, void* arg); | ||||
virtual int SetPortRegistrationCallback(JackPortRegistrationCallback callback, void* arg); | virtual int SetPortRegistrationCallback(JackPortRegistrationCallback callback, void* arg); | ||||
virtual int SetPortConnectCallback(JackPortConnectCallback callback, void *arg); | |||||
// Internal clients | |||||
virtual char* GetInternalClientName(int ref); | |||||
virtual int InternalClientHandle(const char* client_name, jack_status_t* status); | |||||
virtual int InternalClientLoad(const char* client_name, jack_options_t options, jack_status_t* status, jack_varargs_t* va); | |||||
virtual void InternalClientUnload(int ref, jack_status_t* status); | |||||
// Fons Adriaensen thread model | |||||
virtual jack_nframes_t Wait(int status); | |||||
virtual jack_nframes_t CycleWait(); | |||||
void CycleSignal(int status); | |||||
int SetProcessThread(JackThreadCallback fun, void *arg); | |||||
virtual int SetPortConnectCallback(JackPortConnectCallback callback, void *arg); | |||||
// Internal clients | |||||
virtual char* GetInternalClientName(int ref); | |||||
virtual int InternalClientHandle(const char* client_name, jack_status_t* status); | |||||
virtual int InternalClientLoad(const char* client_name, jack_options_t options, jack_status_t* status, jack_varargs_t* va); | |||||
virtual void InternalClientUnload(int ref, jack_status_t* status); | |||||
// Fons Adriaensen thread model | |||||
virtual jack_nframes_t Wait(int status); | |||||
virtual jack_nframes_t CycleWait(); | |||||
void CycleSignal(int status); | |||||
int SetProcessThread(JackThreadCallback fun, void *arg); | |||||
// JackRunnableInterface interface | // JackRunnableInterface interface | ||||
bool Init(); | bool Init(); | ||||
@@ -31,16 +31,16 @@ namespace Jack | |||||
{ | { | ||||
/*! | /*! | ||||
\brief Client control in shared memory. | |||||
\brief Client control in shared memory. | |||||
*/ | */ | ||||
struct JackClientControl : public JackShmMem | struct JackClientControl : public JackShmMem | ||||
{ | { | ||||
char fName[JACK_CLIENT_NAME_SIZE + 1]; | char fName[JACK_CLIENT_NAME_SIZE + 1]; | ||||
bool fCallback[kMaxNotification]; | |||||
volatile jack_transport_state_t fTransportState; | |||||
int fRefNum; | |||||
bool fActive; | |||||
bool fCallback[kMaxNotification]; | |||||
volatile jack_transport_state_t fTransportState; | |||||
int fRefNum; | |||||
bool fActive; | |||||
JackClientControl(const char* name, int refnum) | JackClientControl(const char* name, int refnum) | ||||
{ | { | ||||
@@ -60,16 +60,16 @@ struct JackClientControl : public JackShmMem | |||||
void Init(const char* name, int refnum) | void Init(const char* name, int refnum) | ||||
{ | { | ||||
strcpy(fName, name); | strcpy(fName, name); | ||||
for (int i = 0; i < kMaxNotification; i++) | |||||
fCallback[i] = false; | |||||
// Always activated | |||||
fCallback[kAddClient] = true; | |||||
fCallback[kRemoveClient] = true; | |||||
fCallback[kActivateClient] = true; | |||||
// So that driver synchro are correctly setup in "flush" or "normal" mode | |||||
fCallback[kStartFreewheelCallback] = true; | |||||
fCallback[kStopFreewheelCallback] = true; | |||||
fRefNum = refnum; | |||||
for (int i = 0; i < kMaxNotification; i++) | |||||
fCallback[i] = false; | |||||
// Always activated | |||||
fCallback[kAddClient] = true; | |||||
fCallback[kRemoveClient] = true; | |||||
fCallback[kActivateClient] = true; | |||||
// So that driver synchro are correctly setup in "flush" or "normal" mode | |||||
fCallback[kStartFreewheelCallback] = true; | |||||
fCallback[kStopFreewheelCallback] = true; | |||||
fRefNum = refnum; | |||||
fTransportState = JackTransportStopped; | fTransportState = JackTransportStopped; | ||||
fActive = false; | fActive = false; | ||||
} | } | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2004-2008 Grame | |||||
Copyright (C) 2004-2008 Grame | |||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
it under the terms of the GNU General Public License as published by | it under the terms of the GNU General Public License as published by | ||||
@@ -245,7 +245,7 @@ void JackConnectionManager::ResetGraph(JackClientTiming* timing) | |||||
// Reset activation counter : must be done *before* starting to resume clients | // Reset activation counter : must be done *before* starting to resume clients | ||||
for (int i = 0; i < CLIENT_NUM; i++) { | for (int i = 0; i < CLIENT_NUM; i++) { | ||||
fInputCounter[i].Reset(); | fInputCounter[i].Reset(); | ||||
timing[i].fStatus = NotTriggered; | |||||
timing[i].fStatus = NotTriggered; | |||||
} | } | ||||
} | } | ||||
@@ -256,8 +256,8 @@ int JackConnectionManager::SuspendRefNum(JackClientControl* control, JackSynchro | |||||
{ | { | ||||
bool res; | bool res; | ||||
if ((res = table[control->fRefNum]->TimedWait(time_out_usec))) { | if ((res = table[control->fRefNum]->TimedWait(time_out_usec))) { | ||||
timing[control->fRefNum].fStatus = Running; | |||||
timing[control->fRefNum].fAwakeAt = GetMicroSeconds(); | |||||
timing[control->fRefNum].fStatus = Running; | |||||
timing[control->fRefNum].fAwakeAt = GetMicroSeconds(); | |||||
} | } | ||||
return (res) ? 0 : -1; | return (res) ? 0 : -1; | ||||
} | } | ||||
@@ -267,22 +267,22 @@ int JackConnectionManager::SuspendRefNum(JackClientControl* control, JackSynchro | |||||
*/ | */ | ||||
int JackConnectionManager::ResumeRefNum(JackClientControl* control, JackSynchro** table, JackClientTiming* timing) | int JackConnectionManager::ResumeRefNum(JackClientControl* control, JackSynchro** table, JackClientTiming* timing) | ||||
{ | { | ||||
jack_time_t current_date = GetMicroSeconds(); | |||||
jack_time_t current_date = GetMicroSeconds(); | |||||
const jack_int_t* outputRef = fConnectionRef.GetItems(control->fRefNum); | const jack_int_t* outputRef = fConnectionRef.GetItems(control->fRefNum); | ||||
int res = 0; | |||||
int res = 0; | |||||
// Update state and timestamp of current client | // Update state and timestamp of current client | ||||
timing[control->fRefNum].fStatus = Finished; | |||||
timing[control->fRefNum].fFinishedAt = current_date; | |||||
timing[control->fRefNum].fStatus = Finished; | |||||
timing[control->fRefNum].fFinishedAt = current_date; | |||||
for (int i = 0; i < CLIENT_NUM; i++) { | for (int i = 0; i < CLIENT_NUM; i++) { | ||||
// Signal connected clients or drivers | // Signal connected clients or drivers | ||||
if (outputRef[i] > 0) { | if (outputRef[i] > 0) { | ||||
// Update state and timestamp of destination clients | |||||
timing[i].fStatus = Triggered; | |||||
timing[i].fSignaledAt = current_date; | |||||
// Update state and timestamp of destination clients | |||||
timing[i].fStatus = Triggered; | |||||
timing[i].fSignaledAt = current_date; | |||||
if (!fInputCounter[i].Signal(table[i], control)) { | if (!fInputCounter[i].Signal(table[i], control)) { | ||||
JackLog("JackConnectionManager::ResumeRefNum error: ref = %ld output = %ld \n", control->fRefNum, i); | JackLog("JackConnectionManager::ResumeRefNum error: ref = %ld output = %ld \n", control->fRefNum, i); | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2004-2008 Grame | |||||
Copyright (C) 2004-2008 Grame | |||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
it under the terms of the GNU General Public License as published by | it under the terms of the GNU General Public License as published by | ||||
@@ -59,7 +59,7 @@ class JackFixedArray | |||||
fCounter = 0; | fCounter = 0; | ||||
} | } | ||||
bool AddItem(jack_int_t index) | |||||
bool AddItem(jack_int_t index) | |||||
{ | { | ||||
for (int i = 0; i < SIZE; i++) { | for (int i = 0; i < SIZE; i++) { | ||||
if (fTable[i] == EMPTY) { | if (fTable[i] == EMPTY) { | ||||
@@ -92,7 +92,7 @@ class JackFixedArray | |||||
return false; | return false; | ||||
} | } | ||||
jack_int_t GetItem(jack_int_t index) const | |||||
jack_int_t GetItem(jack_int_t index) const | |||||
{ | { | ||||
return (index < SIZE) ? fTable[index] : EMPTY; | return (index < SIZE) ? fTable[index] : EMPTY; | ||||
} | } | ||||
@@ -145,7 +145,7 @@ class JackFixedArray1 : public JackFixedArray<SIZE> | |||||
fUsed = false; | fUsed = false; | ||||
} | } | ||||
bool IsAvailable() | |||||
bool IsAvailable() | |||||
{ | { | ||||
if (fUsed) { | if (fUsed) { | ||||
return false; | return false; | ||||
@@ -358,25 +358,25 @@ struct JackClientTiming | |||||
jack_time_t fSignaledAt; | jack_time_t fSignaledAt; | ||||
jack_time_t fAwakeAt; | jack_time_t fAwakeAt; | ||||
jack_time_t fFinishedAt; | jack_time_t fFinishedAt; | ||||
jack_client_state_t fStatus; | |||||
JackClientTiming():fSignaledAt(0), fAwakeAt(0), fFinishedAt(0), fStatus(NotTriggered) | |||||
jack_client_state_t fStatus; | |||||
JackClientTiming(): fSignaledAt(0), fAwakeAt(0), fFinishedAt(0), fStatus(NotTriggered) | |||||
{} | {} | ||||
~JackClientTiming() | |||||
~JackClientTiming() | |||||
{} | {} | ||||
}; | }; | ||||
/*! | /*! | ||||
\brief Connection manager. | \brief Connection manager. | ||||
<UL> | <UL> | ||||
<LI>The <B>fConnection</B> array contains the list (array line) of connected ports for a given port. | <LI>The <B>fConnection</B> array contains the list (array line) of connected ports for a given port. | ||||
<LI>The <B>fConnectionCount</B> array contains the number of connected ports to a given port. | <LI>The <B>fConnectionCount</B> array contains the number of connected ports to a given port. | ||||
<LI>The <B>fInputPort</B> array contains the list (array line) of input connected ports for a given client. | <LI>The <B>fInputPort</B> array contains the list (array line) of input connected ports for a given client. | ||||
<LI>The <B>fOutputPort</B> array contains the list (array line) of ouput connected ports for a given client. | <LI>The <B>fOutputPort</B> array contains the list (array line) of ouput connected ports for a given client. | ||||
<LI>The <B>fConnectionRef</B> array contains the number of ports connected between two clients. | |||||
<LI>The <B>fInputRef</B> array contains the number of input clients connected to a given client. | |||||
<LI>The <B>fInputCounter</B> array contains the number of input clients connected to a given for activation purpose. | |||||
<LI>The <B>fConnectionRef</B> array contains the number of ports connected between two clients. | |||||
<LI>The <B>fInputRef</B> array contains the number of input clients connected to a given client. | |||||
<LI>The <B>fInputCounter</B> array contains the number of input clients connected to a given for activation purpose. | |||||
</UL> | </UL> | ||||
*/ | */ | ||||
@@ -393,7 +393,7 @@ class JackConnectionManager | |||||
JackLoopFeedback<CONNECTION_NUM> fLoopFeedback; /*! Loop feedback connections */ | JackLoopFeedback<CONNECTION_NUM> fLoopFeedback; /*! Loop feedback connections */ | ||||
bool IsLoopPathAux(int ref1, int ref2) const; | bool IsLoopPathAux(int ref1, int ref2) const; | ||||
public: | public: | ||||
JackConnectionManager(); | JackConnectionManager(); | ||||
@@ -427,8 +427,8 @@ class JackConnectionManager | |||||
const jack_int_t* GetOutputPorts(int refnum); | const jack_int_t* GetOutputPorts(int refnum); | ||||
// Client management | // Client management | ||||
void InitRefNum(int refnum); | |||||
int GetInputRefNum(jack_port_id_t port_index) const; | |||||
void InitRefNum(int refnum); | |||||
int GetInputRefNum(jack_port_id_t port_index) const; | |||||
int GetOutputRefNum(jack_port_id_t port_index) const; | int GetOutputRefNum(jack_port_id_t port_index) const; | ||||
// Connect/Disconnect 2 refnum "directly" | // Connect/Disconnect 2 refnum "directly" | ||||
@@ -52,17 +52,17 @@ namespace Jack | |||||
#define SOCKET_TIME_OUT 5 | #define SOCKET_TIME_OUT 5 | ||||
#ifdef WIN32 | #ifdef WIN32 | ||||
#define jack_server_dir "server" | |||||
#define jack_client_dir "client" | |||||
#define ADDON_DIR "jackmp" | |||||
#define jack_server_dir "server" | |||||
#define jack_client_dir "client" | |||||
#define ADDON_DIR "jackmp" | |||||
#elif __APPLE__ | #elif __APPLE__ | ||||
#define jack_server_dir "/tmp" | |||||
#define jack_client_dir "/tmp" | |||||
#define JACK_DEFAULT_DRIVER "coreaudio" | |||||
#define jack_server_dir "/tmp" | |||||
#define jack_client_dir "/tmp" | |||||
#define JACK_DEFAULT_DRIVER "coreaudio" | |||||
#else | #else | ||||
#define jack_server_dir "/dev/shm" | |||||
#define jack_client_dir "/dev/shm" | |||||
#define JACK_DEFAULT_DRIVER "alsa" | |||||
#define jack_server_dir "/dev/shm" | |||||
#define jack_client_dir "/dev/shm" | |||||
#define JACK_DEFAULT_DRIVER "alsa" | |||||
#endif | #endif | ||||
#define jack_server_entry "jackdmp_entry" | #define jack_server_entry "jackdmp_entry" | ||||
@@ -71,9 +71,9 @@ namespace Jack | |||||
#define ALL_CLIENTS -1 // for notification | #define ALL_CLIENTS -1 // for notification | ||||
#if defined(__ppc64__) || defined(__x86_64__) | #if defined(__ppc64__) || defined(__x86_64__) | ||||
#define JACK_PROTOCOL_VERSION 4 | |||||
#define JACK_PROTOCOL_VERSION 4 | |||||
#else | #else | ||||
#define JACK_PROTOCOL_VERSION 3 | |||||
#define JACK_PROTOCOL_VERSION 3 | |||||
#endif | #endif | ||||
#define DRIVER_OPEN_TIMEOUT 5 // in sec | #define DRIVER_OPEN_TIMEOUT 5 // in sec | ||||
@@ -113,25 +113,25 @@ int JackDebugClient::Close() | |||||
void JackDebugClient::CheckClient() const | void JackDebugClient::CheckClient() const | ||||
{ | { | ||||
if (fIsClosed > 0) { | if (fIsClosed > 0) { | ||||
*fStream << "!!! ERROR !!! : Accessing a client '" << fClientName << "' already closed !" << endl; | |||||
*fStream << "This is likely to cause crash !'" << endl; | |||||
} | |||||
*fStream << "!!! ERROR !!! : Accessing a client '" << fClientName << "' already closed !" << endl; | |||||
*fStream << "This is likely to cause crash !'" << endl; | |||||
} | |||||
} | } | ||||
pthread_t JackDebugClient::GetThreadID() | pthread_t JackDebugClient::GetThreadID() | ||||
{ | { | ||||
CheckClient(); | |||||
CheckClient(); | |||||
return fClient->GetThreadID(); | return fClient->GetThreadID(); | ||||
} | } | ||||
JackGraphManager* JackDebugClient::GetGraphManager() const | JackGraphManager* JackDebugClient::GetGraphManager() const | ||||
{ | { | ||||
CheckClient(); | |||||
CheckClient(); | |||||
return fClient->GetGraphManager(); | return fClient->GetGraphManager(); | ||||
} | } | ||||
JackEngineControl* JackDebugClient::GetEngineControl() const | JackEngineControl* JackDebugClient::GetEngineControl() const | ||||
{ | { | ||||
CheckClient(); | |||||
CheckClient(); | |||||
return fClient->GetEngineControl(); | return fClient->GetEngineControl(); | ||||
} | } | ||||
/*! | /*! | ||||
@@ -140,13 +140,13 @@ JackEngineControl* JackDebugClient::GetEngineControl() const | |||||
int JackDebugClient::ClientNotify(int refnum, const char* name, int notify, int sync, int value1, int value2) | int JackDebugClient::ClientNotify(int refnum, const char* name, int notify, int sync, int value1, int value2) | ||||
{ | { | ||||
CheckClient(); | |||||
CheckClient(); | |||||
return fClient->ClientNotify( refnum, name, notify, sync, value1, value2); | return fClient->ClientNotify( refnum, name, notify, sync, value1, value2); | ||||
} | } | ||||
int JackDebugClient::Activate() | int JackDebugClient::Activate() | ||||
{ | { | ||||
CheckClient(); | |||||
CheckClient(); | |||||
int res = fClient->Activate(); | int res = fClient->Activate(); | ||||
fIsActivated++; | fIsActivated++; | ||||
if (fIsDeactivated) | if (fIsDeactivated) | ||||
@@ -159,7 +159,7 @@ int JackDebugClient::Activate() | |||||
int JackDebugClient::Deactivate() | int JackDebugClient::Deactivate() | ||||
{ | { | ||||
CheckClient(); | |||||
CheckClient(); | |||||
int res = fClient->Deactivate(); | int res = fClient->Deactivate(); | ||||
fIsDeactivated++; | fIsDeactivated++; | ||||
if (fIsActivated == 0) | if (fIsActivated == 0) | ||||
@@ -176,7 +176,7 @@ int JackDebugClient::Deactivate() | |||||
int JackDebugClient::PortRegister(const char* port_name, const char* port_type, unsigned long flags, unsigned long buffer_size) | int JackDebugClient::PortRegister(const char* port_name, const char* port_type, unsigned long flags, unsigned long buffer_size) | ||||
{ | { | ||||
CheckClient(); | |||||
CheckClient(); | |||||
int res = fClient->PortRegister(port_name, port_type, flags, buffer_size); | int res = fClient->PortRegister(port_name, port_type, flags, buffer_size); | ||||
if (res <= 0) { | if (res <= 0) { | ||||
*fStream << "Client '" << fClientName << "' try port register ('" << port_name << "') and server return error " << res << " ." << endl; | *fStream << "Client '" << fClientName << "' try port register ('" << port_name << "') and server return error " << res << " ." << endl; | ||||
@@ -198,7 +198,7 @@ int JackDebugClient::PortRegister(const char* port_name, const char* port_type, | |||||
int JackDebugClient::PortUnRegister(jack_port_id_t port_index) | int JackDebugClient::PortUnRegister(jack_port_id_t port_index) | ||||
{ | { | ||||
CheckClient(); | |||||
CheckClient(); | |||||
int res = fClient->PortUnRegister(port_index); | int res = fClient->PortUnRegister(port_index); | ||||
fOpenPortNumber--; | fOpenPortNumber--; | ||||
int i; | int i; | ||||
@@ -220,7 +220,7 @@ int JackDebugClient::PortUnRegister(jack_port_id_t port_index) | |||||
int JackDebugClient::PortConnect(const char* src, const char* dst) | int JackDebugClient::PortConnect(const char* src, const char* dst) | ||||
{ | { | ||||
CheckClient(); | |||||
CheckClient(); | |||||
if (!fIsActivated) | if (!fIsActivated) | ||||
*fStream << "!!! ERROR !!! Trying to connect a port ( " << src << " to " << dst << ") while the client has not been activated !" << endl; | *fStream << "!!! ERROR !!! Trying to connect a port ( " << src << " to " << dst << ") while the client has not been activated !" << endl; | ||||
int i; | int i; | ||||
@@ -250,7 +250,7 @@ int JackDebugClient::PortConnect(const char* src, const char* dst) | |||||
int JackDebugClient::PortDisconnect(const char* src, const char* dst) | int JackDebugClient::PortDisconnect(const char* src, const char* dst) | ||||
{ | { | ||||
CheckClient(); | |||||
CheckClient(); | |||||
if (!fIsActivated) | if (!fIsActivated) | ||||
*fStream << "!!! ERROR !!! Trying to disconnect a port ( " << src << " to " << dst << ") while the client has not been activated !" << endl; | *fStream << "!!! ERROR !!! Trying to disconnect a port ( " << src << " to " << dst << ") while the client has not been activated !" << endl; | ||||
int res = fClient->PortDisconnect( src, dst); | int res = fClient->PortDisconnect( src, dst); | ||||
@@ -279,8 +279,8 @@ int JackDebugClient::PortDisconnect(const char* src, const char* dst) | |||||
} | } | ||||
int JackDebugClient::PortConnect(jack_port_id_t src, jack_port_id_t dst) | int JackDebugClient::PortConnect(jack_port_id_t src, jack_port_id_t dst) | ||||
{ | |||||
CheckClient(); | |||||
{ | |||||
CheckClient(); | |||||
if (!fIsActivated) | if (!fIsActivated) | ||||
*fStream << "!!! ERROR !!! : Trying to connect port " << src << " to " << dst << " while the client has not been activated !" << endl; | *fStream << "!!! ERROR !!! : Trying to connect port " << src << " to " << dst << " while the client has not been activated !" << endl; | ||||
int res = fClient->PortConnect(src, dst); | int res = fClient->PortConnect(src, dst); | ||||
@@ -310,7 +310,7 @@ int JackDebugClient::PortConnect(jack_port_id_t src, jack_port_id_t dst) | |||||
int JackDebugClient::PortDisconnect(jack_port_id_t src) | int JackDebugClient::PortDisconnect(jack_port_id_t src) | ||||
{ | { | ||||
CheckClient(); | |||||
CheckClient(); | |||||
if (!fIsActivated) | if (!fIsActivated) | ||||
*fStream << "!!! ERROR !!! : Trying to disconnect port " << src << " while that client has not been activated !" << endl; | *fStream << "!!! ERROR !!! : Trying to disconnect port " << src << " while that client has not been activated !" << endl; | ||||
int res = fClient->PortDisconnect(src); | int res = fClient->PortDisconnect(src); | ||||
@@ -334,7 +334,7 @@ int JackDebugClient::PortDisconnect(jack_port_id_t src) | |||||
int JackDebugClient::PortIsMine(jack_port_id_t port_index) | int JackDebugClient::PortIsMine(jack_port_id_t port_index) | ||||
{ | { | ||||
CheckClient(); | |||||
CheckClient(); | |||||
return fClient->PortIsMine(port_index); | return fClient->PortIsMine(port_index); | ||||
} | } | ||||
@@ -344,13 +344,13 @@ int JackDebugClient::PortIsMine(jack_port_id_t port_index) | |||||
int JackDebugClient::SetBufferSize(jack_nframes_t buffer_size) | int JackDebugClient::SetBufferSize(jack_nframes_t buffer_size) | ||||
{ | { | ||||
CheckClient(); | |||||
CheckClient(); | |||||
return fClient->SetBufferSize(buffer_size); | return fClient->SetBufferSize(buffer_size); | ||||
} | } | ||||
int JackDebugClient::SetFreeWheel(int onoff) | int JackDebugClient::SetFreeWheel(int onoff) | ||||
{ | { | ||||
CheckClient(); | |||||
CheckClient(); | |||||
return fClient->SetFreeWheel(onoff); | return fClient->SetFreeWheel(onoff); | ||||
} | } | ||||
@@ -372,61 +372,61 @@ void JackDebugClient::ShutDown() | |||||
int JackDebugClient::ReleaseTimebase() | int JackDebugClient::ReleaseTimebase() | ||||
{ | { | ||||
CheckClient(); | |||||
CheckClient(); | |||||
return fClient->ReleaseTimebase(); | return fClient->ReleaseTimebase(); | ||||
} | } | ||||
int JackDebugClient::SetSyncCallback(JackSyncCallback sync_callback, void* arg) | int JackDebugClient::SetSyncCallback(JackSyncCallback sync_callback, void* arg) | ||||
{ | { | ||||
CheckClient(); | |||||
CheckClient(); | |||||
return fClient->SetSyncCallback(sync_callback, arg); | return fClient->SetSyncCallback(sync_callback, arg); | ||||
} | } | ||||
int JackDebugClient::SetSyncTimeout(jack_time_t timeout) | int JackDebugClient::SetSyncTimeout(jack_time_t timeout) | ||||
{ | { | ||||
CheckClient(); | |||||
CheckClient(); | |||||
return fClient->SetSyncTimeout(timeout); | return fClient->SetSyncTimeout(timeout); | ||||
} | } | ||||
int JackDebugClient::SetTimebaseCallback(int conditional, JackTimebaseCallback timebase_callback, void* arg) | int JackDebugClient::SetTimebaseCallback(int conditional, JackTimebaseCallback timebase_callback, void* arg) | ||||
{ | { | ||||
CheckClient(); | |||||
CheckClient(); | |||||
return fClient->SetTimebaseCallback( conditional, timebase_callback, arg); | return fClient->SetTimebaseCallback( conditional, timebase_callback, arg); | ||||
} | } | ||||
int JackDebugClient::TransportLocate(jack_nframes_t frame) | int JackDebugClient::TransportLocate(jack_nframes_t frame) | ||||
{ | { | ||||
CheckClient(); | |||||
CheckClient(); | |||||
return fClient->TransportLocate(frame); | return fClient->TransportLocate(frame); | ||||
} | } | ||||
jack_transport_state_t JackDebugClient::TransportQuery(jack_position_t* pos) | jack_transport_state_t JackDebugClient::TransportQuery(jack_position_t* pos) | ||||
{ | { | ||||
CheckClient(); | |||||
CheckClient(); | |||||
return fClient->TransportQuery(pos); | return fClient->TransportQuery(pos); | ||||
} | } | ||||
jack_nframes_t JackDebugClient::GetCurrentTransportFrame() | jack_nframes_t JackDebugClient::GetCurrentTransportFrame() | ||||
{ | { | ||||
CheckClient(); | |||||
CheckClient(); | |||||
return fClient->GetCurrentTransportFrame(); | return fClient->GetCurrentTransportFrame(); | ||||
} | } | ||||
int JackDebugClient::TransportReposition(jack_position_t* pos) | int JackDebugClient::TransportReposition(jack_position_t* pos) | ||||
{ | { | ||||
CheckClient(); | |||||
CheckClient(); | |||||
return fClient->TransportReposition(pos); | return fClient->TransportReposition(pos); | ||||
} | } | ||||
void JackDebugClient::TransportStart() | void JackDebugClient::TransportStart() | ||||
{ | { | ||||
CheckClient(); | |||||
CheckClient(); | |||||
fClient->TransportStart(); | fClient->TransportStart(); | ||||
} | } | ||||
void JackDebugClient::TransportStop() | void JackDebugClient::TransportStop() | ||||
{ | { | ||||
CheckClient(); | |||||
CheckClient(); | |||||
fClient->TransportStop(); | fClient->TransportStop(); | ||||
} | } | ||||
@@ -436,112 +436,112 @@ void JackDebugClient::TransportStop() | |||||
void JackDebugClient::OnShutdown(JackShutdownCallback callback, void *arg) | void JackDebugClient::OnShutdown(JackShutdownCallback callback, void *arg) | ||||
{ | { | ||||
CheckClient(); | |||||
CheckClient(); | |||||
fClient->OnShutdown(callback, arg); | fClient->OnShutdown(callback, arg); | ||||
} | } | ||||
int JackDebugClient::TimeCallback(jack_nframes_t nframes, void *arg) | int JackDebugClient::TimeCallback(jack_nframes_t nframes, void *arg) | ||||
{ | { | ||||
JackDebugClient* client = (JackDebugClient*)arg; | |||||
jack_time_t t1 = GetMicroSeconds(); | |||||
int res = client->fProcessTimeCallback(nframes, client->fProcessTimeCallbackArg); | |||||
jack_time_t t2 = GetMicroSeconds(); | |||||
long delta = long((t2 - t1) - client->GetEngineControl()->fPeriodUsecs); | |||||
if (delta > 0) | |||||
*client->fStream << "!!! ERROR !!! : Process overload of " << delta << " us" << endl; | |||||
return res; | |||||
JackDebugClient* client = (JackDebugClient*)arg; | |||||
jack_time_t t1 = GetMicroSeconds(); | |||||
int res = client->fProcessTimeCallback(nframes, client->fProcessTimeCallbackArg); | |||||
jack_time_t t2 = GetMicroSeconds(); | |||||
long delta = long((t2 - t1) - client->GetEngineControl()->fPeriodUsecs); | |||||
if (delta > 0) | |||||
*client->fStream << "!!! ERROR !!! : Process overload of " << delta << " us" << endl; | |||||
return res; | |||||
} | } | ||||
int JackDebugClient::SetProcessCallback(JackProcessCallback callback, void *arg) | int JackDebugClient::SetProcessCallback(JackProcessCallback callback, void *arg) | ||||
{ | { | ||||
CheckClient(); | |||||
fProcessTimeCallback = callback; | |||||
fProcessTimeCallbackArg = arg; | |||||
return fClient->SetProcessCallback(TimeCallback, this); | |||||
CheckClient(); | |||||
fProcessTimeCallback = callback; | |||||
fProcessTimeCallbackArg = arg; | |||||
return fClient->SetProcessCallback(TimeCallback, this); | |||||
} | } | ||||
int JackDebugClient::SetXRunCallback(JackXRunCallback callback, void *arg) | int JackDebugClient::SetXRunCallback(JackXRunCallback callback, void *arg) | ||||
{ | { | ||||
CheckClient(); | |||||
CheckClient(); | |||||
return fClient->SetXRunCallback(callback, arg); | return fClient->SetXRunCallback(callback, arg); | ||||
} | } | ||||
int JackDebugClient::SetInitCallback(JackThreadInitCallback callback, void *arg) | int JackDebugClient::SetInitCallback(JackThreadInitCallback callback, void *arg) | ||||
{ | { | ||||
CheckClient(); | |||||
CheckClient(); | |||||
return fClient->SetInitCallback(callback, arg); | return fClient->SetInitCallback(callback, arg); | ||||
} | } | ||||
int JackDebugClient::SetGraphOrderCallback(JackGraphOrderCallback callback, void *arg) | int JackDebugClient::SetGraphOrderCallback(JackGraphOrderCallback callback, void *arg) | ||||
{ | { | ||||
CheckClient(); | |||||
CheckClient(); | |||||
return fClient->SetGraphOrderCallback(callback, arg); | return fClient->SetGraphOrderCallback(callback, arg); | ||||
} | } | ||||
int JackDebugClient::SetBufferSizeCallback(JackBufferSizeCallback callback, void *arg) | int JackDebugClient::SetBufferSizeCallback(JackBufferSizeCallback callback, void *arg) | ||||
{ | { | ||||
CheckClient(); | |||||
CheckClient(); | |||||
return fClient->SetBufferSizeCallback(callback, arg); | return fClient->SetBufferSizeCallback(callback, arg); | ||||
} | } | ||||
int JackDebugClient::SetClientRegistrationCallback(JackClientRegistrationCallback callback, void* arg) | int JackDebugClient::SetClientRegistrationCallback(JackClientRegistrationCallback callback, void* arg) | ||||
{ | { | ||||
CheckClient(); | |||||
CheckClient(); | |||||
return fClient->SetClientRegistrationCallback(callback, arg); | return fClient->SetClientRegistrationCallback(callback, arg); | ||||
} | } | ||||
int JackDebugClient::SetFreewheelCallback(JackFreewheelCallback callback, void *arg) | int JackDebugClient::SetFreewheelCallback(JackFreewheelCallback callback, void *arg) | ||||
{ | { | ||||
CheckClient(); | |||||
CheckClient(); | |||||
return fClient->SetFreewheelCallback(callback, arg); | return fClient->SetFreewheelCallback(callback, arg); | ||||
} | } | ||||
int JackDebugClient::SetPortRegistrationCallback(JackPortRegistrationCallback callback, void *arg) | int JackDebugClient::SetPortRegistrationCallback(JackPortRegistrationCallback callback, void *arg) | ||||
{ | { | ||||
CheckClient(); | |||||
CheckClient(); | |||||
return fClient->SetPortRegistrationCallback(callback, arg); | return fClient->SetPortRegistrationCallback(callback, arg); | ||||
} | } | ||||
int JackDebugClient::SetPortConnectCallback(JackPortConnectCallback callback, void *arg) | int JackDebugClient::SetPortConnectCallback(JackPortConnectCallback callback, void *arg) | ||||
{ | { | ||||
CheckClient(); | |||||
CheckClient(); | |||||
return fClient->SetPortConnectCallback(callback, arg); | return fClient->SetPortConnectCallback(callback, arg); | ||||
} | } | ||||
JackClientControl* JackDebugClient::GetClientControl() const | JackClientControl* JackDebugClient::GetClientControl() const | ||||
{ | { | ||||
CheckClient(); | |||||
CheckClient(); | |||||
return fClient->GetClientControl(); | return fClient->GetClientControl(); | ||||
} | } | ||||
// Internal clients | // Internal clients | ||||
char* JackDebugClient::GetInternalClientName(int ref) | char* JackDebugClient::GetInternalClientName(int ref) | ||||
{ | { | ||||
CheckClient(); | |||||
CheckClient(); | |||||
return fClient->GetInternalClientName(ref); | return fClient->GetInternalClientName(ref); | ||||
} | } | ||||
int JackDebugClient::InternalClientHandle(const char* client_name, jack_status_t* status) | int JackDebugClient::InternalClientHandle(const char* client_name, jack_status_t* status) | ||||
{ | { | ||||
CheckClient(); | |||||
CheckClient(); | |||||
return fClient->InternalClientHandle(client_name, status); | return fClient->InternalClientHandle(client_name, status); | ||||
} | } | ||||
int JackDebugClient::InternalClientLoad(const char* client_name, jack_options_t options, jack_status_t* status, jack_varargs_t* va) | int JackDebugClient::InternalClientLoad(const char* client_name, jack_options_t options, jack_status_t* status, jack_varargs_t* va) | ||||
{ | { | ||||
CheckClient(); | |||||
CheckClient(); | |||||
return fClient->InternalClientLoad(client_name, options, status, va); | return fClient->InternalClientLoad(client_name, options, status, va); | ||||
} | } | ||||
void JackDebugClient::InternalClientUnload(int ref, jack_status_t* status) | void JackDebugClient::InternalClientUnload(int ref, jack_status_t* status) | ||||
{ | { | ||||
CheckClient(); | |||||
CheckClient(); | |||||
fClient->InternalClientUnload(ref, status); | fClient->InternalClientUnload(ref, status); | ||||
} | } | ||||
jack_nframes_t JackDebugClient::Wait(int status) | jack_nframes_t JackDebugClient::Wait(int status) | ||||
{ | { | ||||
CheckClient(); | |||||
CheckClient(); | |||||
return fClient->Wait(status); | return fClient->Wait(status); | ||||
} | } | ||||
@@ -45,22 +45,22 @@ PortFollower; | |||||
/*! | /*! | ||||
\brief A "decorator" debug client to validate API use. | \brief A "decorator" debug client to validate API use. | ||||
*/ | */ | ||||
class JackDebugClient : public JackClient | class JackDebugClient : public JackClient | ||||
{ | { | ||||
protected: | protected: | ||||
JackClient* fClient; | |||||
JackClient* fClient; | |||||
std::ofstream* fStream; | std::ofstream* fStream; | ||||
PortFollower fPortList[MAX_PORT_HISTORY]; // Arbitrary value... To be tuned... | |||||
PortFollower fPortList[MAX_PORT_HISTORY]; // Arbitrary value... To be tuned... | |||||
int fTotalPortNumber; // The total number of port opened and maybe closed. Historical view. | int fTotalPortNumber; // The total number of port opened and maybe closed. Historical view. | ||||
int fOpenPortNumber; // The current number of opened port. | int fOpenPortNumber; // The current number of opened port. | ||||
int fIsActivated; | int fIsActivated; | ||||
int fIsDeactivated; | int fIsDeactivated; | ||||
int fIsClosed; | int fIsClosed; | ||||
char fClientName[JACK_CLIENT_NAME_SIZE]; | char fClientName[JACK_CLIENT_NAME_SIZE]; | ||||
JackProcessCallback fProcessTimeCallback; | |||||
void* fProcessTimeCallbackArg; | |||||
JackProcessCallback fProcessTimeCallback; | |||||
void* fProcessTimeCallbackArg; | |||||
public: | public: | ||||
@@ -115,24 +115,24 @@ class JackDebugClient : public JackClient | |||||
int SetInitCallback(JackThreadInitCallback callback, void* arg); | int SetInitCallback(JackThreadInitCallback callback, void* arg); | ||||
int SetGraphOrderCallback(JackGraphOrderCallback callback, void* arg); | int SetGraphOrderCallback(JackGraphOrderCallback callback, void* arg); | ||||
int SetBufferSizeCallback(JackBufferSizeCallback callback, void* arg); | int SetBufferSizeCallback(JackBufferSizeCallback callback, void* arg); | ||||
int SetClientRegistrationCallback(JackClientRegistrationCallback callback, void* arg); | |||||
int SetClientRegistrationCallback(JackClientRegistrationCallback callback, void* arg); | |||||
int SetFreewheelCallback(JackFreewheelCallback callback, void* arg); | int SetFreewheelCallback(JackFreewheelCallback callback, void* arg); | ||||
int SetPortRegistrationCallback(JackPortRegistrationCallback callback, void* arg); | int SetPortRegistrationCallback(JackPortRegistrationCallback callback, void* arg); | ||||
int SetPortConnectCallback(JackPortConnectCallback callback, void *arg); | |||||
// Internal clients | |||||
char* GetInternalClientName(int ref); | |||||
int InternalClientHandle(const char* client_name, jack_status_t* status); | |||||
int InternalClientLoad(const char* client_name, jack_options_t options, jack_status_t* status, jack_varargs_t* va); | |||||
void InternalClientUnload(int ref, jack_status_t* status); | |||||
// Fons Adriaensen thread model | |||||
jack_nframes_t Wait(int status); | |||||
int SetPortConnectCallback(JackPortConnectCallback callback, void *arg); | |||||
// Internal clients | |||||
char* GetInternalClientName(int ref); | |||||
int InternalClientHandle(const char* client_name, jack_status_t* status); | |||||
int InternalClientLoad(const char* client_name, jack_options_t options, jack_status_t* status, jack_varargs_t* va); | |||||
void InternalClientUnload(int ref, jack_status_t* status); | |||||
// Fons Adriaensen thread model | |||||
jack_nframes_t Wait(int status); | |||||
JackClientControl* GetClientControl() const; | JackClientControl* GetClientControl() const; | ||||
void CheckClient() const; | |||||
static int TimeCallback(jack_nframes_t nframes, void *arg); | |||||
void CheckClient() const; | |||||
static int TimeCallback(jack_nframes_t nframes, void *arg); | |||||
}; | }; | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2004-2008 Grame | Copyright (C) 2004-2008 Grame | ||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
@@ -18,7 +18,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||||
*/ | */ | ||||
#ifdef WIN32 | |||||
#ifdef WIN32 | |||||
#pragma warning (disable : 4786) | #pragma warning (disable : 4786) | ||||
#endif | #endif | ||||
@@ -70,15 +70,15 @@ int JackDriver::Open() | |||||
{ | { | ||||
int refnum = -1; | int refnum = -1; | ||||
if (fEngine->ClientInternalOpen(fClientControl->fName, &refnum, &fEngineControl, &fGraphManager, this, false) != 0) { | |||||
if (fEngine->ClientInternalOpen(fClientControl->fName, &refnum, &fEngineControl, &fGraphManager, this, false) != 0) { | |||||
jack_error("Cannot allocate internal client for audio driver"); | jack_error("Cannot allocate internal client for audio driver"); | ||||
return -1; | return -1; | ||||
} | } | ||||
fClientControl->fRefNum = refnum; | fClientControl->fRefNum = refnum; | ||||
fClientControl->fActive = true; | |||||
fGraphManager->DirectConnect(fClientControl->fRefNum, fClientControl->fRefNum); // Connect driver to itself for "sync" mode | |||||
SetupDriverSync(fClientControl->fRefNum, false); | |||||
fClientControl->fActive = true; | |||||
fGraphManager->DirectConnect(fClientControl->fRefNum, fClientControl->fRefNum); // Connect driver to itself for "sync" mode | |||||
SetupDriverSync(fClientControl->fRefNum, false); | |||||
return 0; | return 0; | ||||
} | } | ||||
@@ -104,7 +104,7 @@ int JackDriver::Open(jack_nframes_t nframes, | |||||
} | } | ||||
fClientControl->fRefNum = refnum; | fClientControl->fRefNum = refnum; | ||||
fClientControl->fActive = true; | |||||
fClientControl->fActive = true; | |||||
fEngineControl->fBufferSize = nframes; | fEngineControl->fBufferSize = nframes; | ||||
fEngineControl->fSampleRate = samplerate; | fEngineControl->fSampleRate = samplerate; | ||||
fCaptureLatency = capture_latency; | fCaptureLatency = capture_latency; | ||||
@@ -122,7 +122,7 @@ int JackDriver::Open(jack_nframes_t nframes, | |||||
fGraphManager->SetBufferSize(nframes); | fGraphManager->SetBufferSize(nframes); | ||||
fGraphManager->DirectConnect(fClientControl->fRefNum, fClientControl->fRefNum); // Connect driver to itself for "sync" mode | fGraphManager->DirectConnect(fClientControl->fRefNum, fClientControl->fRefNum); // Connect driver to itself for "sync" mode | ||||
SetupDriverSync(fClientControl->fRefNum, false); | |||||
SetupDriverSync(fClientControl->fRefNum, false); | |||||
return 0; | return 0; | ||||
} | } | ||||
@@ -141,31 +141,31 @@ int JackDriver::Close() | |||||
*/ | */ | ||||
void JackDriver::SetupDriverSync(int ref, bool freewheel) | void JackDriver::SetupDriverSync(int ref, bool freewheel) | ||||
{ | { | ||||
if (!freewheel && !fEngineControl->fSyncMode) { | |||||
if (!freewheel && !fEngineControl->fSyncMode) { | |||||
JackLog("JackDriver::SetupDriverSync driver sem in flush mode\n"); | JackLog("JackDriver::SetupDriverSync driver sem in flush mode\n"); | ||||
fSynchroTable[ref]->SetFlush(true); | fSynchroTable[ref]->SetFlush(true); | ||||
} else { | } else { | ||||
JackLog("JackDriver::SetupDriverSync driver sem in normal mode\n"); | JackLog("JackDriver::SetupDriverSync driver sem in normal mode\n"); | ||||
fSynchroTable[ref]->SetFlush(false); | fSynchroTable[ref]->SetFlush(false); | ||||
} | |||||
} | |||||
} | } | ||||
int JackDriver::ClientNotify(int refnum, const char* name, int notify, int sync, int value1, int value2) | int JackDriver::ClientNotify(int refnum, const char* name, int notify, int sync, int value1, int value2) | ||||
{ | { | ||||
switch (notify) { | |||||
case kStartFreewheelCallback: | |||||
JackLog("JackDriver::kStartFreewheel\n"); | |||||
SetupDriverSync(fClientControl->fRefNum, true); | |||||
break; | |||||
case kStopFreewheelCallback: | |||||
JackLog("JackDriver::kStopFreewheel\n"); | |||||
SetupDriverSync(fClientControl->fRefNum, false); | |||||
break; | |||||
} | |||||
switch (notify) { | |||||
case kStartFreewheelCallback: | |||||
JackLog("JackDriver::kStartFreewheel\n"); | |||||
SetupDriverSync(fClientControl->fRefNum, true); | |||||
break; | |||||
return 0; | |||||
case kStopFreewheelCallback: | |||||
JackLog("JackDriver::kStopFreewheel\n"); | |||||
SetupDriverSync(fClientControl->fRefNum, false); | |||||
break; | |||||
} | |||||
return 0; | |||||
} | } | ||||
bool JackDriver::IsRealTime() | bool JackDriver::IsRealTime() | ||||
@@ -205,14 +205,14 @@ void JackDriverClient::RemoveSlave(JackDriverInterface* slave) | |||||
int JackDriverClient::ProcessSlaves() | int JackDriverClient::ProcessSlaves() | ||||
{ | { | ||||
int res = 0; | |||||
int res = 0; | |||||
list<JackDriverInterface*>::const_iterator it; | list<JackDriverInterface*>::const_iterator it; | ||||
for (it = fSlaveList.begin(); it != fSlaveList.end(); it++) { | for (it = fSlaveList.begin(); it != fSlaveList.end(); it++) { | ||||
JackDriverInterface* slave = *it; | JackDriverInterface* slave = *it; | ||||
if (slave->Process() < 0) | if (slave->Process() < 0) | ||||
res = -1; | |||||
res = -1; | |||||
} | } | ||||
return res; | |||||
return res; | |||||
} | } | ||||
} // end of namespace | } // end of namespace |
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2004-2008 Grame | Copyright (C) 2004-2008 Grame | ||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
@@ -65,14 +65,14 @@ class EXPORT JackDriverInterface | |||||
virtual int Attach() = 0; | virtual int Attach() = 0; | ||||
virtual int Detach() = 0; | virtual int Detach() = 0; | ||||
virtual int Read() = 0; | virtual int Read() = 0; | ||||
virtual int Write() = 0; | virtual int Write() = 0; | ||||
virtual int Start() = 0; | virtual int Start() = 0; | ||||
virtual int Stop() = 0; | virtual int Stop() = 0; | ||||
virtual int SetBufferSize(jack_nframes_t buffer_size) = 0; | virtual int SetBufferSize(jack_nframes_t buffer_size) = 0; | ||||
virtual int SetSampleRate(jack_nframes_t sample_rate) = 0; | |||||
virtual int SetSampleRate(jack_nframes_t sample_rate) = 0; | |||||
virtual int Process() = 0; | virtual int Process() = 0; | ||||
@@ -90,7 +90,7 @@ class EXPORT JackDriverInterface | |||||
*/ | */ | ||||
class EXPORT JackDriverClientInterface : public JackDriverInterface, public JackClientInterface | class EXPORT JackDriverClientInterface : public JackDriverInterface, public JackClientInterface | ||||
{}; | |||||
{}; | |||||
/*! | /*! | ||||
\brief The base class for drivers clients. | \brief The base class for drivers clients. | ||||
@@ -195,9 +195,9 @@ class EXPORT JackDriver : public JackDriverClient | |||||
{ | { | ||||
return 0; | return 0; | ||||
} | } | ||||
virtual int SetSampleRate(jack_nframes_t sample_rate) | |||||
{ | |||||
virtual int SetSampleRate(jack_nframes_t sample_rate) | |||||
{ | |||||
return 0; | return 0; | ||||
} | } | ||||
@@ -206,8 +206,8 @@ class EXPORT JackDriver : public JackDriverClient | |||||
virtual bool IsRealTime(); | virtual bool IsRealTime(); | ||||
int ClientNotify(int refnum, const char* name, int notify, int sync, int value1, int value2); | int ClientNotify(int refnum, const char* name, int notify, int sync, int value1, int value2); | ||||
void SetupDriverSync(int ref, bool freewheel); | |||||
void SetupDriverSync(int ref, bool freewheel); | |||||
}; | }; | ||||
@@ -1,6 +1,6 @@ | |||||
/* | /* | ||||
Copyright (C) 2001-2005 Paul Davis | Copyright (C) 2001-2005 Paul Davis | ||||
Copyright (C) 2004-2008 Grame | |||||
Copyright (C) 2004-2008 Grame | |||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
it under the terms of the GNU General Public License as published by | it under the terms of the GNU General Public License as published by | ||||
@@ -18,11 +18,11 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||||
*/ | */ | ||||
#ifdef WIN32 | |||||
#ifdef WIN32 | |||||
#pragma warning (disable : 4786) | #pragma warning (disable : 4786) | ||||
#endif | #endif | ||||
#ifndef WIN32 | |||||
#ifndef WIN32 | |||||
#ifndef ADDON_DIR | #ifndef ADDON_DIR | ||||
#include "config.h" | #include "config.h" | ||||
#endif | #endif | ||||
@@ -32,7 +32,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||||
#include "JackError.h" | #include "JackError.h" | ||||
#include <getopt.h> | #include <getopt.h> | ||||
#ifndef WIN32 | |||||
#ifndef WIN32 | |||||
#include <dirent.h> | #include <dirent.h> | ||||
#endif | #endif | ||||
@@ -116,7 +116,7 @@ jack_parse_driver_params (jack_driver_desc_t * desc, int argc, char* argv[], JSL | |||||
printf ("Parameters for driver '%s' (all parameters are optional):\n", desc->name); | printf ("Parameters for driver '%s' (all parameters are optional):\n", desc->name); | ||||
jack_print_driver_options (desc, stdout); | jack_print_driver_options (desc, stdout); | ||||
return 1; | return 1; | ||||
} | |||||
} | |||||
/* set up the stuff for getopt */ | /* set up the stuff for getopt */ | ||||
options = (char*)calloc (desc->nparams * 3 + 1, sizeof (char)); | options = (char*)calloc (desc->nparams * 3 + 1, sizeof (char)); | ||||
@@ -186,7 +186,7 @@ jack_parse_driver_params (jack_driver_desc_t * desc, int argc, char* argv[], JSL | |||||
strcasecmp ("no", optarg) == 0 || | strcasecmp ("no", optarg) == 0 || | ||||
strcasecmp ("0", optarg) == 0 || | strcasecmp ("0", optarg) == 0 || | ||||
strcasecmp ("(null)", optarg) == 0 ) { | strcasecmp ("(null)", optarg) == 0 ) { | ||||
*/ | |||||
*/ | |||||
// steph | // steph | ||||
if (strcmp ("false", optarg) == 0 || | if (strcmp ("false", optarg) == 0 || | ||||
strcmp ("off", optarg) == 0 || | strcmp ("off", optarg) == 0 || | ||||
@@ -256,15 +256,15 @@ jack_drivers_get_descriptor (JSList * drivers, const char * sofile) | |||||
#endif | #endif | ||||
int err; | int err; | ||||
/* | |||||
char* driver_dir; | |||||
if ((driver_dir = getenv("JACK_DRIVER_DIR")) == 0) { | |||||
driver_dir = ADDON_DIR; | |||||
} | |||||
*/ | |||||
/* | |||||
char* driver_dir; | |||||
if ((driver_dir = getenv("JACK_DRIVER_DIR")) == 0) { | |||||
driver_dir = ADDON_DIR; | |||||
} | |||||
*/ | |||||
#ifdef WIN32 | #ifdef WIN32 | ||||
char* driver_dir = ADDON_DIR; | |||||
char* driver_dir = ADDON_DIR; | |||||
if (strcmp(ADDON_DIR, "") == 0) { | if (strcmp(ADDON_DIR, "") == 0) { | ||||
char temp_driver_dir1[512]; | char temp_driver_dir1[512]; | ||||
char temp_driver_dir2[512]; | char temp_driver_dir2[512]; | ||||
@@ -273,8 +273,8 @@ jack_drivers_get_descriptor (JSList * drivers, const char * sofile) | |||||
driver_dir = temp_driver_dir2; | driver_dir = temp_driver_dir2; | ||||
} | } | ||||
#else | #else | ||||
char driver_dir[512]; | |||||
snprintf(driver_dir, sizeof(driver_dir) - 1, "%s/%s/jackmp", ADDON_DIR, LIB_DIR); | |||||
char driver_dir[512]; | |||||
snprintf(driver_dir, sizeof(driver_dir) - 1, "%s/%s/jackmp", ADDON_DIR, LIB_DIR); | |||||
#endif | #endif | ||||
filename = (char *)malloc(strlen (driver_dir) + 1 + strlen(sofile) + 1); | filename = (char *)malloc(strlen (driver_dir) + 1 + strlen(sofile) + 1); | ||||
@@ -330,7 +330,7 @@ jack_drivers_get_descriptor (JSList * drivers, const char * sofile) | |||||
if (strcmp(descriptor->name, other_descriptor->name) == 0) { | if (strcmp(descriptor->name, other_descriptor->name) == 0) { | ||||
jack_error("the drivers in '%s' and '%s' both have the name '%s'; using the first\n", | jack_error("the drivers in '%s' and '%s' both have the name '%s'; using the first\n", | ||||
other_descriptor->file, filename, other_descriptor->name); | |||||
other_descriptor->file, filename, other_descriptor->name); | |||||
/* FIXME: delete the descriptor */ | /* FIXME: delete the descriptor */ | ||||
free(filename); | free(filename); | ||||
return NULL; | return NULL; | ||||
@@ -400,15 +400,15 @@ jack_drivers_load (JSList * drivers) { | |||||
JSList * driver_list = NULL; | JSList * driver_list = NULL; | ||||
jack_driver_desc_t * desc; | jack_driver_desc_t * desc; | ||||
/* | |||||
char* driver_dir; | |||||
/* | |||||
char* driver_dir; | |||||
if ((driver_dir = getenv("JACK_DRIVER_DIR")) == 0) { | if ((driver_dir = getenv("JACK_DRIVER_DIR")) == 0) { | ||||
driver_dir = ADDON_DIR; | |||||
} | |||||
*/ | |||||
char driver_dir[512]; | |||||
snprintf(driver_dir, sizeof(driver_dir) - 1, "%s/%s/jackmp", ADDON_DIR, LIB_DIR); | |||||
driver_dir = ADDON_DIR; | |||||
} | |||||
*/ | |||||
char driver_dir[512]; | |||||
snprintf(driver_dir, sizeof(driver_dir) - 1, "%s/%s/jackmp", ADDON_DIR, LIB_DIR); | |||||
/* search through the driver_dir and add get descriptors | /* search through the driver_dir and add get descriptors | ||||
from the .so files in it */ | from the .so files in it */ | ||||
dir_stream = opendir (driver_dir); | dir_stream = opendir (driver_dir); | ||||
@@ -1,6 +1,6 @@ | |||||
/* | /* | ||||
Copyright (C) 2001-2005 Paul Davis | Copyright (C) 2001-2005 Paul Davis | ||||
Copyright (C) 2004-2008 Grame | |||||
Copyright (C) 2004-2008 Grame | |||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
it under the terms of the GNU General Public License as published by | it under the terms of the GNU General Public License as published by | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2004-2008 Grame | Copyright (C) 2004-2008 Grame | ||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2004-2008 Grame | Copyright (C) 2004-2008 Grame | ||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2004-2008 Grame | |||||
Copyright (C) 2004-2008 Grame | |||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
it under the terms of the GNU General Public License as published by | it under the terms of the GNU General Public License as published by | ||||
@@ -38,15 +38,15 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||||
namespace Jack | namespace Jack | ||||
{ | { | ||||
JackEngine::JackEngine(JackGraphManager* manager, | |||||
JackSynchro** table, | |||||
JackEngineControl* control) | |||||
JackEngine::JackEngine(JackGraphManager* manager, | |||||
JackSynchro** table, | |||||
JackEngineControl* control) | |||||
{ | { | ||||
fGraphManager = manager; | fGraphManager = manager; | ||||
fSynchroTable = table; | fSynchroTable = table; | ||||
fEngineControl = control; | fEngineControl = control; | ||||
fChannel = JackGlobals::MakeServerNotifyChannel(); | |||||
fSignal = JackGlobals::MakeInterProcessSync(); | |||||
fChannel = JackGlobals::MakeServerNotifyChannel(); | |||||
fSignal = JackGlobals::MakeInterProcessSync(); | |||||
for (int i = 0; i < CLIENT_NUM; i++) | for (int i = 0; i < CLIENT_NUM; i++) | ||||
fClientTable[i] = NULL; | fClientTable[i] = NULL; | ||||
} | } | ||||
@@ -54,7 +54,7 @@ JackEngine::JackEngine(JackGraphManager* manager, | |||||
JackEngine::~JackEngine() | JackEngine::~JackEngine() | ||||
{ | { | ||||
delete fChannel; | delete fChannel; | ||||
delete fSignal; | |||||
delete fSignal; | |||||
} | } | ||||
int JackEngine::Open() | int JackEngine::Open() | ||||
@@ -79,14 +79,14 @@ int JackEngine::Close() | |||||
for (int i = 0; i < CLIENT_NUM; i++) { | for (int i = 0; i < CLIENT_NUM; i++) { | ||||
JackClientInterface* client = fClientTable[i]; | JackClientInterface* client = fClientTable[i]; | ||||
if (client) { | if (client) { | ||||
JackLog("JackEngine::Close remaining client %ld\n", i); | |||||
fClientTable[i] = NULL; | |||||
JackLog("JackEngine::Close remaining client %ld\n", i); | |||||
fClientTable[i] = NULL; | |||||
client->Close(); | client->Close(); | ||||
delete client; | delete client; | ||||
} | } | ||||
} | } | ||||
fSignal->Destroy(); | |||||
fSignal->Destroy(); | |||||
return 0; | return 0; | ||||
} | } | ||||
@@ -107,23 +107,23 @@ int JackEngine::AllocateRefnum() | |||||
void JackEngine::ReleaseRefnum(int ref) | void JackEngine::ReleaseRefnum(int ref) | ||||
{ | { | ||||
fClientTable[ref] = NULL; | |||||
if (fEngineControl->fTemporary) { | |||||
int i; | |||||
for (i = REAL_REFNUM; i < CLIENT_NUM; i++) { | |||||
if (fClientTable[i]) | |||||
break; | |||||
} | |||||
if (i == CLIENT_NUM) { | |||||
// last client and temporay case: quit the server | |||||
JackLog("JackEngine::ReleaseRefnum server quit\n"); | |||||
fEngineControl->fTemporary = false; | |||||
#ifndef WIN32 | |||||
kill(getpid(), SIGINT); | |||||
#endif | |||||
} | |||||
} | |||||
fClientTable[ref] = NULL; | |||||
if (fEngineControl->fTemporary) { | |||||
int i; | |||||
for (i = REAL_REFNUM; i < CLIENT_NUM; i++) { | |||||
if (fClientTable[i]) | |||||
break; | |||||
} | |||||
if (i == CLIENT_NUM) { | |||||
// last client and temporay case: quit the server | |||||
JackLog("JackEngine::ReleaseRefnum server quit\n"); | |||||
fEngineControl->fTemporary = false; | |||||
#ifndef WIN32 | |||||
kill(getpid(), SIGINT); | |||||
#endif | |||||
} | |||||
} | |||||
} | } | ||||
//------------------ | //------------------ | ||||
@@ -132,46 +132,46 @@ void JackEngine::ReleaseRefnum(int ref) | |||||
void JackEngine::ProcessNext(jack_time_t callback_usecs) | void JackEngine::ProcessNext(jack_time_t callback_usecs) | ||||
{ | { | ||||
fLastSwitchUsecs = callback_usecs; | |||||
if (fGraphManager->RunNextGraph()) // True if the graph actually switched to a new state | |||||
fChannel->ClientNotify(ALL_CLIENTS, kGraphOrderCallback, 0, 0); | |||||
fSignal->SignalAll(); // Signal for threads waiting for next cycle | |||||
fLastSwitchUsecs = callback_usecs; | |||||
if (fGraphManager->RunNextGraph()) // True if the graph actually switched to a new state | |||||
fChannel->ClientNotify(ALL_CLIENTS, kGraphOrderCallback, 0, 0); | |||||
fSignal->SignalAll(); // Signal for threads waiting for next cycle | |||||
} | } | ||||
void JackEngine::ProcessCurrent(jack_time_t callback_usecs) | void JackEngine::ProcessCurrent(jack_time_t callback_usecs) | ||||
{ | { | ||||
if (callback_usecs < fLastSwitchUsecs + 2 * fEngineControl->fPeriodUsecs) // Signal XRun only for the first failing cycle | |||||
CheckXRun(callback_usecs); | |||||
fGraphManager->RunCurrentGraph(); | |||||
if (callback_usecs < fLastSwitchUsecs + 2 * fEngineControl->fPeriodUsecs) // Signal XRun only for the first failing cycle | |||||
CheckXRun(callback_usecs); | |||||
fGraphManager->RunCurrentGraph(); | |||||
} | } | ||||
bool JackEngine::Process(jack_time_t callback_usecs) | bool JackEngine::Process(jack_time_t callback_usecs) | ||||
{ | { | ||||
bool res = true; | |||||
bool res = true; | |||||
// Cycle begin | // Cycle begin | ||||
fEngineControl->CycleBegin(fClientTable, fGraphManager, callback_usecs); | |||||
fEngineControl->CycleBegin(fClientTable, fGraphManager, callback_usecs); | |||||
// Graph | |||||
// Graph | |||||
if (fGraphManager->IsFinishedGraph()) { | if (fGraphManager->IsFinishedGraph()) { | ||||
ProcessNext(callback_usecs); | ProcessNext(callback_usecs); | ||||
res = true; | |||||
res = true; | |||||
} else { | } else { | ||||
JackLog("Process: graph not finished!\n"); | JackLog("Process: graph not finished!\n"); | ||||
if (callback_usecs > fLastSwitchUsecs + fEngineControl->fTimeOutUsecs) { | |||||
if (callback_usecs > fLastSwitchUsecs + fEngineControl->fTimeOutUsecs) { | |||||
JackLog("Process: switch to next state delta = %ld\n", long(callback_usecs - fLastSwitchUsecs)); | JackLog("Process: switch to next state delta = %ld\n", long(callback_usecs - fLastSwitchUsecs)); | ||||
ProcessNext(callback_usecs); | |||||
res = true; | |||||
ProcessNext(callback_usecs); | |||||
res = true; | |||||
} else { | } else { | ||||
JackLog("Process: waiting to switch delta = %ld\n", long(callback_usecs - fLastSwitchUsecs)); | JackLog("Process: waiting to switch delta = %ld\n", long(callback_usecs - fLastSwitchUsecs)); | ||||
ProcessCurrent(callback_usecs); | ProcessCurrent(callback_usecs); | ||||
res = false; | |||||
} | |||||
res = false; | |||||
} | |||||
} | } | ||||
// Cycle end | // Cycle end | ||||
fEngineControl->CycleEnd(fClientTable); | |||||
return res; | |||||
fEngineControl->CycleEnd(fClientTable); | |||||
return res; | |||||
} | } | ||||
@@ -185,15 +185,15 @@ void JackEngine::CheckXRun(jack_time_t callback_usecs) // REVOIR les conditions | |||||
for (int i = REAL_REFNUM; i < CLIENT_NUM; i++) { | for (int i = REAL_REFNUM; i < CLIENT_NUM; i++) { | ||||
JackClientInterface* client = fClientTable[i]; | JackClientInterface* client = fClientTable[i]; | ||||
if (client && client->GetClientControl()->fActive) { | if (client && client->GetClientControl()->fActive) { | ||||
JackClientTiming* timing = fGraphManager->GetClientTiming(i); | |||||
jack_client_state_t status = timing->fStatus; | |||||
JackClientTiming* timing = fGraphManager->GetClientTiming(i); | |||||
jack_client_state_t status = timing->fStatus; | |||||
jack_time_t finished_date = timing->fFinishedAt; | jack_time_t finished_date = timing->fFinishedAt; | ||||
if (status != NotTriggered && status != Finished) { | if (status != NotTriggered && status != Finished) { | ||||
jack_error("JackEngine::XRun: client = %s was not run: state = %ld", client->GetClientControl()->fName, status); | jack_error("JackEngine::XRun: client = %s was not run: state = %ld", client->GetClientControl()->fName, status); | ||||
fChannel->ClientNotify(ALL_CLIENTS, kXRunCallback, 0, 0); // Notify all clients | fChannel->ClientNotify(ALL_CLIENTS, kXRunCallback, 0, 0); // Notify all clients | ||||
} | } | ||||
if (status == Finished && (long)(finished_date - callback_usecs) > 0) { | if (status == Finished && (long)(finished_date - callback_usecs) > 0) { | ||||
jack_error("JackEngine::XRun: client %s finished after current callback", client->GetClientControl()->fName); | jack_error("JackEngine::XRun: client %s finished after current callback", client->GetClientControl()->fName); | ||||
fChannel->ClientNotify(ALL_CLIENTS, kXRunCallback, 0, 0); // Notify all clients | fChannel->ClientNotify(ALL_CLIENTS, kXRunCallback, 0, 0); // Notify all clients | ||||
@@ -209,13 +209,13 @@ void JackEngine::CheckXRun(jack_time_t callback_usecs) // REVOIR les conditions | |||||
void JackEngine::NotifyClient(int refnum, int event, int sync, int value1, int value2) | void JackEngine::NotifyClient(int refnum, int event, int sync, int value1, int value2) | ||||
{ | { | ||||
JackClientInterface* client = fClientTable[refnum]; | JackClientInterface* client = fClientTable[refnum]; | ||||
// The client may be notified by the RT thread while closing | // The client may be notified by the RT thread while closing | ||||
if (!client) { | if (!client) { | ||||
JackLog("JackEngine::NotifyClient: client not available anymore\n"); | |||||
} else if (client->GetClientControl()->fCallback[event]) { | |||||
if (client->ClientNotify(refnum, client->GetClientControl()->fName, event, sync, value1, value2) < 0) | |||||
jack_error("NotifyClient fails name = %s event = %ld = val1 = %ld val2 = %ld", client->GetClientControl()->fName, event, value1, value2); | |||||
JackLog("JackEngine::NotifyClient: client not available anymore\n"); | |||||
} else if (client->GetClientControl()->fCallback[event]) { | |||||
if (client->ClientNotify(refnum, client->GetClientControl()->fName, event, sync, value1, value2) < 0) | |||||
jack_error("NotifyClient fails name = %s event = %ld = val1 = %ld val2 = %ld", client->GetClientControl()->fName, event, value1, value2); | |||||
} else { | } else { | ||||
JackLog("JackEngine::NotifyClient: no callback for event = %ld\n", event); | JackLog("JackEngine::NotifyClient: no callback for event = %ld\n", event); | ||||
} | } | ||||
@@ -225,14 +225,14 @@ void JackEngine::NotifyClients(int event, int sync, int value1, int value2) | |||||
{ | { | ||||
for (int i = 0; i < CLIENT_NUM; i++) { | for (int i = 0; i < CLIENT_NUM; i++) { | ||||
JackClientInterface* client = fClientTable[i]; | JackClientInterface* client = fClientTable[i]; | ||||
if (client) { | |||||
if (client->GetClientControl()->fCallback[event]) { | |||||
if (client->ClientNotify(i, client->GetClientControl()->fName, event, sync, value1, value2) < 0) | |||||
jack_error("NotifyClient fails name = %s event = %ld = val1 = %ld val2 = %ld", client->GetClientControl()->fName, event, value1, value2); | |||||
} else { | |||||
JackLog("JackEngine::NotifyClients: no callback for event = %ld\n", event); | |||||
} | |||||
} | |||||
if (client) { | |||||
if (client->GetClientControl()->fCallback[event]) { | |||||
if (client->ClientNotify(i, client->GetClientControl()->fName, event, sync, value1, value2) < 0) | |||||
jack_error("NotifyClient fails name = %s event = %ld = val1 = %ld val2 = %ld", client->GetClientControl()->fName, event, value1, value2); | |||||
} else { | |||||
JackLog("JackEngine::NotifyClients: no callback for event = %ld\n", event); | |||||
} | |||||
} | |||||
} | } | ||||
} | } | ||||
@@ -244,12 +244,12 @@ int JackEngine::NotifyAddClient(JackClientInterface* new_client, const char* nam | |||||
if (old_client) { | if (old_client) { | ||||
if (old_client->ClientNotify(refnum, name, kAddClient, true, 0, 0) < 0) { | if (old_client->ClientNotify(refnum, name, kAddClient, true, 0, 0) < 0) { | ||||
jack_error("NotifyAddClient old_client fails name = %s", old_client->GetClientControl()->fName); | jack_error("NotifyAddClient old_client fails name = %s", old_client->GetClientControl()->fName); | ||||
return -1; | |||||
} | |||||
if (new_client->ClientNotify(i, old_client->GetClientControl()->fName, kAddClient, true, 0, 0) < 0) { | |||||
return -1; | |||||
} | |||||
if (new_client->ClientNotify(i, old_client->GetClientControl()->fName, kAddClient, true, 0, 0) < 0) { | |||||
jack_error("NotifyAddClient new_client fails name = %s", name); | jack_error("NotifyAddClient new_client fails name = %s", name); | ||||
return -1; | |||||
} | |||||
return -1; | |||||
} | |||||
} | } | ||||
} | } | ||||
@@ -271,7 +271,7 @@ void JackEngine::NotifyRemoveClient(const char* name, int refnum) | |||||
void JackEngine::NotifyXRun(jack_time_t callback_usecs) | void JackEngine::NotifyXRun(jack_time_t callback_usecs) | ||||
{ | { | ||||
// Use the audio thread => request thread communication channel | // Use the audio thread => request thread communication channel | ||||
fEngineControl->ResetFrameTime(callback_usecs); | |||||
fEngineControl->ResetFrameTime(callback_usecs); | |||||
fChannel->ClientNotify(ALL_CLIENTS, kXRunCallback, 0, 0); | fChannel->ClientNotify(ALL_CLIENTS, kXRunCallback, 0, 0); | ||||
} | } | ||||
@@ -312,7 +312,7 @@ void JackEngine::NotifyPortConnect(jack_port_id_t src, jack_port_id_t dst, bool | |||||
void JackEngine::NotifyActivate(int refnum) | void JackEngine::NotifyActivate(int refnum) | ||||
{ | { | ||||
NotifyClient(refnum, kActivateClient, true, 0, 0); | |||||
NotifyClient(refnum, kActivateClient, true, 0, 0); | |||||
} | } | ||||
//---------------------------- | //---------------------------- | ||||
@@ -321,45 +321,45 @@ void JackEngine::NotifyActivate(int refnum) | |||||
int JackEngine::GetInternalClientName(int refnum, char* name_res) | int JackEngine::GetInternalClientName(int refnum, char* name_res) | ||||
{ | { | ||||
assert(refnum >= 0 && refnum < CLIENT_NUM); | |||||
JackClientInterface* client = fClientTable[refnum]; | |||||
if (client) { | |||||
strncpy(name_res, client->GetClientControl()->fName, JACK_CLIENT_NAME_SIZE); | |||||
return 0; | |||||
} else { | |||||
return -1; | |||||
} | |||||
assert(refnum >= 0 && refnum < CLIENT_NUM); | |||||
JackClientInterface* client = fClientTable[refnum]; | |||||
if (client) { | |||||
strncpy(name_res, client->GetClientControl()->fName, JACK_CLIENT_NAME_SIZE); | |||||
return 0; | |||||
} else { | |||||
return -1; | |||||
} | |||||
} | } | ||||
int JackEngine::InternalClientHandle(const char* client_name, int* status, int* int_ref) | int JackEngine::InternalClientHandle(const char* client_name, int* status, int* int_ref) | ||||
{ | { | ||||
// Clear status | |||||
*status = 0; | |||||
for (int i = 0; i < CLIENT_NUM; i++) { | |||||
// Clear status | |||||
*status = 0; | |||||
for (int i = 0; i < CLIENT_NUM; i++) { | |||||
JackClientInterface* client = fClientTable[i]; | JackClientInterface* client = fClientTable[i]; | ||||
if (client && dynamic_cast<JackLoadableInternalClient*>(client) && (strcmp(client->GetClientControl()->fName, client_name) == 0)) { | if (client && dynamic_cast<JackLoadableInternalClient*>(client) && (strcmp(client->GetClientControl()->fName, client_name) == 0)) { | ||||
JackLog("InternalClientHandle found client name = %s ref = %ld\n", client_name, i); | |||||
*int_ref = i; | |||||
return 0; | |||||
} | |||||
JackLog("InternalClientHandle found client name = %s ref = %ld\n", client_name, i); | |||||
*int_ref = i; | |||||
return 0; | |||||
} | |||||
} | } | ||||
*status |= (JackNoSuchClient | JackFailure); | |||||
return -1; | |||||
*status |= (JackNoSuchClient | JackFailure); | |||||
return -1; | |||||
} | } | ||||
int JackEngine::InternalClientUnload(int refnum, int* status) | int JackEngine::InternalClientUnload(int refnum, int* status) | ||||
{ | { | ||||
assert(refnum >= 0 && refnum < CLIENT_NUM); | |||||
JackClientInterface* client = fClientTable[refnum]; | |||||
if (client) { | |||||
int res = client->Close(); | |||||
delete client; | |||||
*status = 0; | |||||
return res; | |||||
} else { | |||||
*status = (JackNoSuchClient | JackFailure); | |||||
assert(refnum >= 0 && refnum < CLIENT_NUM); | |||||
JackClientInterface* client = fClientTable[refnum]; | |||||
if (client) { | |||||
int res = client->Close(); | |||||
delete client; | |||||
*status = 0; | |||||
return res; | |||||
} else { | |||||
*status = (JackNoSuchClient | JackFailure); | |||||
return -1; | return -1; | ||||
} | } | ||||
} | } | ||||
@@ -370,68 +370,68 @@ int JackEngine::InternalClientUnload(int refnum, int* status) | |||||
int JackEngine::ClientCheck(const char* name, char* name_res, int protocol, int options, int* status) | int JackEngine::ClientCheck(const char* name, char* name_res, int protocol, int options, int* status) | ||||
{ | { | ||||
// Clear status | |||||
*status = 0; | |||||
strcpy(name_res, name); | |||||
JackLog("Check protocol client %ld server = %ld\n", protocol, JACK_PROTOCOL_VERSION); | |||||
if (protocol != JACK_PROTOCOL_VERSION) { | |||||
*status |= (JackFailure | JackVersionError); | |||||
jack_error("JACK protocol mismatch (%d vs %d)", protocol, JACK_PROTOCOL_VERSION); | |||||
return -1; | |||||
} | |||||
if (ClientCheckName(name)) { | |||||
*status |= JackNameNotUnique; | |||||
if (options & JackUseExactName) { | |||||
jack_error("cannot create new client; %s already exists", name); | |||||
*status |= JackFailure; | |||||
return -1; | |||||
} | |||||
if (GenerateUniqueName(name_res)) { | |||||
*status |= JackFailure; | |||||
return -1; | |||||
} | |||||
} | |||||
return 0; | |||||
// Clear status | |||||
*status = 0; | |||||
strcpy(name_res, name); | |||||
JackLog("Check protocol client %ld server = %ld\n", protocol, JACK_PROTOCOL_VERSION); | |||||
if (protocol != JACK_PROTOCOL_VERSION) { | |||||
*status |= (JackFailure | JackVersionError); | |||||
jack_error("JACK protocol mismatch (%d vs %d)", protocol, JACK_PROTOCOL_VERSION); | |||||
return -1; | |||||
} | |||||
if (ClientCheckName(name)) { | |||||
*status |= JackNameNotUnique; | |||||
if (options & JackUseExactName) { | |||||
jack_error("cannot create new client; %s already exists", name); | |||||
*status |= JackFailure; | |||||
return -1; | |||||
} | |||||
if (GenerateUniqueName(name_res)) { | |||||
*status |= JackFailure; | |||||
return -1; | |||||
} | |||||
} | |||||
return 0; | |||||
} | } | ||||
bool JackEngine::GenerateUniqueName(char* name) | bool JackEngine::GenerateUniqueName(char* name) | ||||
{ | { | ||||
int tens, ones; | |||||
int length = strlen(name); | |||||
if (length > JACK_CLIENT_NAME_SIZE - 4) { | |||||
jack_error("%s exists and is too long to make unique", name); | |||||
return true; /* failure */ | |||||
} | |||||
/* generate a unique name by appending "-01".."-99" */ | |||||
name[length++] = '-'; | |||||
tens = length++; | |||||
ones = length++; | |||||
name[tens] = '0'; | |||||
name[ones] = '1'; | |||||
name[length] = '\0'; | |||||
while (ClientCheckName(name)) { | |||||
if (name[ones] == '9') { | |||||
if (name[tens] == '9') { | |||||
jack_error("client %s has 99 extra instances already", name); | |||||
return true; /* give up */ | |||||
} | |||||
name[tens]++; | |||||
name[ones] = '0'; | |||||
} else { | |||||
name[ones]++; | |||||
} | |||||
} | |||||
return false; | |||||
int tens, ones; | |||||
int length = strlen(name); | |||||
if (length > JACK_CLIENT_NAME_SIZE - 4) { | |||||
jack_error("%s exists and is too long to make unique", name); | |||||
return true; /* failure */ | |||||
} | |||||
/* generate a unique name by appending "-01".."-99" */ | |||||
name[length++] = '-'; | |||||
tens = length++; | |||||
ones = length++; | |||||
name[tens] = '0'; | |||||
name[ones] = '1'; | |||||
name[length] = '\0'; | |||||
while (ClientCheckName(name)) { | |||||
if (name[ones] == '9') { | |||||
if (name[tens] == '9') { | |||||
jack_error("client %s has 99 extra instances already", name); | |||||
return true; /* give up */ | |||||
} | |||||
name[tens]++; | |||||
name[ones] = '0'; | |||||
} else { | |||||
name[ones]++; | |||||
} | |||||
} | |||||
return false; | |||||
} | } | ||||
bool JackEngine::ClientCheckName(const char* name) | bool JackEngine::ClientCheckName(const char* name) | ||||
@@ -449,18 +449,18 @@ bool JackEngine::ClientCheckName(const char* name) | |||||
int JackEngine::ClientExternalOpen(const char* name, int* ref, int* shared_engine, int* shared_client, int* shared_graph_manager) | int JackEngine::ClientExternalOpen(const char* name, int* ref, int* shared_engine, int* shared_client, int* shared_graph_manager) | ||||
{ | { | ||||
JackLog("JackEngine::ClientOpen: name = %s \n", name); | JackLog("JackEngine::ClientOpen: name = %s \n", name); | ||||
int refnum = AllocateRefnum(); | |||||
int refnum = AllocateRefnum(); | |||||
if (refnum < 0) { | if (refnum < 0) { | ||||
jack_error("No more refnum available"); | jack_error("No more refnum available"); | ||||
return -1; | return -1; | ||||
} | } | ||||
JackExternalClient* client = new JackExternalClient(); | |||||
JackExternalClient* client = new JackExternalClient(); | |||||
if (!fSynchroTable[refnum]->Allocate(name, fEngineControl->fServerName, 0)) { | if (!fSynchroTable[refnum]->Allocate(name, fEngineControl->fServerName, 0)) { | ||||
jack_error("Cannot allocate synchro"); | jack_error("Cannot allocate synchro"); | ||||
goto error; | |||||
goto error; | |||||
} | } | ||||
if (client->Open(name, refnum, shared_client) < 0) { | if (client->Open(name, refnum, shared_client) < 0) { | ||||
@@ -480,8 +480,8 @@ int JackEngine::ClientExternalOpen(const char* name, int* ref, int* shared_engin | |||||
} | } | ||||
fClientTable[refnum] = client; | fClientTable[refnum] = client; | ||||
fGraphManager->InitRefNum(refnum); | |||||
fEngineControl->ResetRollingUsecs(); | |||||
fGraphManager->InitRefNum(refnum); | |||||
fEngineControl->ResetRollingUsecs(); | |||||
*shared_engine = fEngineControl->GetShmIndex(); | *shared_engine = fEngineControl->GetShmIndex(); | ||||
*shared_graph_manager = fGraphManager->GetShmIndex(); | *shared_graph_manager = fGraphManager->GetShmIndex(); | ||||
*ref = refnum; | *ref = refnum; | ||||
@@ -490,7 +490,7 @@ int JackEngine::ClientExternalOpen(const char* name, int* ref, int* shared_engin | |||||
error: | error: | ||||
ClientCloseAux(refnum, client, false); | ClientCloseAux(refnum, client, false); | ||||
client->Close(); | client->Close(); | ||||
delete client; | |||||
delete client; | |||||
return -1; | return -1; | ||||
} | } | ||||
@@ -498,32 +498,32 @@ error: | |||||
int JackEngine::ClientInternalOpen(const char* name, int* ref, JackEngineControl** shared_engine, JackGraphManager** shared_manager, JackClientInterface* client, bool wait) | int JackEngine::ClientInternalOpen(const char* name, int* ref, JackEngineControl** shared_engine, JackGraphManager** shared_manager, JackClientInterface* client, bool wait) | ||||
{ | { | ||||
JackLog("JackEngine::ClientInternalNew: name = %s\n", name); | JackLog("JackEngine::ClientInternalNew: name = %s\n", name); | ||||
int refnum = AllocateRefnum(); | |||||
if (refnum < 0) { | |||||
int refnum = AllocateRefnum(); | |||||
if (refnum < 0) { | |||||
jack_error("No more refnum available"); | jack_error("No more refnum available"); | ||||
return -1; | return -1; | ||||
} | } | ||||
if (!fSynchroTable[refnum]->Allocate(name, fEngineControl->fServerName, 0)) { | if (!fSynchroTable[refnum]->Allocate(name, fEngineControl->fServerName, 0)) { | ||||
jack_error("Cannot allocate synchro"); | jack_error("Cannot allocate synchro"); | ||||
return -1; | |||||
return -1; | |||||
} | } | ||||
if (wait && !fSignal->TimedWait(DRIVER_OPEN_TIMEOUT * 1000000)) { | |||||
if (wait && !fSignal->TimedWait(DRIVER_OPEN_TIMEOUT * 1000000)) { | |||||
// Failure if RT thread is not running (problem with the driver...) | // Failure if RT thread is not running (problem with the driver...) | ||||
jack_error("Driver is not running"); | jack_error("Driver is not running"); | ||||
return -1; | |||||
return -1; | |||||
} | } | ||||
if (NotifyAddClient(client, name, refnum) < 0) { | if (NotifyAddClient(client, name, refnum) < 0) { | ||||
jack_error("Cannot notify add client"); | jack_error("Cannot notify add client"); | ||||
return -1; | |||||
return -1; | |||||
} | } | ||||
fClientTable[refnum] = client; | fClientTable[refnum] = client; | ||||
fGraphManager->InitRefNum(refnum); | |||||
fEngineControl->ResetRollingUsecs(); | |||||
fGraphManager->InitRefNum(refnum); | |||||
fEngineControl->ResetRollingUsecs(); | |||||
*shared_engine = fEngineControl; | *shared_engine = fEngineControl; | ||||
*shared_manager = fGraphManager; | *shared_manager = fGraphManager; | ||||
*ref = refnum; | *ref = refnum; | ||||
@@ -554,28 +554,28 @@ int JackEngine::ClientInternalClose(int refnum, bool wait) | |||||
int JackEngine::ClientCloseAux(int refnum, JackClientInterface* client, bool wait) | int JackEngine::ClientCloseAux(int refnum, JackClientInterface* client, bool wait) | ||||
{ | { | ||||
JackLog("JackEngine::ClientCloseAux ref = %ld name = %s\n", | |||||
refnum, | |||||
(client->GetClientControl()) ? client->GetClientControl()->fName : "No name"); | |||||
JackLog("JackEngine::ClientCloseAux ref = %ld name = %s\n", | |||||
refnum, | |||||
(client->GetClientControl()) ? client->GetClientControl()->fName : "No name"); | |||||
// Remove the client from the table | // Remove the client from the table | ||||
ReleaseRefnum(refnum); | |||||
// Notiy unregister | |||||
jack_int_t ports[PORT_NUM_FOR_CLIENT]; | |||||
int i; | |||||
fGraphManager->GetInputPorts(refnum, ports); | |||||
for (i = 0; (i < PORT_NUM_FOR_CLIENT) && (ports[i] != EMPTY) ; i++) { | |||||
NotifyPortRegistation(ports[i], false); | |||||
} | |||||
fGraphManager->GetOutputPorts(refnum, ports); | |||||
for (i = 0; (i < PORT_NUM_FOR_CLIENT) && (ports[i] != EMPTY) ; i++) { | |||||
NotifyPortRegistation(ports[i], false); | |||||
} | |||||
// Remove all ports | |||||
ReleaseRefnum(refnum); | |||||
// Notiy unregister | |||||
jack_int_t ports[PORT_NUM_FOR_CLIENT]; | |||||
int i; | |||||
fGraphManager->GetInputPorts(refnum, ports); | |||||
for (i = 0; (i < PORT_NUM_FOR_CLIENT) && (ports[i] != EMPTY) ; i++) { | |||||
NotifyPortRegistation(ports[i], false); | |||||
} | |||||
fGraphManager->GetOutputPorts(refnum, ports); | |||||
for (i = 0; (i < PORT_NUM_FOR_CLIENT) && (ports[i] != EMPTY) ; i++) { | |||||
NotifyPortRegistation(ports[i], false); | |||||
} | |||||
// Remove all ports | |||||
fGraphManager->RemoveAllPorts(refnum); | fGraphManager->RemoveAllPorts(refnum); | ||||
// Wait until next cycle to be sure client is not used anymore | // Wait until next cycle to be sure client is not used anymore | ||||
@@ -586,51 +586,51 @@ int JackEngine::ClientCloseAux(int refnum, JackClientInterface* client, bool wai | |||||
} | } | ||||
// Notify running clients | // Notify running clients | ||||
if (client->GetClientControl()) // When called in error cases, client may not be completely allocated | |||||
NotifyRemoveClient(client->GetClientControl()->fName, client->GetClientControl()->fRefNum); | |||||
if (client->GetClientControl()) // When called in error cases, client may not be completely allocated | |||||
NotifyRemoveClient(client->GetClientControl()->fName, client->GetClientControl()->fRefNum); | |||||
// Cleanup... | // Cleanup... | ||||
fSynchroTable[refnum]->Destroy(); | fSynchroTable[refnum]->Destroy(); | ||||
fEngineControl->ResetRollingUsecs(); | |||||
fEngineControl->ResetRollingUsecs(); | |||||
return 0; | return 0; | ||||
} | } | ||||
int JackEngine::ClientActivate(int refnum) | int JackEngine::ClientActivate(int refnum) | ||||
{ | { | ||||
JackClientInterface* client = fClientTable[refnum]; | JackClientInterface* client = fClientTable[refnum]; | ||||
assert(fClientTable[refnum]); | |||||
JackLog("JackEngine::ClientActivate ref = %ld name = %s\n", refnum, client->GetClientControl()->fName); | |||||
fGraphManager->Activate(refnum); | |||||
// Wait for graph state change to be effective | |||||
if (!fSignal->TimedWait(fEngineControl->fTimeOutUsecs * 10)) { | |||||
jack_error("JackEngine::ClientActivate wait error ref = %ld name = %s", refnum, client->GetClientControl()->fName); | |||||
return -1; | |||||
} else { | |||||
NotifyActivate(refnum); | |||||
return 0; | |||||
} | |||||
assert(fClientTable[refnum]); | |||||
JackLog("JackEngine::ClientActivate ref = %ld name = %s\n", refnum, client->GetClientControl()->fName); | |||||
fGraphManager->Activate(refnum); | |||||
// Wait for graph state change to be effective | |||||
if (!fSignal->TimedWait(fEngineControl->fTimeOutUsecs * 10)) { | |||||
jack_error("JackEngine::ClientActivate wait error ref = %ld name = %s", refnum, client->GetClientControl()->fName); | |||||
return -1; | |||||
} else { | |||||
NotifyActivate(refnum); | |||||
return 0; | |||||
} | |||||
} | } | ||||
// May be called without client | // May be called without client | ||||
int JackEngine::ClientDeactivate(int refnum) | int JackEngine::ClientDeactivate(int refnum) | ||||
{ | { | ||||
JackClientInterface* client = fClientTable[refnum]; | JackClientInterface* client = fClientTable[refnum]; | ||||
if (client == NULL) | |||||
return -1; | |||||
JackLog("JackEngine::ClientDeactivate ref = %ld name = %s\n", refnum, client->GetClientControl()->fName); | |||||
fGraphManager->Deactivate(refnum); | |||||
fLastSwitchUsecs = 0; // Force switch to occur next cycle, even when called with "dead" clients | |||||
// Wait for graph state change to be effective | |||||
if (!fSignal->TimedWait(fEngineControl->fTimeOutUsecs * 10)) { | |||||
jack_error("JackEngine::ClientDeactivate wait error ref = %ld name = %s", refnum, client->GetClientControl()->fName); | |||||
return -1; | |||||
} else { | |||||
return 0; | |||||
} | |||||
if (client == NULL) | |||||
return -1; | |||||
JackLog("JackEngine::ClientDeactivate ref = %ld name = %s\n", refnum, client->GetClientControl()->fName); | |||||
fGraphManager->Deactivate(refnum); | |||||
fLastSwitchUsecs = 0; // Force switch to occur next cycle, even when called with "dead" clients | |||||
// Wait for graph state change to be effective | |||||
if (!fSignal->TimedWait(fEngineControl->fTimeOutUsecs * 10)) { | |||||
jack_error("JackEngine::ClientDeactivate wait error ref = %ld name = %s", refnum, client->GetClientControl()->fName); | |||||
return -1; | |||||
} else { | |||||
return 0; | |||||
} | |||||
} | } | ||||
//----------------- | //----------------- | ||||
@@ -702,67 +702,67 @@ int JackEngine::PortConnect(int refnum, jack_port_id_t src, jack_port_id_t dst) | |||||
" \"%s\" is not active", client->GetClientControl()->fName); | " \"%s\" is not active", client->GetClientControl()->fName); | ||||
return -1; | return -1; | ||||
} | } | ||||
int res = fGraphManager->Connect(src, dst); | |||||
if (res == 0) { | |||||
NotifyPortConnect(src, dst, true); | |||||
NotifyPortConnect(dst, src, true); | |||||
} | |||||
return res; | |||||
int res = fGraphManager->Connect(src, dst); | |||||
if (res == 0) { | |||||
NotifyPortConnect(src, dst, true); | |||||
NotifyPortConnect(dst, src, true); | |||||
} | |||||
return res; | |||||
} | } | ||||
int JackEngine::PortDisconnect(int refnum, const char* src, const char* dst) | int JackEngine::PortDisconnect(int refnum, const char* src, const char* dst) | ||||
{ | { | ||||
JackLog("JackEngine::PortDisconnect src = %s dst = %s\n", src, dst); | JackLog("JackEngine::PortDisconnect src = %s dst = %s\n", src, dst); | ||||
jack_port_id_t port_src, port_dst; | jack_port_id_t port_src, port_dst; | ||||
if (fGraphManager->CheckPorts(src, dst, &port_src, &port_dst) < 0) { | |||||
return -1; | |||||
} else if (fGraphManager->Disconnect(port_src, port_dst) == 0){ | |||||
NotifyPortConnect(port_src, port_dst, false); | |||||
NotifyPortConnect(port_dst, port_src, false); | |||||
return 0; | |||||
} else { | |||||
return -1; | |||||
} | |||||
if (fGraphManager->CheckPorts(src, dst, &port_src, &port_dst) < 0) { | |||||
return -1; | |||||
} else if (fGraphManager->Disconnect(port_src, port_dst) == 0) { | |||||
NotifyPortConnect(port_src, port_dst, false); | |||||
NotifyPortConnect(port_dst, port_src, false); | |||||
return 0; | |||||
} else { | |||||
return -1; | |||||
} | |||||
} | } | ||||
int JackEngine::PortDisconnect(int refnum, jack_port_id_t src, jack_port_id_t dst) | int JackEngine::PortDisconnect(int refnum, jack_port_id_t src, jack_port_id_t dst) | ||||
{ | { | ||||
JackLog("JackEngine::PortDisconnect src = %d dst = %d\n", src, dst); | JackLog("JackEngine::PortDisconnect src = %d dst = %d\n", src, dst); | ||||
if (dst == ALL_PORTS) { | if (dst == ALL_PORTS) { | ||||
jack_int_t connections[CONNECTION_NUM]; | |||||
fGraphManager->GetConnections(src, connections); | |||||
// Notifications | |||||
JackPort* port = fGraphManager->GetPort(src); | |||||
if (port->GetFlags() & JackPortIsOutput) { | |||||
for (int i = 0; (i < CONNECTION_NUM) && (connections[i] != EMPTY); i++) { | |||||
JackLog("NotifyPortConnect src = %ld dst = %ld false\n", src, connections[i]); | |||||
NotifyPortConnect(src, connections[i], false); | |||||
NotifyPortConnect(connections[i], src, false); | |||||
} | |||||
} else { | |||||
for (int i = 0; (i < CONNECTION_NUM) && (connections[i] != EMPTY); i++) { | |||||
JackLog("NotifyPortConnect src = %ld dst = %ld false\n", connections[i], src); | |||||
NotifyPortConnect(connections[i], src, false); | |||||
NotifyPortConnect(connections[i], src, false); | |||||
} | |||||
} | |||||
return fGraphManager->DisconnectAll(src); | |||||
} else if (fGraphManager->CheckPorts(src, dst) < 0) { | |||||
return -1; | |||||
} else if (fGraphManager->Disconnect(src, dst) == 0) { | |||||
// Notifications | |||||
NotifyPortConnect(src, dst, false); | |||||
NotifyPortConnect(dst, src, false); | |||||
return 0; | |||||
jack_int_t connections[CONNECTION_NUM]; | |||||
fGraphManager->GetConnections(src, connections); | |||||
// Notifications | |||||
JackPort* port = fGraphManager->GetPort(src); | |||||
if (port->GetFlags() & JackPortIsOutput) { | |||||
for (int i = 0; (i < CONNECTION_NUM) && (connections[i] != EMPTY); i++) { | |||||
JackLog("NotifyPortConnect src = %ld dst = %ld false\n", src, connections[i]); | |||||
NotifyPortConnect(src, connections[i], false); | |||||
NotifyPortConnect(connections[i], src, false); | |||||
} | |||||
} else { | |||||
for (int i = 0; (i < CONNECTION_NUM) && (connections[i] != EMPTY); i++) { | |||||
JackLog("NotifyPortConnect src = %ld dst = %ld false\n", connections[i], src); | |||||
NotifyPortConnect(connections[i], src, false); | |||||
NotifyPortConnect(connections[i], src, false); | |||||
} | |||||
} | |||||
return fGraphManager->DisconnectAll(src); | |||||
} else if (fGraphManager->CheckPorts(src, dst) < 0) { | |||||
return -1; | |||||
} else if (fGraphManager->Disconnect(src, dst) == 0) { | |||||
// Notifications | |||||
NotifyPortConnect(src, dst, false); | |||||
NotifyPortConnect(dst, src, false); | |||||
return 0; | |||||
} else { | } else { | ||||
return -1; | |||||
} | |||||
return -1; | |||||
} | |||||
} | } | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2004-2008 Grame | |||||
Copyright (C) 2004-2008 Grame | |||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
it under the terms of the GNU General Public License as published by | it under the terms of the GNU General Public License as published by | ||||
@@ -52,22 +52,22 @@ class JackEngine | |||||
int ClientCloseAux(int refnum, JackClientInterface* client, bool wait); | int ClientCloseAux(int refnum, JackClientInterface* client, bool wait); | ||||
void CheckXRun(jack_time_t callback_usecs); | void CheckXRun(jack_time_t callback_usecs); | ||||
int NotifyAddClient(JackClientInterface* new_client, const char* name, int refnum); | int NotifyAddClient(JackClientInterface* new_client, const char* name, int refnum); | ||||
void NotifyRemoveClient(const char* name, int refnum); | void NotifyRemoveClient(const char* name, int refnum); | ||||
void ProcessNext(jack_time_t callback_usecs); | |||||
void ProcessCurrent(jack_time_t callback_usecs); | |||||
bool ClientCheckName(const char* name); | |||||
bool GenerateUniqueName(char* name); | |||||
int AllocateRefnum(); | |||||
void ReleaseRefnum(int ref); | |||||
void NotifyClient(int refnum, int event, int sync, int value1, int value2); | |||||
void ProcessNext(jack_time_t callback_usecs); | |||||
void ProcessCurrent(jack_time_t callback_usecs); | |||||
bool ClientCheckName(const char* name); | |||||
bool GenerateUniqueName(char* name); | |||||
int AllocateRefnum(); | |||||
void ReleaseRefnum(int ref); | |||||
void NotifyClient(int refnum, int event, int sync, int value1, int value2); | |||||
void NotifyClients(int event, int sync, int value1, int value2); | void NotifyClients(int event, int sync, int value1, int value2); | ||||
public: | public: | ||||
JackEngine(JackGraphManager* manager, JackSynchro** table, JackEngineControl* controler); | JackEngine(JackGraphManager* manager, JackSynchro** table, JackEngineControl* controler); | ||||
@@ -75,22 +75,22 @@ class JackEngine | |||||
int Open(); | int Open(); | ||||
int Close(); | int Close(); | ||||
// Client management | // Client management | ||||
int ClientCheck(const char* name, char* name_res, int protocol, int options, int* status); | |||||
int ClientCheck(const char* name, char* name_res, int protocol, int options, int* status); | |||||
int ClientExternalOpen(const char* name, int* ref, int* shared_engine, int* shared_client, int* shared_graph_manager); | int ClientExternalOpen(const char* name, int* ref, int* shared_engine, int* shared_client, int* shared_graph_manager); | ||||
int ClientInternalOpen(const char* name, int* ref, JackEngineControl** shared_engine, JackGraphManager** shared_manager, JackClientInterface* client, bool wait); | int ClientInternalOpen(const char* name, int* ref, JackEngineControl** shared_engine, JackGraphManager** shared_manager, JackClientInterface* client, bool wait); | ||||
int ClientExternalClose(int refnum); | int ClientExternalClose(int refnum); | ||||
int ClientInternalClose(int refnum, bool wait); | int ClientInternalClose(int refnum, bool wait); | ||||
int ClientActivate(int refnum); | int ClientActivate(int refnum); | ||||
int ClientDeactivate(int refnum); | int ClientDeactivate(int refnum); | ||||
// Internal client management | |||||
int GetInternalClientName(int int_ref, char* name_res); | |||||
int InternalClientHandle(const char* client_name, int* status, int* int_ref); | |||||
int InternalClientUnload(int refnum, int* status); | |||||
// Internal client management | |||||
int GetInternalClientName(int int_ref, char* name_res); | |||||
int InternalClientHandle(const char* client_name, int* status, int* int_ref); | |||||
int InternalClientUnload(int refnum, int* status); | |||||
// Port management | // Port management | ||||
int PortRegister(int refnum, const char* name, const char *type, unsigned int flags, unsigned int buffer_size, unsigned int* port_index); | int PortRegister(int refnum, const char* name, const char *type, unsigned int flags, unsigned int buffer_size, unsigned int* port_index); | ||||
@@ -104,16 +104,16 @@ class JackEngine | |||||
// Graph | // Graph | ||||
bool Process(jack_time_t callback_usecs); | bool Process(jack_time_t callback_usecs); | ||||
// Notifications | |||||
void NotifyXRun(jack_time_t callback_usecs); | |||||
// Notifications | |||||
void NotifyXRun(jack_time_t callback_usecs); | |||||
void NotifyXRun(int refnum); | void NotifyXRun(int refnum); | ||||
void NotifyGraphReorder(); | void NotifyGraphReorder(); | ||||
void NotifyBufferSize(jack_nframes_t nframes); | void NotifyBufferSize(jack_nframes_t nframes); | ||||
void NotifyFreewheel(bool onoff); | void NotifyFreewheel(bool onoff); | ||||
void NotifyPortRegistation(jack_port_id_t port_index, bool onoff); | void NotifyPortRegistation(jack_port_id_t port_index, bool onoff); | ||||
void NotifyPortConnect(jack_port_id_t src, jack_port_id_t dst, bool onoff); | |||||
void NotifyActivate(int refnum); | |||||
void NotifyPortConnect(jack_port_id_t src, jack_port_id_t dst, bool onoff); | |||||
void NotifyActivate(int refnum); | |||||
}; | }; | ||||
@@ -29,35 +29,35 @@ namespace Jack | |||||
void JackEngineControl::CycleBegin(JackClientInterface** table, JackGraphManager* manager, jack_time_t callback_usecs) | void JackEngineControl::CycleBegin(JackClientInterface** table, JackGraphManager* manager, jack_time_t callback_usecs) | ||||
{ | { | ||||
// Transport | |||||
fTransport.CycleBegin(fSampleRate, callback_usecs); | |||||
// Timer | |||||
fFrameTimer.IncFrameTime(fBufferSize, callback_usecs, fPeriodUsecs); | |||||
// Timing | |||||
GetTimeMeasure(table, manager, callback_usecs); | |||||
// Transport | |||||
fTransport.CycleBegin(fSampleRate, callback_usecs); | |||||
// Timer | |||||
fFrameTimer.IncFrameTime(fBufferSize, callback_usecs, fPeriodUsecs); | |||||
// Timing | |||||
GetTimeMeasure(table, manager, callback_usecs); | |||||
CalcCPULoad(table, manager); | CalcCPULoad(table, manager); | ||||
} | } | ||||
void JackEngineControl::CycleEnd(JackClientInterface** table) | void JackEngineControl::CycleEnd(JackClientInterface** table) | ||||
{ | { | ||||
fTransport.CycleEnd(table, fSampleRate, fBufferSize); | |||||
fTransport.CycleEnd(table, fSampleRate, fBufferSize); | |||||
} | } | ||||
void JackEngineControl::InitFrameTime() | void JackEngineControl::InitFrameTime() | ||||
{ | { | ||||
fFrameTimer.InitFrameTime(); | |||||
fFrameTimer.InitFrameTime(); | |||||
} | } | ||||
void JackEngineControl::ResetFrameTime(jack_time_t callback_usecs) | void JackEngineControl::ResetFrameTime(jack_time_t callback_usecs) | ||||
{ | { | ||||
fFrameTimer.ResetFrameTime(fSampleRate, callback_usecs, fPeriodUsecs); | |||||
fFrameTimer.ResetFrameTime(fSampleRate, callback_usecs, fPeriodUsecs); | |||||
} | } | ||||
void JackEngineControl::ReadFrameTime(JackTimer* timer) | void JackEngineControl::ReadFrameTime(JackTimer* timer) | ||||
{ | { | ||||
fFrameTimer.ReadFrameTime(timer); | |||||
fFrameTimer.ReadFrameTime(timer); | |||||
} | } | ||||
// Private | // Private | ||||
@@ -76,8 +76,8 @@ void JackEngineControl::CalcCPULoad(JackClientInterface** table, JackGraphManage | |||||
for (int i = REAL_REFNUM; i < CLIENT_NUM; i++) { | for (int i = REAL_REFNUM; i < CLIENT_NUM; i++) { | ||||
JackClientInterface* client = table[i]; | JackClientInterface* client = table[i]; | ||||
JackClientTiming* timing = manager->GetClientTiming(i); | |||||
if (client && client->GetClientControl()->fActive && timing->fStatus == Finished) { | |||||
JackClientTiming* timing = manager->GetClientTiming(i); | |||||
if (client && client->GetClientControl()->fActive && timing->fStatus == Finished) { | |||||
lastCycleEnd = MAX(lastCycleEnd, timing->fFinishedAt); | lastCycleEnd = MAX(lastCycleEnd, timing->fFinishedAt); | ||||
} | } | ||||
} | } | ||||
@@ -131,9 +131,9 @@ void JackEngineControl::GetTimeMeasure(JackClientInterface** table, JackGraphMan | |||||
for (int i = 0; i < CLIENT_NUM; i++) { | for (int i = 0; i < CLIENT_NUM; i++) { | ||||
JackClientInterface* client = table[i]; | JackClientInterface* client = table[i]; | ||||
JackClientTiming* timing = manager->GetClientTiming(i); | |||||
JackClientTiming* timing = manager->GetClientTiming(i); | |||||
if (client && client->GetClientControl()->fActive) { | if (client && client->GetClientControl()->fActive) { | ||||
fMeasure[pos].fClientTable[i].fRefNum = i; | |||||
fMeasure[pos].fClientTable[i].fRefNum = i; | |||||
fMeasure[pos].fClientTable[i].fSignaledAt = timing->fSignaledAt; | fMeasure[pos].fClientTable[i].fSignaledAt = timing->fSignaledAt; | ||||
fMeasure[pos].fClientTable[i].fAwakeAt = timing->fAwakeAt; | fMeasure[pos].fClientTable[i].fAwakeAt = timing->fAwakeAt; | ||||
fMeasure[pos].fClientTable[i].fFinishedAt = timing->fFinishedAt; | fMeasure[pos].fClientTable[i].fFinishedAt = timing->fFinishedAt; | ||||
@@ -42,7 +42,7 @@ class JackGraphManager; | |||||
struct JackTimingMeasureClient | struct JackTimingMeasureClient | ||||
{ | { | ||||
int fRefNum; | |||||
int fRefNum; | |||||
jack_time_t fSignaledAt; | jack_time_t fSignaledAt; | ||||
jack_time_t fAwakeAt; | jack_time_t fAwakeAt; | ||||
jack_time_t fFinishedAt; | jack_time_t fFinishedAt; | ||||
@@ -55,7 +55,7 @@ struct JackTimingMeasureClient | |||||
struct JackTimingMeasure | struct JackTimingMeasure | ||||
{ | { | ||||
unsigned int fAudioCycle; | |||||
unsigned int fAudioCycle; | |||||
jack_time_t fEngineTime; | jack_time_t fEngineTime; | ||||
JackTimingMeasureClient fClientTable[CLIENT_NUM]; | JackTimingMeasureClient fClientTable[CLIENT_NUM]; | ||||
}; | }; | ||||
@@ -66,81 +66,81 @@ struct JackTimingMeasure | |||||
struct JackEngineControl : public JackShmMem | struct JackEngineControl : public JackShmMem | ||||
{ | { | ||||
// Shared state | |||||
// Shared state | |||||
jack_nframes_t fBufferSize; | jack_nframes_t fBufferSize; | ||||
jack_nframes_t fSampleRate; | jack_nframes_t fSampleRate; | ||||
bool fSyncMode; | |||||
bool fTemporary; | |||||
bool fSyncMode; | |||||
bool fTemporary; | |||||
jack_time_t fPeriodUsecs; | jack_time_t fPeriodUsecs; | ||||
jack_time_t fTimeOutUsecs; | jack_time_t fTimeOutUsecs; | ||||
bool fTimeOut; | |||||
bool fRealTime; | |||||
int fPriority; | |||||
char fServerName[64]; | |||||
bool fTimeOut; | |||||
bool fRealTime; | |||||
int fPriority; | |||||
char fServerName[64]; | |||||
JackTransportEngine fTransport; | JackTransportEngine fTransport; | ||||
bool fVerbose; | bool fVerbose; | ||||
// Timing | |||||
JackTimingMeasure fMeasure[TIME_POINTS]; | |||||
jack_time_t fLastTime; | |||||
jack_time_t fCurTime; | |||||
jack_time_t fProcessTime; | |||||
jack_time_t fLastProcessTime; | |||||
jack_time_t fSpareUsecs; | |||||
jack_time_t fMaxUsecs; | |||||
unsigned int fAudioCycle; | |||||
jack_time_t fRollingClientUsecs[JACK_ENGINE_ROLLING_COUNT]; | |||||
int fRollingClientUsecsCnt; | |||||
int fRollingClientUsecsIndex; | |||||
int fRollingInterval; | |||||
float fCPULoad; | |||||
// Fos OSX thread | |||||
// Timing | |||||
JackTimingMeasure fMeasure[TIME_POINTS]; | |||||
jack_time_t fLastTime; | |||||
jack_time_t fCurTime; | |||||
jack_time_t fProcessTime; | |||||
jack_time_t fLastProcessTime; | |||||
jack_time_t fSpareUsecs; | |||||
jack_time_t fMaxUsecs; | |||||
unsigned int fAudioCycle; | |||||
jack_time_t fRollingClientUsecs[JACK_ENGINE_ROLLING_COUNT]; | |||||
int fRollingClientUsecsCnt; | |||||
int fRollingClientUsecsIndex; | |||||
int fRollingInterval; | |||||
float fCPULoad; | |||||
// Fos OSX thread | |||||
UInt64 fPeriod; | UInt64 fPeriod; | ||||
UInt64 fComputation; | UInt64 fComputation; | ||||
UInt64 fConstraint; | UInt64 fConstraint; | ||||
// Timer | |||||
JackFrameTimer fFrameTimer; | |||||
JackEngineControl(bool sync, bool temporary, long timeout, bool rt, long priority, bool verbose, const char* server_name) | |||||
{ | |||||
fSyncMode = sync; | |||||
fTemporary = temporary; | |||||
fTimeOut = (timeout > 0); | |||||
fTimeOutUsecs = timeout * 1000; | |||||
fRealTime = rt; | |||||
fPriority = priority; | |||||
fVerbose = verbose; | |||||
fLastTime = 0; | |||||
fCurTime = 0; | |||||
fProcessTime = 0; | |||||
fLastProcessTime = 0; | |||||
fSpareUsecs = 0; | |||||
fMaxUsecs = 0; | |||||
fAudioCycle = 0; | |||||
ClearTimeMeasures(); | |||||
ResetRollingUsecs(); | |||||
snprintf(fServerName, sizeof(fServerName), server_name); | |||||
} | |||||
~JackEngineControl() | |||||
{} | |||||
// Cycle | |||||
void CycleBegin(JackClientInterface** table, JackGraphManager* manager, jack_time_t callback_usecs); | |||||
void CycleEnd(JackClientInterface** table); | |||||
// Timer | |||||
void InitFrameTime(); | |||||
void ResetFrameTime(jack_time_t callback_usecs); | |||||
void ReadFrameTime(JackTimer* timer); | |||||
// Private | |||||
void CalcCPULoad(JackClientInterface** table, JackGraphManager* manager); | |||||
void GetTimeMeasure(JackClientInterface** table, JackGraphManager* manager, jack_time_t callback_usecs); | |||||
void ClearTimeMeasures(); | |||||
void ResetRollingUsecs(); | |||||
// Timer | |||||
JackFrameTimer fFrameTimer; | |||||
JackEngineControl(bool sync, bool temporary, long timeout, bool rt, long priority, bool verbose, const char* server_name) | |||||
{ | |||||
fSyncMode = sync; | |||||
fTemporary = temporary; | |||||
fTimeOut = (timeout > 0); | |||||
fTimeOutUsecs = timeout * 1000; | |||||
fRealTime = rt; | |||||
fPriority = priority; | |||||
fVerbose = verbose; | |||||
fLastTime = 0; | |||||
fCurTime = 0; | |||||
fProcessTime = 0; | |||||
fLastProcessTime = 0; | |||||
fSpareUsecs = 0; | |||||
fMaxUsecs = 0; | |||||
fAudioCycle = 0; | |||||
ClearTimeMeasures(); | |||||
ResetRollingUsecs(); | |||||
snprintf(fServerName, sizeof(fServerName), server_name); | |||||
} | |||||
~JackEngineControl() | |||||
{} | |||||
// Cycle | |||||
void CycleBegin(JackClientInterface** table, JackGraphManager* manager, jack_time_t callback_usecs); | |||||
void CycleEnd(JackClientInterface** table); | |||||
// Timer | |||||
void InitFrameTime(); | |||||
void ResetFrameTime(jack_time_t callback_usecs); | |||||
void ReadFrameTime(JackTimer* timer); | |||||
// Private | |||||
void CalcCPULoad(JackClientInterface** table, JackGraphManager* manager); | |||||
void GetTimeMeasure(JackClientInterface** table, JackGraphManager* manager, jack_time_t callback_usecs); | |||||
void ClearTimeMeasures(); | |||||
void ResetRollingUsecs(); | |||||
}; | }; | ||||
} // end of namespace | } // end of namespace | ||||
@@ -1,6 +1,6 @@ | |||||
/* | /* | ||||
Copyright (C) 2001 Paul Davis | Copyright (C) 2001 Paul Davis | ||||
Copyright (C) 2004-2008 Grame | |||||
Copyright (C) 2004-2008 Grame | |||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
it under the terms of the GNU General Public License as published by | it under the terms of the GNU General Public License as published by | ||||
@@ -30,8 +30,8 @@ extern "C" | |||||
#endif | #endif | ||||
#ifdef WIN32 | #ifdef WIN32 | ||||
#define vsnprintf _vsnprintf | |||||
#define snprintf _snprintf | |||||
#define vsnprintf _vsnprintf | |||||
#define snprintf _snprintf | |||||
#endif | #endif | ||||
EXPORT void jack_error(const char *fmt, ...); | EXPORT void jack_error(const char *fmt, ...); | ||||
@@ -39,8 +39,8 @@ extern "C" | |||||
EXPORT void JackLog(const char *fmt, ...); | EXPORT void JackLog(const char *fmt, ...); | ||||
extern int jack_verbose; | extern int jack_verbose; | ||||
extern void (*jack_error_callback)(const char *desc); | |||||
extern void (*jack_error_callback)(const char *desc); | |||||
#ifdef __cplusplus | #ifdef __cplusplus | ||||
} | } | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2004-2005 Grame | |||||
Copyright (C) 2004-2005 Grame | |||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
it under the terms of the GNU General Public License as published by | it under the terms of the GNU General Public License as published by | ||||
@@ -21,9 +21,9 @@ This program is free software; you can redistribute it and/or modify | |||||
#define __JackExports__ | #define __JackExports__ | ||||
#ifdef WIN32 | #ifdef WIN32 | ||||
#define EXPORT __declspec(dllexport) | |||||
#define EXPORT __declspec(dllexport) | |||||
#else | #else | ||||
#define EXPORT | |||||
#define EXPORT | |||||
#endif | #endif | ||||
#endif | #endif | ||||
@@ -1,7 +1,7 @@ | |||||
/* | /* | ||||
Copyright (C) 2001-2003 Paul Davis | Copyright (C) 2001-2003 Paul Davis | ||||
Copyright (C) 2004-2008 Grame | Copyright (C) 2004-2008 Grame | ||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
it under the terms of the GNU General Public License as published by | it under the terms of the GNU General Public License as published by | ||||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2004-2008 Grame | |||||
Copyright (C) 2004-2008 Grame | |||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
it under the terms of the GNU General Public License as published by | it under the terms of the GNU General Public License as published by | ||||
@@ -37,12 +37,12 @@ bool JackFifo::Signal() | |||||
{ | { | ||||
bool res; | bool res; | ||||
char c = 0; | char c = 0; | ||||
if (fFifo < 0) { | |||||
jack_error("JackFifo::Signal name = %s already desallocated!!", fName); | |||||
return false; | |||||
} | |||||
if (fFifo < 0) { | |||||
jack_error("JackFifo::Signal name = %s already desallocated!!", fName); | |||||
return false; | |||||
} | |||||
if (fFlush) | if (fFlush) | ||||
return true; | return true; | ||||
@@ -56,11 +56,11 @@ bool JackFifo::SignalAll() | |||||
{ | { | ||||
bool res; | bool res; | ||||
char c = 0; | char c = 0; | ||||
if (fFifo < 0) { | |||||
jack_error("JackFifo::SignalAll name = %s already desallocated!!", fName); | |||||
return false; | |||||
} | |||||
if (fFifo < 0) { | |||||
jack_error("JackFifo::SignalAll name = %s already desallocated!!", fName); | |||||
return false; | |||||
} | |||||
if (fFlush) | if (fFlush) | ||||
return true; | return true; | ||||
@@ -75,11 +75,11 @@ bool JackFifo::Wait() | |||||
{ | { | ||||
bool res; | bool res; | ||||
char c; | char c; | ||||
if (fFifo < 0) { | if (fFifo < 0) { | ||||
jack_error("JackFifo::Wait name = %s already desallocated!!", fName); | |||||
return false; | |||||
} | |||||
jack_error("JackFifo::Wait name = %s already desallocated!!", fName); | |||||
return false; | |||||
} | |||||
if ((res = (read(fFifo, &c, sizeof(c)) != sizeof(c)))) { | if ((res = (read(fFifo, &c, sizeof(c)) != sizeof(c)))) { | ||||
jack_error("JackFifo::Wait name = %s err = %s", fName, strerror(errno)); | jack_error("JackFifo::Wait name = %s err = %s", fName, strerror(errno)); | ||||
@@ -93,7 +93,7 @@ bool JackFifo::TimedWait(long usec) | |||||
{ | { | ||||
return Wait(); | return Wait(); | ||||
} | } | ||||
#else | |||||
#else | |||||
// Does not work on OSX ?? | // Does not work on OSX ?? | ||||
bool JackFifo::TimedWait(long usec) | bool JackFifo::TimedWait(long usec) | ||||
{ | { | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2004-2008 Grame | |||||
Copyright (C) 2004-2008 Grame | |||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
it under the terms of the GNU General Public License as published by | it under the terms of the GNU General Public License as published by | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2004-2008 Grame | Copyright (C) 2004-2008 Grame | ||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2004-2008 Grame | Copyright (C) 2004-2008 Grame | ||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
@@ -47,11 +47,11 @@ struct JackTimer | |||||
JackTimer(); | JackTimer(); | ||||
~JackTimer() | ~JackTimer() | ||||
{} | {} | ||||
}; | }; | ||||
/*! | /*! | ||||
\brief A class using the JackAtomicState to manage jack time. | |||||
\brief A class using the JackAtomicState to manage jack time. | |||||
*/ | */ | ||||
class JackFrameTimer : public JackAtomicState<JackTimer> | class JackFrameTimer : public JackAtomicState<JackTimer> | ||||
@@ -60,7 +60,7 @@ class JackFrameTimer : public JackAtomicState<JackTimer> | |||||
bool fFirstWakeUp; | bool fFirstWakeUp; | ||||
void IncFrameTimeAux(jack_nframes_t nframes, jack_time_t callback_usecs, jack_time_t period_usecs); | void IncFrameTimeAux(jack_nframes_t nframes, jack_time_t callback_usecs, jack_time_t period_usecs); | ||||
void InitFrameTimeAux(jack_time_t callback_usecs, jack_time_t period_usecs); | |||||
void InitFrameTimeAux(jack_time_t callback_usecs, jack_time_t period_usecs); | |||||
public: | public: | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2004-2008 Grame | Copyright (C) 2004-2008 Grame | ||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
@@ -19,7 +19,7 @@ JackEngine.cpp | |||||
*/ | */ | ||||
#ifdef WIN32 | |||||
#ifdef WIN32 | |||||
#pragma warning (disable : 4786) | #pragma warning (disable : 4786) | ||||
#endif | #endif | ||||
@@ -34,7 +34,7 @@ int JackFreewheelDriver::Process() | |||||
{ | { | ||||
if (fIsMaster) { | if (fIsMaster) { | ||||
JackLog("JackFreewheelDriver::Process master %lld\n", fEngineControl->fTimeOutUsecs); | JackLog("JackFreewheelDriver::Process master %lld\n", fEngineControl->fTimeOutUsecs); | ||||
fLastWaitUst = GetMicroSeconds(); | |||||
fLastWaitUst = GetMicroSeconds(); | |||||
fEngine->Process(fLastWaitUst); | fEngine->Process(fLastWaitUst); | ||||
fGraphManager->ResumeRefNum(fClientControl, fSynchroTable); // Signal all clients | fGraphManager->ResumeRefNum(fClientControl, fSynchroTable); // Signal all clients | ||||
if (fGraphManager->SuspendRefNum(fClientControl, fSynchroTable, 10 * 1000000) < 0) // Wait for all clients to finish for 10 sec | if (fGraphManager->SuspendRefNum(fClientControl, fSynchroTable, 10 * 1000000) < 0) // Wait for all clients to finish for 10 sec | ||||
@@ -44,8 +44,8 @@ int JackFreewheelDriver::Process() | |||||
if (fEngineControl->fSyncMode) { | if (fEngineControl->fSyncMode) { | ||||
if (fGraphManager->SuspendRefNum(fClientControl, fSynchroTable, fEngineControl->fTimeOutUsecs) < 0) { | if (fGraphManager->SuspendRefNum(fClientControl, fSynchroTable, fEngineControl->fTimeOutUsecs) < 0) { | ||||
jack_error("JackFreewheelDriver::ProcessSync SuspendRefNum error"); | jack_error("JackFreewheelDriver::ProcessSync SuspendRefNum error"); | ||||
return -1; | |||||
} | |||||
return -1; | |||||
} | |||||
} | } | ||||
} | } | ||||
return 0; | return 0; | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2004-2008 Grame | Copyright (C) 2004-2008 Grame | ||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
@@ -44,8 +44,8 @@ class JackFreewheelDriver : public JackDriver | |||||
{ | { | ||||
return false; | return false; | ||||
} | } | ||||
int Process(); | |||||
int Process(); | |||||
}; | }; | ||||
} // end of namespace | } // end of namespace | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2004-2008 Grame | |||||
Copyright (C) 2004-2008 Grame | |||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
it under the terms of the GNU General Public License as published by | it under the terms of the GNU General Public License as published by | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2004-2008 Grame | |||||
Copyright (C) 2004-2008 Grame | |||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
it under the terms of the GNU General Public License as published by | it under the terms of the GNU General Public License as published by | ||||
@@ -38,7 +38,7 @@ class JackEngine; | |||||
/*! | /*! | ||||
\brief Factory description | \brief Factory description | ||||
\todo possibly use in a dynamic way to test different communication/synchro implementations. | \todo possibly use in a dynamic way to test different communication/synchro implementations. | ||||
*/ | */ | ||||
@@ -230,18 +230,18 @@ class JackGlobals | |||||
{ | { | ||||
JackLog("JackGlobals InitServer\n"); | JackLog("JackGlobals InitServer\n"); | ||||
if (!fInstance) { | if (!fInstance) { | ||||
#ifdef __APPLE__ | |||||
#ifdef __APPLE__ | |||||
fInstance = new JackFactoryOSXServer(); | fInstance = new JackFactoryOSXServer(); | ||||
#endif | |||||
#endif | |||||
#ifdef WIN32 | |||||
fInstance = new JackFactoryWindowsServer(); | |||||
#endif | |||||
#ifdef WIN32 | |||||
fInstance = new JackFactoryWindowsServer(); | |||||
#endif | |||||
#ifdef __linux__ | |||||
fInstance = new JackFactoryLinuxServer(); | |||||
#endif | |||||
#ifdef __linux__ | |||||
fInstance = new JackFactoryLinuxServer(); | |||||
#endif | |||||
} | } | ||||
} | } | ||||
@@ -250,18 +250,18 @@ class JackGlobals | |||||
{ | { | ||||
JackLog("JackGlobals InitClient\n"); | JackLog("JackGlobals InitClient\n"); | ||||
if (!fInstance) { | if (!fInstance) { | ||||
#ifdef __APPLE__ | |||||
#ifdef __APPLE__ | |||||
fInstance = new JackFactoryOSXClient(); | fInstance = new JackFactoryOSXClient(); | ||||
#endif | |||||
#endif | |||||
#ifdef WIN32 | |||||
#ifdef WIN32 | |||||
fInstance = new JackFactoryWindowsClient(); | fInstance = new JackFactoryWindowsClient(); | ||||
#endif | |||||
#endif | |||||
#ifdef __linux__ | |||||
#ifdef __linux__ | |||||
fInstance = new JackFactoryLinuxClient(); | fInstance = new JackFactoryLinuxClient(); | ||||
#endif | |||||
#endif | |||||
} | } | ||||
} | } | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2004-2008 Grame | |||||
Copyright (C) 2004-2008 Grame | |||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
it under the terms of the GNU General Public License as published by | it under the terms of the GNU General Public License as published by | ||||
@@ -70,7 +70,7 @@ namespace Jack | |||||
JackSynchro* JackFactoryWindowsClient::MakeSynchro() | JackSynchro* JackFactoryWindowsClient::MakeSynchro() | ||||
{ | { | ||||
return new JackWinSemaphore(); | |||||
return new JackWinSemaphore(); | |||||
} | } | ||||
JackServerNotifyChannelInterface* JackFactoryWindowsClient::MakeServerNotifyChannel() | JackServerNotifyChannelInterface* JackFactoryWindowsClient::MakeServerNotifyChannel() | ||||
@@ -221,7 +221,7 @@ JackThread* JackFactoryLinuxClient::MakeThread(JackRunnableInterface* runnable) | |||||
#if defined(__APPLE__) | #if defined(__APPLE__) | ||||
#if defined(MACH_RPC_MACH_SEMA) | |||||
#if defined(MACH_RPC_MACH_SEMA) | |||||
// Mach RPC + Mach Semaphore | // Mach RPC + Mach Semaphore | ||||
JackSynchro* JackFactoryOSXClient::MakeSynchro() | JackSynchro* JackFactoryOSXClient::MakeSynchro() | ||||
{ | { | ||||
@@ -259,7 +259,7 @@ JackThread* JackFactoryOSXClient::MakeThread(JackRunnableInterface* runnable) | |||||
} | } | ||||
#endif | #endif | ||||
#if defined(SOCKET_RPC_POSIX_SEMA) | |||||
#if defined(SOCKET_RPC_POSIX_SEMA) | |||||
// Socket RPC + Posix Semaphore | // Socket RPC + Posix Semaphore | ||||
JackSynchro* JackFactoryOSXClient::MakeSynchro() | JackSynchro* JackFactoryOSXClient::MakeSynchro() | ||||
{ | { | ||||
@@ -297,7 +297,7 @@ JackThread* JackFactoryOSXClient::MakeThread(JackRunnableInterface* runnable) | |||||
} | } | ||||
#endif | #endif | ||||
#if defined(SOCKET_RPC_FIFO_SEMA) | |||||
#if defined(SOCKET_RPC_FIFO_SEMA) | |||||
// Socket RPC + Fifo Semaphore | // Socket RPC + Fifo Semaphore | ||||
JackSynchro* JackFactoryOSXClient::MakeSynchro() | JackSynchro* JackFactoryOSXClient::MakeSynchro() | ||||
{ | { | ||||
@@ -336,7 +336,7 @@ JackThread* JackFactoryOSXClient::MakeThread(JackRunnableInterface* runnable) | |||||
#endif | #endif | ||||
#if defined(MACH_RPC_FIFO_SEMA) | |||||
#if defined(MACH_RPC_FIFO_SEMA) | |||||
// Mach RPC + Fifo Semaphore | // Mach RPC + Fifo Semaphore | ||||
JackSynchro* JackFactoryOSXClient::MakeSynchro() | JackSynchro* JackFactoryOSXClient::MakeSynchro() | ||||
{ | { | ||||
@@ -374,7 +374,7 @@ JackThread* JackFactoryOSXClient::MakeThread(JackRunnableInterface* runnable) | |||||
} | } | ||||
#endif | #endif | ||||
#if defined(MACH_RPC_POSIX_SEMA) | |||||
#if defined(MACH_RPC_POSIX_SEMA) | |||||
// Mach RPC + Posix Semaphore | // Mach RPC + Posix Semaphore | ||||
JackSynchro* JackFactoryOSXClient::MakeSynchro() | JackSynchro* JackFactoryOSXClient::MakeSynchro() | ||||
{ | { | ||||
@@ -412,7 +412,7 @@ JackThread* JackFactoryOSXClient::MakeThread(JackRunnableInterface* runnable) | |||||
} | } | ||||
#endif | #endif | ||||
#if defined SOCKET_RPC_MACH_SEMA | |||||
#if defined SOCKET_RPC_MACH_SEMA | |||||
// Socket RPC + Mach Semaphore | // Socket RPC + Mach Semaphore | ||||
JackSynchro* JackFactoryOSXClient::MakeSynchro() | JackSynchro* JackFactoryOSXClient::MakeSynchro() | ||||
{ | { | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2004-2008 Grame | |||||
Copyright (C) 2004-2008 Grame | |||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
it under the terms of the GNU General Public License as published by | it under the terms of the GNU General Public License as published by | ||||
@@ -17,7 +17,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||||
*/ | */ | ||||
#ifdef WIN32 | |||||
#ifdef WIN32 | |||||
#pragma warning (disable : 4786) | #pragma warning (disable : 4786) | ||||
#endif | #endif | ||||
@@ -80,7 +80,7 @@ namespace Jack | |||||
#ifdef WIN32 | #ifdef WIN32 | ||||
JackSynchro* JackFactoryWindowsServer::MakeSynchro() | JackSynchro* JackFactoryWindowsServer::MakeSynchro() | ||||
{ | { | ||||
return new JackWinSemaphore(); | |||||
return new JackWinSemaphore(); | |||||
} | } | ||||
JackServerNotifyChannelInterface* JackFactoryWindowsServer::MakeServerNotifyChannel() | JackServerNotifyChannelInterface* JackFactoryWindowsServer::MakeServerNotifyChannel() | ||||
@@ -231,7 +231,7 @@ JackThread* JackFactoryLinuxServer::MakeThread(JackRunnableInterface* runnable) | |||||
#if defined(__APPLE__) | #if defined(__APPLE__) | ||||
#if defined(MACH_RPC_MACH_SEMA) | |||||
#if defined(MACH_RPC_MACH_SEMA) | |||||
// Mach RPC + Mach Semaphore | // Mach RPC + Mach Semaphore | ||||
JackSynchro* JackFactoryOSXServer::MakeSynchro() | JackSynchro* JackFactoryOSXServer::MakeSynchro() | ||||
{ | { | ||||
@@ -269,7 +269,7 @@ JackThread* JackFactoryOSXServer::MakeThread(JackRunnableInterface* runnable) | |||||
} | } | ||||
#endif | #endif | ||||
#if defined(SOCKET_RPC_POSIX_SEMA) | |||||
#if defined(SOCKET_RPC_POSIX_SEMA) | |||||
// Socket RPC + Posix Semaphore | // Socket RPC + Posix Semaphore | ||||
JackSynchro* JackFactoryOSXServer::MakeSynchro() | JackSynchro* JackFactoryOSXServer::MakeSynchro() | ||||
{ | { | ||||
@@ -307,7 +307,7 @@ JackThread* JackFactoryOSXServer::MakeThread(JackRunnableInterface* runnable) | |||||
} | } | ||||
#endif | #endif | ||||
#if defined(SOCKET_RPC_FIFO_SEMA) | |||||
#if defined(SOCKET_RPC_FIFO_SEMA) | |||||
// Socket RPC + Fifo Semaphore | // Socket RPC + Fifo Semaphore | ||||
JackSynchro* JackFactoryOSXServer::MakeSynchro() | JackSynchro* JackFactoryOSXServer::MakeSynchro() | ||||
{ | { | ||||
@@ -345,7 +345,7 @@ JackThread* JackFactoryOSXServer::MakeThread(JackRunnableInterface* runnable) | |||||
} | } | ||||
#endif | #endif | ||||
#if defined(MACH_RPC_FIFO_SEMA) | |||||
#if defined(MACH_RPC_FIFO_SEMA) | |||||
// Mach RPC + Fifo Semaphore | // Mach RPC + Fifo Semaphore | ||||
JackSynchro* JackFactoryOSXServer::MakeSynchro() | JackSynchro* JackFactoryOSXServer::MakeSynchro() | ||||
{ | { | ||||
@@ -383,7 +383,7 @@ JackThread* JackFactoryOSXServer::MakeThread(JackRunnableInterface* runnable) | |||||
} | } | ||||
#endif | #endif | ||||
#if defined(MACH_RPC_POSIX_SEMA) | |||||
#if defined(MACH_RPC_POSIX_SEMA) | |||||
// Mach RPC + Posix Semaphore | // Mach RPC + Posix Semaphore | ||||
JackSynchro* JackFactoryOSXServer::MakeSynchro() | JackSynchro* JackFactoryOSXServer::MakeSynchro() | ||||
{ | { | ||||
@@ -421,7 +421,7 @@ JackThread* JackFactoryOSXServer::MakeThread(JackRunnableInterface* runnable) | |||||
} | } | ||||
#endif | #endif | ||||
#if defined(SOCKET_RPC_MACH_SEMA) | |||||
#if defined(SOCKET_RPC_MACH_SEMA) | |||||
// Socket RPC + Mac Semaphore | // Socket RPC + Mac Semaphore | ||||
JackSynchro* JackFactoryOSXServer::MakeSynchro() | JackSynchro* JackFactoryOSXServer::MakeSynchro() | ||||
{ | { | ||||
@@ -1,6 +1,6 @@ | |||||
/* | /* | ||||
Copyright (C) 2001 Paul Davis | Copyright (C) 2001 Paul Davis | ||||
Copyright (C) 2004-2008 Grame | |||||
Copyright (C) 2004-2008 Grame | |||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
it under the terms of the GNU General Public License as published by | it under the terms of the GNU General Public License as published by | ||||
@@ -113,7 +113,7 @@ int JackGraphManager::SuspendRefNum(JackClientControl* control, JackSynchro** ta | |||||
JackClientTiming* JackGraphManager::GetClientTiming(int ref) | JackClientTiming* JackGraphManager::GetClientTiming(int ref) | ||||
{ | { | ||||
return &fClientTiming[ref]; | |||||
return &fClientTiming[ref]; | |||||
} | } | ||||
// Server | // Server | ||||
@@ -171,19 +171,19 @@ void* JackGraphManager::GetBuffer(jack_port_id_t port_index, jack_nframes_t buff | |||||
assert(manager->GetPort(port_index, 0) != port_index); // Check recursion | assert(manager->GetPort(port_index, 0) != port_index); // Check recursion | ||||
return GetBuffer(manager->GetPort(port_index, 0), buffer_size); | return GetBuffer(manager->GetPort(port_index, 0), buffer_size); | ||||
} else { // Multiple connections | } else { // Multiple connections | ||||
const jack_int_t* connections = manager->GetConnections(port_index); | const jack_int_t* connections = manager->GetConnections(port_index); | ||||
void* buffers[CONNECTION_NUM]; | |||||
jack_port_id_t src_index; | |||||
int i; | |||||
for (i = 0; (i < CONNECTION_NUM) && ((src_index = connections[i]) != EMPTY); i++) { | |||||
void* buffers[CONNECTION_NUM]; | |||||
jack_port_id_t src_index; | |||||
int i; | |||||
for (i = 0; (i < CONNECTION_NUM) && ((src_index = connections[i]) != EMPTY); i++) { | |||||
AssertPort(src_index); | AssertPort(src_index); | ||||
buffers[i] = GetBuffer(src_index, buffer_size); | |||||
buffers[i] = GetBuffer(src_index, buffer_size); | |||||
} | } | ||||
JackPort* port = GetPort(port_index); | |||||
port->MixBuffers(buffers, i, buffer_size); | |||||
JackPort* port = GetPort(port_index); | |||||
port->MixBuffers(buffers, i, buffer_size); | |||||
return port->GetBuffer(); | return port->GetBuffer(); | ||||
} | } | ||||
} | } | ||||
@@ -226,10 +226,10 @@ jack_nframes_t JackGraphManager::ComputeTotalLatencyAux(jack_port_id_t port_inde | |||||
if (hop_count > 8) | if (hop_count > 8) | ||||
return GetPort(port_index)->GetLatency(); | return GetPort(port_index)->GetLatency(); | ||||
for (int i = 0; (i < CONNECTION_NUM) && ((dst_index = connections[i]) != EMPTY); i++) { | for (int i = 0; (i < CONNECTION_NUM) && ((dst_index = connections[i]) != EMPTY); i++) { | ||||
if (src_port_index != dst_index) { | if (src_port_index != dst_index) { | ||||
AssertPort(dst_index); | |||||
AssertPort(dst_index); | |||||
JackPort* dst_port = GetPort(dst_index); | JackPort* dst_port = GetPort(dst_index); | ||||
jack_nframes_t this_latency = (dst_port->fFlags & JackPortIsTerminal) | jack_nframes_t this_latency = (dst_port->fFlags & JackPortIsTerminal) | ||||
? dst_port->GetLatency() | ? dst_port->GetLatency() | ||||
@@ -237,7 +237,7 @@ jack_nframes_t JackGraphManager::ComputeTotalLatencyAux(jack_port_id_t port_inde | |||||
max_latency = MAX(max_latency, this_latency); | max_latency = MAX(max_latency, this_latency); | ||||
} | } | ||||
} | } | ||||
return max_latency + GetPort(port_index)->GetLatency(); | return max_latency + GetPort(port_index)->GetLatency(); | ||||
} | } | ||||
@@ -246,38 +246,38 @@ int JackGraphManager::ComputeTotalLatency(jack_port_id_t port_index) | |||||
{ | { | ||||
UInt16 cur_index; | UInt16 cur_index; | ||||
UInt16 next_index; | UInt16 next_index; | ||||
JackPort* port = GetPort(port_index); | |||||
JackPort* port = GetPort(port_index); | |||||
AssertPort(port_index); | AssertPort(port_index); | ||||
do { | do { | ||||
cur_index = GetCurrentIndex(); | cur_index = GetCurrentIndex(); | ||||
port->fTotalLatency = ComputeTotalLatencyAux(port_index, port_index, ReadCurrentState(), 0); | port->fTotalLatency = ComputeTotalLatencyAux(port_index, port_index, ReadCurrentState(), 0); | ||||
next_index = GetCurrentIndex(); | next_index = GetCurrentIndex(); | ||||
} while (cur_index != next_index); // Until a coherent state has been read | } while (cur_index != next_index); // Until a coherent state has been read | ||||
JackLog("JackGraphManager::GetTotalLatency port_index = %ld total latency = %ld\n", port_index, port->fTotalLatency); | |||||
return 0; | |||||
JackLog("JackGraphManager::GetTotalLatency port_index = %ld total latency = %ld\n", port_index, port->fTotalLatency); | |||||
return 0; | |||||
} | } | ||||
// Client | // Client | ||||
int JackGraphManager::ComputeTotalLatencies() | int JackGraphManager::ComputeTotalLatencies() | ||||
{ | { | ||||
jack_port_id_t port_index; | |||||
for (port_index = FIRST_AVAILABLE_PORT; port_index < PORT_NUM; port_index++) { | |||||
jack_port_id_t port_index; | |||||
for (port_index = FIRST_AVAILABLE_PORT; port_index < PORT_NUM; port_index++) { | |||||
JackPort* port = GetPort(port_index); | JackPort* port = GetPort(port_index); | ||||
if (port->IsUsed()) | |||||
ComputeTotalLatency(port_index); | |||||
} | |||||
return 0; | |||||
if (port->IsUsed()) | |||||
ComputeTotalLatency(port_index); | |||||
} | |||||
return 0; | |||||
} | } | ||||
// Server | // Server | ||||
void JackGraphManager::SetBufferSize(jack_nframes_t buffer_size) | void JackGraphManager::SetBufferSize(jack_nframes_t buffer_size) | ||||
{ | { | ||||
JackLock lock(this); | |||||
JackLock lock (this); | |||||
JackLog("JackGraphManager::SetBufferSize size = %ld\n", (long int)buffer_size); | JackLog("JackGraphManager::SetBufferSize size = %ld\n", (long int)buffer_size); | ||||
jack_port_id_t port_index; | |||||
jack_port_id_t port_index; | |||||
for (port_index = FIRST_AVAILABLE_PORT; port_index < PORT_NUM; port_index++) { | for (port_index = FIRST_AVAILABLE_PORT; port_index < PORT_NUM; port_index++) { | ||||
JackPort* port = GetPort(port_index); | JackPort* port = GetPort(port_index); | ||||
if (port->IsUsed()) | if (port->IsUsed()) | ||||
@@ -296,7 +296,7 @@ jack_port_id_t JackGraphManager::AllocatePortAux(int refnum, const char* port_na | |||||
if (!port->IsUsed()) { | if (!port->IsUsed()) { | ||||
JackLog("JackGraphManager::AllocatePortAux port_index = %ld name = %s type = %s\n", port_index, port_name, port_type); | JackLog("JackGraphManager::AllocatePortAux port_index = %ld name = %s type = %s\n", port_index, port_name, port_type); | ||||
if (!port->Allocate(refnum, port_name, port_type, flags)) | if (!port->Allocate(refnum, port_name, port_type, flags)) | ||||
return NO_PORT; | |||||
return NO_PORT; | |||||
break; | break; | ||||
} | } | ||||
} | } | ||||
@@ -307,7 +307,7 @@ jack_port_id_t JackGraphManager::AllocatePortAux(int refnum, const char* port_na | |||||
// Server | // Server | ||||
jack_port_id_t JackGraphManager::AllocatePort(int refnum, const char* port_name, const char* port_type, JackPortFlags flags, jack_nframes_t buffer_size) | jack_port_id_t JackGraphManager::AllocatePort(int refnum, const char* port_name, const char* port_type, JackPortFlags flags, jack_nframes_t buffer_size) | ||||
{ | { | ||||
JackLock lock(this); | |||||
JackLock lock (this); | |||||
JackConnectionManager* manager = WriteNextStateStart(); | JackConnectionManager* manager = WriteNextStateStart(); | ||||
jack_port_id_t port_index = AllocatePortAux(refnum, port_name, port_type, flags); | jack_port_id_t port_index = AllocatePortAux(refnum, port_name, port_type, flags); | ||||
@@ -322,7 +322,7 @@ jack_port_id_t JackGraphManager::AllocatePort(int refnum, const char* port_name, | |||||
} else { | } else { | ||||
res = manager->AddInputPort(refnum, port_index); | res = manager->AddInputPort(refnum, port_index); | ||||
} | } | ||||
// Insertion failure | |||||
// Insertion failure | |||||
if (res < 0) { | if (res < 0) { | ||||
port->Release(); | port->Release(); | ||||
port_index = NO_PORT; | port_index = NO_PORT; | ||||
@@ -336,7 +336,7 @@ jack_port_id_t JackGraphManager::AllocatePort(int refnum, const char* port_name, | |||||
// Server | // Server | ||||
int JackGraphManager::ReleasePort(int refnum, jack_port_id_t port_index) | int JackGraphManager::ReleasePort(int refnum, jack_port_id_t port_index) | ||||
{ | { | ||||
JackLock lock(this); | |||||
JackLock lock (this); | |||||
JackConnectionManager* manager = WriteNextStateStart(); | JackConnectionManager* manager = WriteNextStateStart(); | ||||
JackPort* port = GetPort(port_index); | JackPort* port = GetPort(port_index); | ||||
int res; | int res; | ||||
@@ -349,25 +349,25 @@ int JackGraphManager::ReleasePort(int refnum, jack_port_id_t port_index) | |||||
res = manager->RemoveInputPort(refnum, port_index); | res = manager->RemoveInputPort(refnum, port_index); | ||||
} | } | ||||
port->Release(); | |||||
port->Release(); | |||||
WriteNextStateStop(); | WriteNextStateStop(); | ||||
return res; | return res; | ||||
} | } | ||||
void JackGraphManager::GetInputPorts(int refnum, jack_int_t* res) | void JackGraphManager::GetInputPorts(int refnum, jack_int_t* res) | ||||
{ | { | ||||
JackConnectionManager* manager = WriteNextStateStart(); | |||||
const jack_int_t* input = manager->GetInputPorts(refnum); | |||||
memcpy(res, input, sizeof(jack_int_t) * PORT_NUM_FOR_CLIENT); | |||||
WriteNextStateStop(); | |||||
JackConnectionManager* manager = WriteNextStateStart(); | |||||
const jack_int_t* input = manager->GetInputPorts(refnum); | |||||
memcpy(res, input, sizeof(jack_int_t) * PORT_NUM_FOR_CLIENT); | |||||
WriteNextStateStop(); | |||||
} | } | ||||
void JackGraphManager::GetOutputPorts(int refnum, jack_int_t* res) | void JackGraphManager::GetOutputPorts(int refnum, jack_int_t* res) | ||||
{ | { | ||||
JackConnectionManager* manager = WriteNextStateStart(); | |||||
const jack_int_t* output = manager->GetOutputPorts(refnum); | |||||
memcpy(res, output, sizeof(jack_int_t) * PORT_NUM_FOR_CLIENT); | |||||
WriteNextStateStop(); | |||||
JackConnectionManager* manager = WriteNextStateStart(); | |||||
const jack_int_t* output = manager->GetOutputPorts(refnum); | |||||
memcpy(res, output, sizeof(jack_int_t) * PORT_NUM_FOR_CLIENT); | |||||
WriteNextStateStop(); | |||||
} | } | ||||
// Server | // Server | ||||
@@ -420,7 +420,7 @@ void JackGraphManager::DisconnectAllInput(jack_port_id_t port_index) | |||||
for (int i = 0; i < PORT_NUM; i++) { | for (int i = 0; i < PORT_NUM; i++) { | ||||
if (manager->IsConnected(i, port_index)) { | if (manager->IsConnected(i, port_index)) { | ||||
JackLog("JackGraphManager::Disconnect i = %ld port_index = %ld\n", i, port_index); | |||||
JackLog("JackGraphManager::Disconnect i = %ld port_index = %ld\n", i, port_index); | |||||
Disconnect(i, port_index); | Disconnect(i, port_index); | ||||
} | } | ||||
} | } | ||||
@@ -434,8 +434,8 @@ void JackGraphManager::DisconnectAllOutput(jack_port_id_t port_index) | |||||
JackConnectionManager* manager = WriteNextStateStart(); | JackConnectionManager* manager = WriteNextStateStart(); | ||||
const jack_int_t* connections = manager->GetConnections(port_index); | const jack_int_t* connections = manager->GetConnections(port_index); | ||||
while (connections[0] != EMPTY) { | |||||
Disconnect(port_index, connections[0]); // Warning : Disconnect shift port to left | |||||
while (connections[0] != EMPTY) { | |||||
Disconnect(port_index, connections[0]); // Warning : Disconnect shift port to left | |||||
} | } | ||||
WriteNextStateStop(); | WriteNextStateStop(); | ||||
} | } | ||||
@@ -447,9 +447,9 @@ int JackGraphManager::DisconnectAll(jack_port_id_t port_index) | |||||
JackPort* port = GetPort(port_index); | JackPort* port = GetPort(port_index); | ||||
if (port->fFlags & JackPortIsOutput) { | if (port->fFlags & JackPortIsOutput) { | ||||
DisconnectAllOutput(port_index); | |||||
DisconnectAllOutput(port_index); | |||||
} else { | } else { | ||||
DisconnectAllInput(port_index); | |||||
DisconnectAllInput(port_index); | |||||
} | } | ||||
return 0; | return 0; | ||||
} | } | ||||
@@ -457,16 +457,16 @@ int JackGraphManager::DisconnectAll(jack_port_id_t port_index) | |||||
// Server | // Server | ||||
void JackGraphManager::GetConnections(jack_port_id_t port_index, jack_int_t* res) | void JackGraphManager::GetConnections(jack_port_id_t port_index, jack_int_t* res) | ||||
{ | { | ||||
JackConnectionManager* manager = WriteNextStateStart(); | |||||
const jack_int_t* connections = manager->GetConnections(port_index); | |||||
memcpy(res, connections, sizeof(jack_int_t) * CONNECTION_NUM); | |||||
WriteNextStateStop(); | |||||
JackConnectionManager* manager = WriteNextStateStart(); | |||||
const jack_int_t* connections = manager->GetConnections(port_index); | |||||
memcpy(res, connections, sizeof(jack_int_t) * CONNECTION_NUM); | |||||
WriteNextStateStop(); | |||||
} | } | ||||
// Server | // Server | ||||
void JackGraphManager::Activate(int refnum) | void JackGraphManager::Activate(int refnum) | ||||
{ | { | ||||
DirectConnect(FREEWHEEL_DRIVER_REFNUM, refnum); | |||||
DirectConnect(FREEWHEEL_DRIVER_REFNUM, refnum); | |||||
DirectConnect(refnum, FREEWHEEL_DRIVER_REFNUM); | DirectConnect(refnum, FREEWHEEL_DRIVER_REFNUM); | ||||
} | } | ||||
@@ -478,16 +478,16 @@ void JackGraphManager::Activate(int refnum) | |||||
// Server | // Server | ||||
void JackGraphManager::Deactivate(int refnum) | void JackGraphManager::Deactivate(int refnum) | ||||
{ | { | ||||
DisconnectAllPorts(refnum); | |||||
// Disconnect only when needed | |||||
DisconnectAllPorts(refnum); | |||||
// Disconnect only when needed | |||||
if (IsDirectConnection(refnum, FREEWHEEL_DRIVER_REFNUM)) { | if (IsDirectConnection(refnum, FREEWHEEL_DRIVER_REFNUM)) { | ||||
DirectDisconnect(refnum, FREEWHEEL_DRIVER_REFNUM); | DirectDisconnect(refnum, FREEWHEEL_DRIVER_REFNUM); | ||||
} else { | } else { | ||||
JackLog("JackServer::Deactivate: client = %ld was not activated \n", refnum); | JackLog("JackServer::Deactivate: client = %ld was not activated \n", refnum); | ||||
} | } | ||||
// Disconnect only when needed | |||||
// Disconnect only when needed | |||||
if (IsDirectConnection(FREEWHEEL_DRIVER_REFNUM, refnum)) { | if (IsDirectConnection(FREEWHEEL_DRIVER_REFNUM, refnum)) { | ||||
DirectDisconnect(FREEWHEEL_DRIVER_REFNUM, refnum); | DirectDisconnect(FREEWHEEL_DRIVER_REFNUM, refnum); | ||||
} else { | } else { | ||||
@@ -532,9 +532,9 @@ int JackGraphManager::Connect(jack_port_id_t port_src, jack_port_id_t port_dst) | |||||
goto end; | goto end; | ||||
} | } | ||||
if (src->fTypeId != dst->fTypeId) { | if (src->fTypeId != dst->fTypeId) { | ||||
jack_error("JackGraphManager::Connect: different port types: port_src = %ld port_dst = %ld", port_src, port_dst); | |||||
res = -1; | |||||
goto end; | |||||
jack_error("JackGraphManager::Connect: different port types: port_src = %ld port_dst = %ld", port_src, port_dst); | |||||
res = -1; | |||||
goto end; | |||||
} | } | ||||
if (manager->IsConnected(port_src, port_dst)) { | if (manager->IsConnected(port_src, port_dst)) { | ||||
jack_error("JackGraphManager::Connect already connected port_src = %ld port_dst = %ld", port_src, port_dst); | jack_error("JackGraphManager::Connect already connected port_src = %ld port_dst = %ld", port_src, port_dst); | ||||
@@ -615,7 +615,7 @@ end: | |||||
int JackGraphManager::IsConnected(jack_port_id_t port_src, jack_port_id_t port_dst) | int JackGraphManager::IsConnected(jack_port_id_t port_src, jack_port_id_t port_dst) | ||||
{ | { | ||||
JackConnectionManager* manager = ReadCurrentState(); | JackConnectionManager* manager = ReadCurrentState(); | ||||
return manager->IsConnected(port_src, port_dst); | |||||
return manager->IsConnected(port_src, port_dst); | |||||
} | } | ||||
// Server | // Server | ||||
@@ -722,11 +722,11 @@ const char** JackGraphManager::GetPortsAux(const char* port_name_pattern, const | |||||
regcomp(&type_regex, type_name_pattern, REG_EXTENDED | REG_NOSUB); | regcomp(&type_regex, type_name_pattern, REG_EXTENDED | REG_NOSUB); | ||||
} | } | ||||
const char** matching_ports = (const char**)malloc(sizeof(char*) * PORT_NUM); | |||||
const char** matching_ports = (const char**)malloc(sizeof(char*) * PORT_NUM); | |||||
for (int i = 0; i < PORT_NUM; i++) { | for (int i = 0; i < PORT_NUM; i++) { | ||||
matching = true; | matching = true; | ||||
JackPort* port = GetPort(i); | |||||
JackPort* port = GetPort(i); | |||||
if (port->IsUsed()) { | if (port->IsUsed()) { | ||||
@@ -741,7 +741,7 @@ const char** JackGraphManager::GetPortsAux(const char* port_name_pattern, const | |||||
matching = false; | matching = false; | ||||
} | } | ||||
} | } | ||||
if (matching && type_name_pattern && type_name_pattern[0]) { | |||||
if (matching && type_name_pattern && type_name_pattern[0]) { | |||||
if (regexec(&type_regex, port->GetType(), 0, NULL, 0)) { | if (regexec(&type_regex, port->GetType(), 0, NULL, 0)) { | ||||
matching = false; | matching = false; | ||||
} | } | ||||
@@ -786,8 +786,8 @@ const char** JackGraphManager::GetPorts(const char* port_name_pattern, const cha | |||||
cur_index = GetCurrentIndex(); | cur_index = GetCurrentIndex(); | ||||
if (matching_ports) { | if (matching_ports) { | ||||
free(matching_ports); | free(matching_ports); | ||||
JackLog("JackGraphManager::GetPorts retry... \n"); | |||||
} | |||||
JackLog("JackGraphManager::GetPorts retry... \n"); | |||||
} | |||||
matching_ports = GetPortsAux(port_name_pattern, type_name_pattern, flags); | matching_ports = GetPortsAux(port_name_pattern, type_name_pattern, flags); | ||||
next_index = GetCurrentIndex(); | next_index = GetCurrentIndex(); | ||||
} while (cur_index != next_index); // Until a coherent state has been read | } while (cur_index != next_index); // Until a coherent state has been read | ||||
@@ -1,6 +1,6 @@ | |||||
/* | /* | ||||
Copyright (C) 2001 Paul Davis | Copyright (C) 2001 Paul Davis | ||||
Copyright (C) 2004-2008 Grame | |||||
Copyright (C) 2004-2008 Grame | |||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
it under the terms of the GNU General Public License as published by | it under the terms of the GNU General Public License as published by | ||||
@@ -40,9 +40,9 @@ class JackGraphManager : public JackShmMem, public JackAtomicState<JackConnectio | |||||
private: | private: | ||||
JackPort fPortArray[PORT_NUM]; | |||||
JackClientTiming fClientTiming[CLIENT_NUM]; | |||||
JackPort fPortArray[PORT_NUM]; | |||||
JackClientTiming fClientTiming[CLIENT_NUM]; | |||||
jack_port_id_t AllocatePortAux(int refnum, const char* port_name, const char* port_type, JackPortFlags flags); | jack_port_id_t AllocatePortAux(int refnum, const char* port_name, const char* port_type, JackPortFlags flags); | ||||
void GetConnectionsAux(JackConnectionManager* manager, const char** res, jack_port_id_t port_index); | void GetConnectionsAux(JackConnectionManager* manager, const char** res, jack_port_id_t port_index); | ||||
const char** GetPortsAux(const char* port_name_pattern, const char* type_name_pattern, unsigned long flags); | const char** GetPortsAux(const char* port_name_pattern, const char* type_name_pattern, unsigned long flags); | ||||
@@ -60,60 +60,60 @@ class JackGraphManager : public JackShmMem, public JackAtomicState<JackConnectio | |||||
void SetBufferSize(jack_nframes_t buffer_size); | void SetBufferSize(jack_nframes_t buffer_size); | ||||
// Ports management | // Ports management | ||||
jack_port_id_t AllocatePort(int refnum, const char* port_name, const char* port_type, JackPortFlags flags, jack_nframes_t buffer_size); | |||||
int ReleasePort(int refnum, jack_port_id_t port_index); | |||||
void GetInputPorts(int refnum, jack_int_t* res); | |||||
void GetOutputPorts(int refnum, jack_int_t* res); | |||||
void RemoveAllPorts(int refnum); | |||||
void DisconnectAllPorts(int refnum); | |||||
JackPort* GetPort(jack_port_id_t index); | |||||
jack_port_id_t GetPort(const char* name); | |||||
int ComputeTotalLatency(jack_port_id_t port_index); | |||||
int ComputeTotalLatencies(); | |||||
int RequestMonitor(jack_port_id_t port_index, bool onoff); | |||||
jack_port_id_t AllocatePort(int refnum, const char* port_name, const char* port_type, JackPortFlags flags, jack_nframes_t buffer_size); | |||||
int ReleasePort(int refnum, jack_port_id_t port_index); | |||||
void GetInputPorts(int refnum, jack_int_t* res); | |||||
void GetOutputPorts(int refnum, jack_int_t* res); | |||||
void RemoveAllPorts(int refnum); | |||||
void DisconnectAllPorts(int refnum); | |||||
JackPort* GetPort(jack_port_id_t index); | |||||
jack_port_id_t GetPort(const char* name); | |||||
int ComputeTotalLatency(jack_port_id_t port_index); | |||||
int ComputeTotalLatencies(); | |||||
int RequestMonitor(jack_port_id_t port_index, bool onoff); | |||||
// Connections management | // Connections management | ||||
int Connect(jack_port_id_t src_index, jack_port_id_t dst_index); | |||||
int Disconnect(jack_port_id_t src_index, jack_port_id_t dst_index); | |||||
int IsConnected(jack_port_id_t port_src, jack_port_id_t port_dst); | |||||
int GetConnectionsNum(jack_port_id_t port_index); | |||||
const char** GetConnections(jack_port_id_t port_index); | |||||
void GetConnections(jack_port_id_t port_index, jack_int_t* connections); // TODO | |||||
const char** GetPorts(const char* port_name_pattern, const char* type_name_pattern, unsigned long flags); | |||||
int CheckPorts(const char* src, const char* dst, jack_port_id_t* src_index, jack_port_id_t* dst_index); | |||||
int CheckPorts(jack_port_id_t port_src, jack_port_id_t port_dst); | |||||
void DisconnectAllInput(jack_port_id_t port_index); | |||||
void DisconnectAllOutput(jack_port_id_t port_index); | |||||
int DisconnectAll(jack_port_id_t port_index); | |||||
bool IsDirectConnection(int ref1, int ref2); | |||||
void DirectConnect(int ref1, int ref2); | |||||
void DirectDisconnect(int ref1, int ref2); | |||||
void Activate(int refnum); | |||||
void Deactivate(int refnum); | |||||
int GetInputRefNum(jack_port_id_t port_index); | |||||
int GetOutputRefNum(jack_port_id_t port_index); | |||||
int Connect(jack_port_id_t src_index, jack_port_id_t dst_index); | |||||
int Disconnect(jack_port_id_t src_index, jack_port_id_t dst_index); | |||||
int IsConnected(jack_port_id_t port_src, jack_port_id_t port_dst); | |||||
int GetConnectionsNum(jack_port_id_t port_index); | |||||
const char** GetConnections(jack_port_id_t port_index); | |||||
void GetConnections(jack_port_id_t port_index, jack_int_t* connections); // TODO | |||||
const char** GetPorts(const char* port_name_pattern, const char* type_name_pattern, unsigned long flags); | |||||
int CheckPorts(const char* src, const char* dst, jack_port_id_t* src_index, jack_port_id_t* dst_index); | |||||
int CheckPorts(jack_port_id_t port_src, jack_port_id_t port_dst); | |||||
void DisconnectAllInput(jack_port_id_t port_index); | |||||
void DisconnectAllOutput(jack_port_id_t port_index); | |||||
int DisconnectAll(jack_port_id_t port_index); | |||||
bool IsDirectConnection(int ref1, int ref2); | |||||
void DirectConnect(int ref1, int ref2); | |||||
void DirectDisconnect(int ref1, int ref2); | |||||
void Activate(int refnum); | |||||
void Deactivate(int refnum); | |||||
int GetInputRefNum(jack_port_id_t port_index); | |||||
int GetOutputRefNum(jack_port_id_t port_index); | |||||
// Buffer management | // Buffer management | ||||
void* GetBuffer(jack_port_id_t port_index, jack_nframes_t frames); | |||||
void* GetBuffer(jack_port_id_t port_index, jack_nframes_t frames); | |||||
// Activation management | // Activation management | ||||
void RunCurrentGraph(); | |||||
bool RunNextGraph(); | |||||
bool IsFinishedGraph(); | |||||
void InitRefNum(int refnum); | |||||
int ResumeRefNum(JackClientControl* control, JackSynchro** table); | |||||
int SuspendRefNum(JackClientControl* control, JackSynchro** table, long usecs); | |||||
JackClientTiming* GetClientTiming(int refnum); | |||||
void RunCurrentGraph(); | |||||
bool RunNextGraph(); | |||||
bool IsFinishedGraph(); | |||||
void InitRefNum(int refnum); | |||||
int ResumeRefNum(JackClientControl* control, JackSynchro** table); | |||||
int SuspendRefNum(JackClientControl* control, JackSynchro** table, long usecs); | |||||
JackClientTiming* GetClientTiming(int refnum); | |||||
void Save(JackConnectionManager* dst); | void Save(JackConnectionManager* dst); | ||||
void Restore(JackConnectionManager* src); | void Restore(JackConnectionManager* src); | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2004-2008 Grame | Copyright (C) 2004-2008 Grame | ||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
@@ -18,7 +18,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||||
*/ | */ | ||||
#ifdef WIN32 | |||||
#ifdef WIN32 | |||||
#pragma warning (disable : 4786) | #pragma warning (disable : 4786) | ||||
#endif | #endif | ||||
@@ -68,22 +68,22 @@ JackInternalClient::~JackInternalClient() | |||||
int JackInternalClient::Open(const char* server_name, const char* name, jack_options_t options, jack_status_t* status) | int JackInternalClient::Open(const char* server_name, const char* name, jack_options_t options, jack_status_t* status) | ||||
{ | { | ||||
int result; | int result; | ||||
char name_res[JACK_CLIENT_NAME_SIZE]; | |||||
char name_res[JACK_CLIENT_NAME_SIZE]; | |||||
JackLog("JackInternalClient::Open name = %s\n", name); | JackLog("JackInternalClient::Open name = %s\n", name); | ||||
snprintf(fServerName, sizeof(fServerName), server_name); | |||||
fChannel->ClientCheck(name, name_res, JACK_PROTOCOL_VERSION, (int)options, (int*)status, &result); | |||||
snprintf(fServerName, sizeof(fServerName), server_name); | |||||
fChannel->ClientCheck(name, name_res, JACK_PROTOCOL_VERSION, (int)options, (int*)status, &result); | |||||
if (result < 0) { | if (result < 0) { | ||||
int status1 = *status; | |||||
int status1 = *status; | |||||
if (status1 & JackVersionError) | if (status1 & JackVersionError) | ||||
jack_error("JACK protocol mismatch %d", JACK_PROTOCOL_VERSION); | |||||
jack_error("JACK protocol mismatch %d", JACK_PROTOCOL_VERSION); | |||||
else | else | ||||
jack_error("Client name = %s conflits with another running client", name); | |||||
jack_error("Client name = %s conflits with another running client", name); | |||||
goto error; | goto error; | ||||
} | } | ||||
strcpy(fClientControl->fName, name_res); | |||||
strcpy(fClientControl->fName, name_res); | |||||
// Require new client | // Require new client | ||||
fChannel->ClientOpen(name_res, &fClientControl->fRefNum, &fEngineControl, &fGraphManager, this, &result); | fChannel->ClientOpen(name_res, &fClientControl->fRefNum, &fEngineControl, &fGraphManager, this, &result); | ||||
@@ -119,49 +119,49 @@ JackClientControl* JackInternalClient::GetClientControl() const | |||||
} | } | ||||
JackLoadableInternalClient::JackLoadableInternalClient(JackServer* server, JackSynchro** table, const char* so_name, const char* object_data) | JackLoadableInternalClient::JackLoadableInternalClient(JackServer* server, JackSynchro** table, const char* so_name, const char* object_data) | ||||
:JackInternalClient(server, table) | |||||
: JackInternalClient(server, table) | |||||
{ | { | ||||
char path_to_so[PATH_MAX + 1]; | |||||
//snprintf(path_to_so, sizeof(path_to_so), ADDON_DIR "/%s.so", so_name); | |||||
snprintf(path_to_so, sizeof(path_to_so), so_name); | |||||
snprintf(fObjectData, JACK_LOAD_INIT_LIMIT, object_data); | |||||
fHandle = LoadJackModule(path_to_so); | |||||
JackLog("JackLoadableInternalClient::JackLoadableInternalClient path_to_so = %s\n", path_to_so); | |||||
if (fHandle == 0) { | |||||
jack_error("error loading %s", so_name); | |||||
throw -1; | |||||
} | |||||
fInitialize = (InitializeCallback)GetJackProc(fHandle, "jack_initialize"); | |||||
if (!fInitialize) { | |||||
UnloadJackModule(fHandle); | |||||
jack_error("symbol jack_initialize cannot be found in %s", so_name); | |||||
throw -1; | |||||
} | |||||
fFinish = (FinishCallback)GetJackProc(fHandle, "jack_finish"); | |||||
if (!fFinish) { | |||||
UnloadJackModule(fHandle); | |||||
jack_error("symbol jack_finish cannot be found in %s", so_name); | |||||
throw -1; | |||||
} | |||||
char path_to_so[PATH_MAX + 1]; | |||||
//snprintf(path_to_so, sizeof(path_to_so), ADDON_DIR "/%s.so", so_name); | |||||
snprintf(path_to_so, sizeof(path_to_so), so_name); | |||||
snprintf(fObjectData, JACK_LOAD_INIT_LIMIT, object_data); | |||||
fHandle = LoadJackModule(path_to_so); | |||||
JackLog("JackLoadableInternalClient::JackLoadableInternalClient path_to_so = %s\n", path_to_so); | |||||
if (fHandle == 0) { | |||||
jack_error("error loading %s", so_name); | |||||
throw - 1; | |||||
} | |||||
fInitialize = (InitializeCallback)GetJackProc(fHandle, "jack_initialize"); | |||||
if (!fInitialize) { | |||||
UnloadJackModule(fHandle); | |||||
jack_error("symbol jack_initialize cannot be found in %s", so_name); | |||||
throw - 1; | |||||
} | |||||
fFinish = (FinishCallback)GetJackProc(fHandle, "jack_finish"); | |||||
if (!fFinish) { | |||||
UnloadJackModule(fHandle); | |||||
jack_error("symbol jack_finish cannot be found in %s", so_name); | |||||
throw - 1; | |||||
} | |||||
} | } | ||||
JackLoadableInternalClient::~JackLoadableInternalClient() | JackLoadableInternalClient::~JackLoadableInternalClient() | ||||
{ | { | ||||
if (fFinish) | |||||
fFinish(fProcessArg); | |||||
UnloadJackModule(fHandle); | |||||
if (fFinish) | |||||
fFinish(fProcessArg); | |||||
UnloadJackModule(fHandle); | |||||
} | } | ||||
int JackLoadableInternalClient::Open(const char* server_name, const char* name, jack_options_t options, jack_status_t* status) | int JackLoadableInternalClient::Open(const char* server_name, const char* name, jack_options_t options, jack_status_t* status) | ||||
{ | { | ||||
int res = JackInternalClient::Open(server_name, name, options, status); | |||||
if (res == 0) | |||||
fInitialize((jack_client_t*)this, fObjectData); | |||||
return res; | |||||
int res = JackInternalClient::Open(server_name, name, options, status); | |||||
if (res == 0) | |||||
fInitialize((jack_client_t*)this, fObjectData); | |||||
return res; | |||||
} | } | ||||
} // end of namespace | } // end of namespace | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2004-2008 Grame | Copyright (C) 2004-2008 Grame | ||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
@@ -62,15 +62,15 @@ class JackInternalClient : public JackClient | |||||
#ifdef WIN32 | #ifdef WIN32 | ||||
#include <windows.h> | #include <windows.h> | ||||
#define HANDLE HINSTANCE | |||||
#define HANDLE HINSTANCE | |||||
#define LoadJackModule(name) LoadLibrary((name)); | #define LoadJackModule(name) LoadLibrary((name)); | ||||
#define UnloadJackModule(handle) FreeLibrary((handle)); | |||||
#define UnloadJackModule(handle) FreeLibrary((handle)); | |||||
#define GetJackProc(handle, name) GetProcAddress((handle), (name)); | #define GetJackProc(handle, name) GetProcAddress((handle), (name)); | ||||
#else | #else | ||||
#include <dlfcn.h> | #include <dlfcn.h> | ||||
#define HANDLE void* | |||||
#define HANDLE void* | |||||
#define LoadJackModule(name) dlopen((name), RTLD_NOW | RTLD_LOCAL); | #define LoadJackModule(name) dlopen((name), RTLD_NOW | RTLD_LOCAL); | ||||
#define UnloadJackModule(handle) dlclose((handle)); | #define UnloadJackModule(handle) dlclose((handle)); | ||||
#define GetJackProc(handle, name) dlsym((handle), (name)); | #define GetJackProc(handle, name) dlsym((handle), (name)); | ||||
@@ -84,18 +84,18 @@ class JackLoadableInternalClient : public JackInternalClient | |||||
{ | { | ||||
private: | private: | ||||
HANDLE fHandle; | |||||
InitializeCallback fInitialize; | |||||
FinishCallback fFinish; | |||||
char fObjectData[JACK_LOAD_INIT_LIMIT]; | |||||
HANDLE fHandle; | |||||
InitializeCallback fInitialize; | |||||
FinishCallback fFinish; | |||||
char fObjectData[JACK_LOAD_INIT_LIMIT]; | |||||
public: | public: | ||||
JackLoadableInternalClient(JackServer* server, JackSynchro** table, const char* so_name, const char* object_data); | JackLoadableInternalClient(JackServer* server, JackSynchro** table, const char* so_name, const char* object_data); | ||||
virtual ~JackLoadableInternalClient(); | |||||
int Open(const char* server_name, const char* name, jack_options_t options, jack_status_t* status); | |||||
virtual ~JackLoadableInternalClient(); | |||||
int Open(const char* server_name, const char* name, jack_options_t options, jack_status_t* status); | |||||
}; | }; | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2004-2008 Grame | |||||
Copyright (C) 2004-2008 Grame | |||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
it under the terms of the GNU General Public License as published by | it under the terms of the GNU General Public License as published by | ||||
@@ -43,15 +43,15 @@ class JackInternalClientChannel : public JackClientChannelInterface | |||||
{} | {} | ||||
virtual ~JackInternalClientChannel() | virtual ~JackInternalClientChannel() | ||||
{} | {} | ||||
// Open the Server/Client connection | |||||
// Open the Server/Client connection | |||||
virtual int Open(const char* name, char* name_res, JackClient* obj, jack_options_t options, jack_status_t* status) | virtual int Open(const char* name, char* name_res, JackClient* obj, jack_options_t options, jack_status_t* status) | ||||
{ | { | ||||
return 0; | return 0; | ||||
} | } | ||||
void ClientCheck(const char* name, char* name_res, int protocol, int options, int* status, int* result) | |||||
{ | |||||
void ClientCheck(const char* name, char* name_res, int protocol, int options, int* status, int* result) | |||||
{ | |||||
*result = fEngine->ClientCheck(name, name_res, protocol, options, status); | *result = fEngine->ClientCheck(name, name_res, protocol, options, status); | ||||
} | } | ||||
void ClientOpen(const char* name, int* ref, JackEngineControl** shared_engine, JackGraphManager** shared_manager, JackClientInterface* client, int* result) | void ClientOpen(const char* name, int* ref, JackEngineControl** shared_engine, JackGraphManager** shared_manager, JackClientInterface* client, int* result) | ||||
@@ -62,14 +62,14 @@ class JackInternalClientChannel : public JackClientChannelInterface | |||||
{ | { | ||||
*result = fEngine->ClientInternalClose(refnum, true); | *result = fEngine->ClientInternalClose(refnum, true); | ||||
} | } | ||||
void ClientActivate(int refnum, int* result) | void ClientActivate(int refnum, int* result) | ||||
{ | { | ||||
*result = fEngine->ClientActivate(refnum); | |||||
*result = fEngine->ClientActivate(refnum); | |||||
} | } | ||||
void ClientDeactivate(int refnum, int* result) | void ClientDeactivate(int refnum, int* result) | ||||
{ | { | ||||
*result = fEngine->ClientDeactivate(refnum); | |||||
*result = fEngine->ClientDeactivate(refnum); | |||||
} | } | ||||
void PortRegister(int refnum, const char* name, const char* type, unsigned int flags, unsigned int buffer_size, unsigned int* port_index, int* result) | void PortRegister(int refnum, const char* name, const char* type, unsigned int flags, unsigned int buffer_size, unsigned int* port_index, int* result) | ||||
@@ -108,7 +108,7 @@ class JackInternalClientChannel : public JackClientChannelInterface | |||||
*result = fServer->SetFreewheel(onoff); | *result = fServer->SetFreewheel(onoff); | ||||
} | } | ||||
void ReleaseTimebase(int refnum, int* result) | |||||
void ReleaseTimebase(int refnum, int* result) | |||||
{ | { | ||||
*result = fServer->ReleaseTimebase(refnum); | *result = fServer->ReleaseTimebase(refnum); | ||||
} | } | ||||
@@ -13,7 +13,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
GNU Lesser General Public License for more details. | GNU Lesser General Public License for more details. | ||||
You should have received a copy of the GNU Lesser General Public License | You should have received a copy of the GNU Lesser General Public License | ||||
along with this program; if not, write to the Free Software | |||||
along with this program; if not, write to the Free Software | |||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||||
*/ | */ | ||||
@@ -29,9 +29,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||||
using namespace Jack; | using namespace Jack; | ||||
#ifdef WIN32 | #ifdef WIN32 | ||||
#define EXPORT __declspec(dllexport) | |||||
#define EXPORT __declspec(dllexport) | |||||
#else | #else | ||||
#define EXPORT | |||||
#define EXPORT | |||||
#endif | #endif | ||||
#ifdef __cplusplus | #ifdef __cplusplus | ||||
@@ -56,10 +56,10 @@ EXPORT jack_client_t* jack_client_open(const char* ext_client_name, jack_options | |||||
va_list ap; /* variable argument pointer */ | va_list ap; /* variable argument pointer */ | ||||
jack_varargs_t va; /* variable arguments */ | jack_varargs_t va; /* variable arguments */ | ||||
jack_status_t my_status; | jack_status_t my_status; | ||||
JackClient* client; | |||||
char client_name[JACK_CLIENT_NAME_SIZE]; | |||||
JackTools::RewriteName(ext_client_name, client_name); | |||||
JackClient* client; | |||||
char client_name[JACK_CLIENT_NAME_SIZE]; | |||||
JackTools::RewriteName(ext_client_name, client_name); | |||||
if (status == NULL) /* no status from caller? */ | if (status == NULL) /* no status from caller? */ | ||||
status = &my_status; /* use local status word */ | status = &my_status; /* use local status word */ | ||||
@@ -76,8 +76,8 @@ EXPORT jack_client_t* jack_client_open(const char* ext_client_name, jack_options | |||||
va_start(ap, status); | va_start(ap, status); | ||||
jack_varargs_parse(options, ap, &va); | jack_varargs_parse(options, ap, &va); | ||||
va_end(ap); | va_end(ap); | ||||
JackLog("jack_client_open %s\n", client_name); | JackLog("jack_client_open %s\n", client_name); | ||||
if (client_name == NULL) { | if (client_name == NULL) { | ||||
jack_error("jack_client_new called with a NULL client_name"); | jack_error("jack_client_new called with a NULL client_name"); | ||||
@@ -85,30 +85,30 @@ EXPORT jack_client_t* jack_client_open(const char* ext_client_name, jack_options | |||||
} | } | ||||
JackLibGlobals::Init(); // jack library initialisation | JackLibGlobals::Init(); // jack library initialisation | ||||
#ifndef WIN32 | #ifndef WIN32 | ||||
if (try_start_server(&va, options, status)) { | |||||
jack_error("jack server is not running or cannot be started"); | |||||
JackLibGlobals::Destroy(); // jack library destruction | |||||
return 0; | |||||
} | |||||
#endif | |||||
if (try_start_server(&va, options, status)) { | |||||
jack_error("jack server is not running or cannot be started"); | |||||
JackLibGlobals::Destroy(); // jack library destruction | |||||
return 0; | |||||
} | |||||
#endif | |||||
#ifndef WIN32 | #ifndef WIN32 | ||||
char* jack_debug = getenv("JACK_CLIENT_DEBUG"); | |||||
if (jack_debug && strcmp(jack_debug, "on") == 0) | |||||
client = new JackDebugClient(new JackLibClient(GetSynchroTable())); // Debug mode | |||||
else | |||||
client = new JackLibClient(GetSynchroTable()); | |||||
char* jack_debug = getenv("JACK_CLIENT_DEBUG"); | |||||
if (jack_debug && strcmp(jack_debug, "on") == 0) | |||||
client = new JackDebugClient(new JackLibClient(GetSynchroTable())); // Debug mode | |||||
else | |||||
client = new JackLibClient(GetSynchroTable()); | |||||
#else | #else | ||||
client = new JackLibClient(GetSynchroTable()); | |||||
#endif | |||||
client = new JackLibClient(GetSynchroTable()); | |||||
#endif | |||||
int res = client->Open(va.server_name, client_name, options, status); | int res = client->Open(va.server_name, client_name, options, status); | ||||
if (res < 0) { | if (res < 0) { | ||||
delete client; | delete client; | ||||
JackLibGlobals::Destroy(); // jack library destruction | JackLibGlobals::Destroy(); // jack library destruction | ||||
int my_status1 = (JackFailure|JackServerError); | |||||
int my_status1 = (JackFailure | JackServerError); | |||||
*status = (jack_status_t)my_status1; | *status = (jack_status_t)my_status1; | ||||
return NULL; | return NULL; | ||||
} else { | } else { | ||||
@@ -124,12 +124,12 @@ EXPORT int jack_client_close(jack_client_t* ext_client) | |||||
jack_error("jack_client_close called with a NULL client"); | jack_error("jack_client_close called with a NULL client"); | ||||
return -1; | return -1; | ||||
} else { | } else { | ||||
int res = client->Close(); | |||||
delete client; | |||||
JackLog("jack_client_close OK\n"); | |||||
JackLibGlobals::Destroy(); // jack library destruction | |||||
return res; | |||||
} | |||||
int res = client->Close(); | |||||
delete client; | |||||
JackLog("jack_client_close OK\n"); | |||||
JackLibGlobals::Destroy(); // jack library destruction | |||||
return res; | |||||
} | |||||
} | } | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2004-2008 Grame | |||||
Copyright (C) 2004-2008 Grame | |||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
it under the terms of the GNU General Public License as published by | it under the terms of the GNU General Public License as published by | ||||
@@ -29,18 +29,18 @@ namespace Jack | |||||
// Used for external C API (JackAPI.cpp) | // Used for external C API (JackAPI.cpp) | ||||
JackGraphManager* GetGraphManager() | JackGraphManager* GetGraphManager() | ||||
{ | { | ||||
if (JackLibGlobals::fGlobals) | |||||
return JackLibGlobals::fGlobals->fGraphManager; | |||||
else | |||||
return NULL; | |||||
if (JackLibGlobals::fGlobals) | |||||
return JackLibGlobals::fGlobals->fGraphManager; | |||||
else | |||||
return NULL; | |||||
} | } | ||||
JackEngineControl* GetEngineControl() | JackEngineControl* GetEngineControl() | ||||
{ | { | ||||
if (JackLibGlobals::fGlobals) | |||||
return JackLibGlobals::fGlobals->fEngineControl; | |||||
else | |||||
return NULL; | |||||
if (JackLibGlobals::fGlobals) | |||||
return JackLibGlobals::fGlobals->fEngineControl; | |||||
else | |||||
return NULL; | |||||
} | } | ||||
JackSynchro** GetSynchroTable() | JackSynchro** GetSynchroTable() | ||||
@@ -68,11 +68,11 @@ int JackLibClient::Open(const char* server_name, const char* name, jack_options_ | |||||
{ | { | ||||
int shared_engine, shared_client, shared_graph, result; | int shared_engine, shared_client, shared_graph, result; | ||||
JackLog("JackLibClient::Open %s\n", name); | JackLog("JackLibClient::Open %s\n", name); | ||||
snprintf(fServerName, sizeof(fServerName), server_name); | |||||
snprintf(fServerName, sizeof(fServerName), server_name); | |||||
// Open server/client channel | // Open server/client channel | ||||
char name_res[JACK_CLIENT_NAME_SIZE]; | |||||
char name_res[JACK_CLIENT_NAME_SIZE]; | |||||
if (fChannel->Open(server_name, name, name_res, this, options, status) < 0) { | if (fChannel->Open(server_name, name, name_res, this, options, status) < 0) { | ||||
jack_error("Cannot connect to the server"); | jack_error("Cannot connect to the server"); | ||||
goto error; | goto error; | ||||
@@ -93,28 +93,28 @@ int JackLibClient::Open(const char* server_name, const char* name, jack_options_ | |||||
try { | try { | ||||
// Map shared memory segments | // Map shared memory segments | ||||
JackLibGlobals::fGlobals->fEngineControl.SetShmIndex(shared_engine, fServerName); | |||||
JackLibGlobals::fGlobals->fEngineControl.SetShmIndex(shared_engine, fServerName); | |||||
JackLibGlobals::fGlobals->fGraphManager.SetShmIndex(shared_graph, fServerName); | JackLibGlobals::fGlobals->fGraphManager.SetShmIndex(shared_graph, fServerName); | ||||
fClientControl.SetShmIndex(shared_client, fServerName); | fClientControl.SetShmIndex(shared_client, fServerName); | ||||
jack_verbose = GetEngineControl()->fVerbose; | jack_verbose = GetEngineControl()->fVerbose; | ||||
} catch (int n) { | |||||
} catch (int n) { | |||||
jack_error("Map shared memory segments exception %d", n); | jack_error("Map shared memory segments exception %d", n); | ||||
goto error; | goto error; | ||||
} | } | ||||
SetupDriverSync(false); | SetupDriverSync(false); | ||||
/* TODO : solve WIN32 thread Kill issue | |||||
#ifndef WIN32 | |||||
// Connect shared synchro : the synchro must be usable in I/O mode when several clients live in the same process | |||||
if (!fSynchroTable[fClientControl->fRefNum]->Connect(name)) { | |||||
jack_error("Cannot ConnectSemaphore %s client", name); | |||||
goto error; | |||||
} | |||||
#endif | |||||
*/ | |||||
// Connect shared synchro : the synchro must be usable in I/O mode when several clients live in the same process | |||||
if (!fSynchroTable[fClientControl->fRefNum]->Connect(name_res, fServerName)) { | |||||
/* TODO : solve WIN32 thread Kill issue | |||||
#ifndef WIN32 | |||||
// Connect shared synchro : the synchro must be usable in I/O mode when several clients live in the same process | |||||
if (!fSynchroTable[fClientControl->fRefNum]->Connect(name)) { | |||||
jack_error("Cannot ConnectSemaphore %s client", name); | |||||
goto error; | |||||
} | |||||
#endif | |||||
*/ | |||||
// Connect shared synchro : the synchro must be usable in I/O mode when several clients live in the same process | |||||
if (!fSynchroTable[fClientControl->fRefNum]->Connect(name_res, fServerName)) { | |||||
jack_error("Cannot ConnectSemaphore %s client", name_res); | jack_error("Cannot ConnectSemaphore %s client", name_res); | ||||
goto error; | goto error; | ||||
} | } | ||||
@@ -140,7 +140,7 @@ int JackLibClient::ClientNotifyImp(int refnum, const char* name, int notify, int | |||||
case kAddClient: | case kAddClient: | ||||
JackLog("JackClient::AddClient name = %s, ref = %ld \n", name, refnum); | JackLog("JackClient::AddClient name = %s, ref = %ld \n", name, refnum); | ||||
// the synchro must be usable in I/O mode when several clients live in the same process | |||||
// the synchro must be usable in I/O mode when several clients live in the same process | |||||
res = fSynchroTable[refnum]->Connect(name, fServerName) ? 0 : -1; | res = fSynchroTable[refnum]->Connect(name, fServerName) ? 0 : -1; | ||||
break; | break; | ||||
@@ -149,7 +149,7 @@ int JackLibClient::ClientNotifyImp(int refnum, const char* name, int notify, int | |||||
if (strcmp(GetClientControl()->fName, name) != 0) | if (strcmp(GetClientControl()->fName, name) != 0) | ||||
res = fSynchroTable[refnum]->Disconnect() ? 0 : -1; | res = fSynchroTable[refnum]->Disconnect() ? 0 : -1; | ||||
break; | break; | ||||
} | |||||
} | |||||
return res; | return res; | ||||
} | } | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2004-2008 Grame | |||||
Copyright (C) 2004-2008 Grame | |||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
it under the terms of the GNU General Public License as published by | it under the terms of the GNU General Public License as published by | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2005 Grame | |||||
Copyright (C) 2005 Grame | |||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
it under the terms of the GNU General Public License as published by | it under the terms of the GNU General Public License as published by | ||||
@@ -49,7 +49,7 @@ struct JackLibGlobals | |||||
std::map<mach_port_t, JackClient*> fClientTable; /*! Client table */ | std::map<mach_port_t, JackClient*> fClientTable; /*! Client table */ | ||||
#endif | #endif | ||||
static int fClientCount; | |||||
static int fClientCount; | |||||
static JackLibGlobals* fGlobals; | static JackLibGlobals* fGlobals; | ||||
JackLibGlobals() | JackLibGlobals() | ||||
@@ -77,7 +77,7 @@ struct JackLibGlobals | |||||
JackGlobals::InitClient(); | JackGlobals::InitClient(); | ||||
InitTime(); | InitTime(); | ||||
fGlobals = new JackLibGlobals(); | fGlobals = new JackLibGlobals(); | ||||
} | |||||
} | |||||
} | } | ||||
static void Destroy() | static void Destroy() | ||||
@@ -89,13 +89,13 @@ struct JackLibGlobals | |||||
JackGlobals::Destroy(); | JackGlobals::Destroy(); | ||||
} | } | ||||
} | } | ||||
static void CheckContext() | |||||
{ | |||||
if (!(fClientCount > 0 && fGlobals)) { | |||||
jack_error("Error !!! : client accessing an already desallocated library context"); | |||||
} | |||||
} | |||||
static void CheckContext() | |||||
{ | |||||
if (!(fClientCount > 0 && fGlobals)) { | |||||
jack_error("Error !!! : client accessing an already desallocated library context"); | |||||
} | |||||
} | |||||
}; | }; | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2004-2008 Grame | Copyright (C) 2004-2008 Grame | ||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
@@ -18,7 +18,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||||
*/ | */ | ||||
#ifdef WIN32 | |||||
#ifdef WIN32 | |||||
#pragma warning (disable : 4786) | #pragma warning (disable : 4786) | ||||
#endif | #endif | ||||
@@ -38,14 +38,14 @@ int JackLoopbackDriver::Process() | |||||
// Loopback copy | // Loopback copy | ||||
for (int i = 0; i < fCaptureChannels; i++) { | for (int i = 0; i < fCaptureChannels; i++) { | ||||
memcpy(GetInputBuffer(i), GetOutputBuffer(i), sizeof(float) * fEngineControl->fBufferSize); | memcpy(GetInputBuffer(i), GetOutputBuffer(i), sizeof(float) * fEngineControl->fBufferSize); | ||||
} | |||||
} | |||||
fGraphManager->ResumeRefNum(fClientControl, fSynchroTable); // Signal all clients | fGraphManager->ResumeRefNum(fClientControl, fSynchroTable); // Signal all clients | ||||
if (fEngineControl->fSyncMode) { | if (fEngineControl->fSyncMode) { | ||||
if (fGraphManager->SuspendRefNum(fClientControl, fSynchroTable, fEngineControl->fTimeOutUsecs) < 0) { | if (fGraphManager->SuspendRefNum(fClientControl, fSynchroTable, fEngineControl->fTimeOutUsecs) < 0) { | ||||
jack_error("JackLoopbackDriver::ProcessSync SuspendRefNum error"); | jack_error("JackLoopbackDriver::ProcessSync SuspendRefNum error"); | ||||
return -1; | |||||
} | |||||
return -1; | |||||
} | |||||
} | } | ||||
return 0; | return 0; | ||||
} | } | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2004-2008 Grame | Copyright (C) 2004-2008 Grame | ||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
@@ -41,7 +41,7 @@ class JackLoopbackDriver : public JackAudioDriver | |||||
virtual ~JackLoopbackDriver() | virtual ~JackLoopbackDriver() | ||||
{} | {} | ||||
int Process(); | |||||
int Process(); | |||||
}; | }; | ||||
} // end of namespace | } // end of namespace | ||||
@@ -28,23 +28,24 @@ This program is free software; you can redistribute it and/or modify | |||||
#endif | #endif | ||||
#ifdef __cplusplus | #ifdef __cplusplus | ||||
extern "C" { | |||||
extern "C" | |||||
{ | |||||
#endif | #endif | ||||
EXPORT jack_nframes_t jack_midi_get_event_count(void* port_buffer); | EXPORT jack_nframes_t jack_midi_get_event_count(void* port_buffer); | ||||
EXPORT int jack_midi_event_get(jack_midi_event_t* event, | EXPORT int jack_midi_event_get(jack_midi_event_t* event, | ||||
void* port_buffer, jack_nframes_t event_index); | |||||
void* port_buffer, jack_nframes_t event_index); | |||||
EXPORT void jack_midi_clear_buffer(void* port_buffer); | EXPORT void jack_midi_clear_buffer(void* port_buffer); | ||||
EXPORT size_t jack_midi_max_event_size(void* port_buffer); | EXPORT size_t jack_midi_max_event_size(void* port_buffer); | ||||
EXPORT jack_midi_data_t* jack_midi_event_reserve(void* port_buffer, | EXPORT jack_midi_data_t* jack_midi_event_reserve(void* port_buffer, | ||||
jack_nframes_t time, size_t data_size); | |||||
jack_nframes_t time, size_t data_size); | |||||
EXPORT int jack_midi_event_write(void* port_buffer, | EXPORT int jack_midi_event_write(void* port_buffer, | ||||
jack_nframes_t time, const jack_midi_data_t* data, size_t data_size); | |||||
jack_nframes_t time, const jack_midi_data_t* data, size_t data_size); | |||||
EXPORT jack_nframes_t jack_midi_get_lost_event_count(void* port_buffer); | EXPORT jack_nframes_t jack_midi_get_lost_event_count(void* port_buffer); | ||||
@@ -108,7 +109,7 @@ jack_midi_data_t* jack_midi_event_reserve(void* port_buffer, jack_nframes_t time | |||||
EXPORT | EXPORT | ||||
int jack_midi_event_write(void* port_buffer, | int jack_midi_event_write(void* port_buffer, | ||||
jack_nframes_t time, const jack_midi_data_t* data, size_t data_size) | |||||
jack_nframes_t time, const jack_midi_data_t* data, size_t data_size) | |||||
{ | { | ||||
JackMidiBuffer *buf = (JackMidiBuffer*)port_buffer; | JackMidiBuffer *buf = (JackMidiBuffer*)port_buffer; | ||||
if (!buf && !buf->IsValid()) | if (!buf && !buf->IsValid()) | ||||
@@ -127,6 +128,6 @@ jack_nframes_t jack_midi_get_lost_event_count(void* port_buffer) | |||||
{ | { | ||||
JackMidiBuffer *buf = (JackMidiBuffer*)port_buffer; | JackMidiBuffer *buf = (JackMidiBuffer*)port_buffer; | ||||
if (buf && buf->IsValid()) | if (buf && buf->IsValid()) | ||||
return buf->lost_events; | |||||
return buf->lost_events; | |||||
return 0; | return 0; | ||||
} | } |
@@ -131,10 +131,11 @@ static void MidiBufferMixdown(void* mixbuffer, void** src_buffers, int src_count | |||||
mix->lost_events += event_count - events_done; | mix->lost_events += event_count - events_done; | ||||
} | } | ||||
const JackPortType gMidiPortType = { | |||||
JACK_DEFAULT_MIDI_TYPE, | |||||
MidiBufferInit, | |||||
MidiBufferMixdown | |||||
}; | |||||
const JackPortType gMidiPortType = | |||||
{ | |||||
JACK_DEFAULT_MIDI_TYPE, | |||||
MidiBufferInit, | |||||
MidiBufferMixdown | |||||
}; | |||||
} // namespace Jack | } // namespace Jack |
@@ -31,9 +31,9 @@ typedef unsigned char jack_midi_data_t; | |||||
/** A Jack MIDI event. */ | /** A Jack MIDI event. */ | ||||
struct jack_midi_event_t | struct jack_midi_event_t | ||||
{ | { | ||||
jack_nframes_t time; /**< Sample index at which event is valid */ | |||||
size_t size; /**< Number of bytes of data in \a buffer */ | |||||
jack_midi_data_t *buffer; /**< Raw MIDI data */ | |||||
jack_nframes_t time; /**< Sample index at which event is valid */ | |||||
size_t size; /**< Number of bytes of data in \a buffer */ | |||||
jack_midi_data_t *buffer; /**< Raw MIDI data */ | |||||
}; | }; | ||||
/** A Jack MIDI port type. */ | /** A Jack MIDI port type. */ | ||||
@@ -84,7 +84,10 @@ struct JackMidiBuffer | |||||
JackMidiEvent events[0]; | JackMidiEvent events[0]; | ||||
int IsValid() const { return magic == MAGIC; } | |||||
int IsValid() const | |||||
{ | |||||
return magic == MAGIC; | |||||
} | |||||
void Reset(jack_nframes_t nframes); | void Reset(jack_nframes_t nframes); | ||||
jack_shmsize_t MaxEventSize() const; | jack_shmsize_t MaxEventSize() const; | ||||
@@ -1,23 +1,23 @@ | |||||
/* | |||||
/* | |||||
Copyright (C) 2006 Grame | |||||
Copyright (C) 2006 Grame | |||||
This library is free software; you can redistribute it and/or | |||||
modify it under the terms of the GNU Lesser General Public | |||||
License as published by the Free Software Foundation; either | |||||
version 2.1 of the License, or (at your option) any later version. | |||||
This library is free software; you can redistribute it and/or | |||||
modify it under the terms of the GNU Lesser General Public | |||||
License as published by the Free Software Foundation; either | |||||
version 2.1 of the License, or (at your option) any later version. | |||||
This library is distributed in the hope that it will be useful, | |||||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||||
Lesser General Public License for more details. | |||||
This library is distributed in the hope that it will be useful, | |||||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||||
Lesser General Public License for more details. | |||||
You should have received a copy of the GNU Lesser General Public | |||||
License along with this library; if not, write to the Free Software | |||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |||||
You should have received a copy of the GNU Lesser General Public | |||||
License along with this library; if not, write to the Free Software | |||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |||||
Grame Research Laboratory, 9 rue du Garet, 69001 Lyon - France | |||||
grame@grame.fr | |||||
Grame Research Laboratory, 9 rue du Garet, 69001 Lyon - France | |||||
grame@grame.fr | |||||
*/ | */ | ||||
@@ -32,117 +32,119 @@ | |||||
#include<assert.h> | #include<assert.h> | ||||
namespace Jack | |||||
namespace Jack | |||||
{ | { | ||||
class JackMutex | |||||
class JackMutex | |||||
{ | { | ||||
private: | |||||
#ifdef WIN32 | |||||
HANDLE fMutex; | |||||
#else | |||||
pthread_mutex_t fMutex; | |||||
#endif | |||||
public: | |||||
#ifdef WIN32 | |||||
JackMutex() | |||||
{ | |||||
fMutex = CreateMutex(0, FALSE, 0); | |||||
} | |||||
virtual ~JackMutex() | |||||
{ | |||||
CloseHandle(fMutex); | |||||
} | |||||
void Lock() | |||||
{ | |||||
DWORD dwWaitResult = WaitForSingleObject(fMutex, INFINITE); | |||||
} | |||||
void Unlock() | |||||
{ | |||||
ReleaseMutex(fMutex); | |||||
} | |||||
#else | |||||
JackMutex() | |||||
{ | |||||
// Use recursive mutex | |||||
pthread_mutexattr_t mutex_attr; | |||||
assert(pthread_mutexattr_init(&mutex_attr) == 0); | |||||
assert(pthread_mutexattr_settype(&mutex_attr, PTHREAD_MUTEX_RECURSIVE) == 0); | |||||
assert(pthread_mutex_init(&fMutex, &mutex_attr) == 0); | |||||
} | |||||
virtual ~JackMutex() | |||||
{ | |||||
pthread_mutex_destroy(&fMutex); | |||||
} | |||||
void Lock() | |||||
{ | |||||
pthread_mutex_lock(&fMutex); | |||||
} | |||||
void Unlock() | |||||
{ | |||||
pthread_mutex_unlock(&fMutex); | |||||
} | |||||
#endif | |||||
private: | |||||
#ifdef WIN32 | |||||
HANDLE fMutex; | |||||
#else | |||||
pthread_mutex_t fMutex; | |||||
#endif | |||||
public: | |||||
#ifdef WIN32 | |||||
JackMutex() | |||||
{ | |||||
fMutex = CreateMutex(0, FALSE, 0); | |||||
} | |||||
virtual ~JackMutex() | |||||
{ | |||||
CloseHandle(fMutex); | |||||
} | |||||
void Lock() | |||||
{ | |||||
DWORD dwWaitResult = WaitForSingleObject(fMutex, INFINITE); | |||||
} | |||||
void Unlock() | |||||
{ | |||||
ReleaseMutex(fMutex); | |||||
} | |||||
#else | |||||
JackMutex() | |||||
{ | |||||
// Use recursive mutex | |||||
pthread_mutexattr_t mutex_attr; | |||||
assert(pthread_mutexattr_init(&mutex_attr) == 0); | |||||
assert(pthread_mutexattr_settype(&mutex_attr, PTHREAD_MUTEX_RECURSIVE) == 0); | |||||
assert(pthread_mutex_init(&fMutex, &mutex_attr) == 0); | |||||
} | |||||
virtual ~JackMutex() | |||||
{ | |||||
pthread_mutex_destroy(&fMutex); | |||||
} | |||||
void Lock() | |||||
{ | |||||
pthread_mutex_lock(&fMutex); | |||||
} | |||||
void Unlock() | |||||
{ | |||||
pthread_mutex_unlock(&fMutex); | |||||
} | |||||
#endif | |||||
}; | }; | ||||
class JackLockAble | class JackLockAble | ||||
{ | { | ||||
private: | |||||
private: | |||||
JackMutex fMutex; | |||||
JackMutex fMutex; | |||||
public: | |||||
public: | |||||
JackLockAble() | |||||
{} | |||||
virtual ~JackLockAble() | |||||
{} | |||||
JackLockAble() {} | |||||
virtual ~JackLockAble() {} | |||||
void Lock() | |||||
{ | |||||
fMutex.Lock(); | |||||
} | |||||
void Lock() | |||||
{ | |||||
fMutex.Lock(); | |||||
} | |||||
void Unlock() | |||||
{ | |||||
fMutex.Unlock(); | |||||
} | |||||
void Unlock() | |||||
{ | |||||
fMutex.Unlock(); | |||||
} | |||||
}; | }; | ||||
class JackLock | class JackLock | ||||
{ | { | ||||
private: | |||||
JackLockAble* fObj; | |||||
public: | |||||
JackLock(JackLockAble* obj):fObj(obj) | |||||
{ | |||||
fObj->Lock(); | |||||
} | |||||
JackLock(const JackLockAble* obj):fObj((JackLockAble*)obj) | |||||
{ | |||||
fObj->Lock(); | |||||
} | |||||
virtual ~JackLock() | |||||
{ | |||||
fObj->Unlock(); | |||||
} | |||||
private: | |||||
JackLockAble* fObj; | |||||
public: | |||||
JackLock(JackLockAble* obj): fObj(obj) | |||||
{ | |||||
fObj->Lock(); | |||||
} | |||||
JackLock(const JackLockAble* obj): fObj((JackLockAble*)obj) | |||||
{ | |||||
fObj->Lock(); | |||||
} | |||||
virtual ~JackLock() | |||||
{ | |||||
fObj->Unlock(); | |||||
} | |||||
}; | }; | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2007 Grame | |||||
Copyright (C) 2007 Grame | |||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
it under the terms of the GNU General Public License as published by | it under the terms of the GNU General Public License as published by | ||||
@@ -22,22 +22,22 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||||
namespace Jack | namespace Jack | ||||
{ | { | ||||
enum NotificationType { | |||||
kAddClient = 0, | |||||
kRemoveClient = 1, | |||||
kActivateClient = 2, | |||||
kXRunCallback = 3, | |||||
kGraphOrderCallback = 4, | |||||
kBufferSizeCallback = 5, | |||||
kStartFreewheelCallback = 6, | |||||
kStopFreewheelCallback = 7, | |||||
kPortRegistrationOnCallback = 8, | |||||
kPortRegistrationOffCallback = 9, | |||||
kPortConnectCallback = 10, | |||||
kPortDisconnectCallback = 11, | |||||
kDeadClient = 12, | |||||
kMaxNotification | |||||
}; | |||||
enum NotificationType { | |||||
kAddClient = 0, | |||||
kRemoveClient = 1, | |||||
kActivateClient = 2, | |||||
kXRunCallback = 3, | |||||
kGraphOrderCallback = 4, | |||||
kBufferSizeCallback = 5, | |||||
kStartFreewheelCallback = 6, | |||||
kStopFreewheelCallback = 7, | |||||
kPortRegistrationOnCallback = 8, | |||||
kPortRegistrationOffCallback = 9, | |||||
kPortConnectCallback = 10, | |||||
kPortDisconnectCallback = 11, | |||||
kDeadClient = 12, | |||||
kMaxNotification | |||||
}; | |||||
} // end of namespace | } // end of namespace | ||||
@@ -39,14 +39,14 @@ bool JackPort::Allocate(int refnum, const char* port_name, const char* port_type | |||||
{ | { | ||||
int id = GetPortTypeId(port_type); | int id = GetPortTypeId(port_type); | ||||
if (id < 0) | if (id < 0) | ||||
return false; | |||||
return false; | |||||
fTypeId = id; | fTypeId = id; | ||||
fFlags = flags; | fFlags = flags; | ||||
fRefNum = refnum; | fRefNum = refnum; | ||||
strcpy(fName, port_name); | strcpy(fName, port_name); | ||||
fInUse = true; | fInUse = true; | ||||
fLatency = 0; | fLatency = 0; | ||||
fTotalLatency = 0; | |||||
fTotalLatency = 0; | |||||
fTied = NO_PORT; | fTied = NO_PORT; | ||||
// DB: At this point we do not know current buffer size in frames, | // DB: At this point we do not know current buffer size in frames, | ||||
// but every time buffer will be returned to any user, | // but every time buffer will be returned to any user, | ||||
@@ -64,10 +64,10 @@ void JackPort::Release() | |||||
fRefNum = -1; | fRefNum = -1; | ||||
fInUse = false; | fInUse = false; | ||||
fLatency = 0; | fLatency = 0; | ||||
fTotalLatency = 0; | |||||
fTotalLatency = 0; | |||||
fTied = NO_PORT; | fTied = NO_PORT; | ||||
fAlias1[0] = '\0'; | |||||
fAlias2[0] = '\0'; | |||||
fAlias1[0] = '\0'; | |||||
fAlias2[0] = '\0'; | |||||
} | } | ||||
bool JackPort::IsUsed() const | bool JackPort::IsUsed() const | ||||
@@ -170,7 +170,7 @@ const char* JackPort::GetShortName() const | |||||
{ | { | ||||
/* we know there is always a colon, because we put | /* we know there is always a colon, because we put | ||||
it there ... | it there ... | ||||
*/ | |||||
*/ | |||||
return strchr(fName, ':') + 1; | return strchr(fName, ':') + 1; | ||||
} | } | ||||
@@ -195,66 +195,66 @@ int JackPort::SetName(const char* new_name) | |||||
bool JackPort::NameEquals(const char* target) | bool JackPort::NameEquals(const char* target) | ||||
{ | { | ||||
char buf[JACK_PORT_NAME_SIZE + 1]; | |||||
/* this nasty, nasty kludge is here because between 0.109.0 and 0.109.1, | |||||
the ALSA audio backend had the name "ALSA", whereas as before and | |||||
after it, it was called "alsa_pcm". this stops breakage for | |||||
any setups that have saved "alsa_pcm" or "ALSA" in their connection | |||||
state. | |||||
*/ | |||||
if (strncmp(target, "ALSA:capture", 12) == 0 || strncmp(target, "ALSA:playback", 13) == 0) { | |||||
snprintf(buf, sizeof(buf), "alsa_pcm%s", target + 4); | |||||
target = buf; | |||||
} | |||||
return (strcmp(fName, target) == 0 | |||||
|| strcmp(fAlias1, target) == 0 | |||||
|| strcmp(fAlias2, target) == 0); | |||||
char buf[JACK_PORT_NAME_SIZE + 1]; | |||||
/* this nasty, nasty kludge is here because between 0.109.0 and 0.109.1, | |||||
the ALSA audio backend had the name "ALSA", whereas as before and | |||||
after it, it was called "alsa_pcm". this stops breakage for | |||||
any setups that have saved "alsa_pcm" or "ALSA" in their connection | |||||
state. | |||||
*/ | |||||
if (strncmp(target, "ALSA:capture", 12) == 0 || strncmp(target, "ALSA:playback", 13) == 0) { | |||||
snprintf(buf, sizeof(buf), "alsa_pcm%s", target + 4); | |||||
target = buf; | |||||
} | |||||
return (strcmp(fName, target) == 0 | |||||
|| strcmp(fAlias1, target) == 0 | |||||
|| strcmp(fAlias2, target) == 0); | |||||
} | } | ||||
int JackPort::GetAliases(char* const aliases[2]) | int JackPort::GetAliases(char* const aliases[2]) | ||||
{ | { | ||||
int cnt = 0; | |||||
if (fAlias1[0] != '\0') { | |||||
snprintf(aliases[0], JACK_CLIENT_NAME_SIZE + JACK_PORT_NAME_SIZE, "%s", fAlias1); | |||||
cnt++; | |||||
} | |||||
if (fAlias2[0] != '\0') { | |||||
snprintf(aliases[1], JACK_CLIENT_NAME_SIZE + JACK_PORT_NAME_SIZE, "%s", fAlias2); | |||||
cnt++; | |||||
} | |||||
return cnt; | |||||
int cnt = 0; | |||||
if (fAlias1[0] != '\0') { | |||||
snprintf(aliases[0], JACK_CLIENT_NAME_SIZE + JACK_PORT_NAME_SIZE, "%s", fAlias1); | |||||
cnt++; | |||||
} | |||||
if (fAlias2[0] != '\0') { | |||||
snprintf(aliases[1], JACK_CLIENT_NAME_SIZE + JACK_PORT_NAME_SIZE, "%s", fAlias2); | |||||
cnt++; | |||||
} | |||||
return cnt; | |||||
} | } | ||||
int JackPort::SetAlias(const char* alias) | int JackPort::SetAlias(const char* alias) | ||||
{ | { | ||||
if (fAlias1[0] == '\0') { | |||||
snprintf(fAlias1, sizeof(fAlias1), "%s", alias); | |||||
} else if (fAlias2[0] == '\0') { | |||||
snprintf(fAlias2, sizeof(fAlias2), "%s", alias); | |||||
} else { | |||||
return -1; | |||||
} | |||||
return 0; | |||||
if (fAlias1[0] == '\0') { | |||||
snprintf(fAlias1, sizeof(fAlias1), "%s", alias); | |||||
} else if (fAlias2[0] == '\0') { | |||||
snprintf(fAlias2, sizeof(fAlias2), "%s", alias); | |||||
} else { | |||||
return -1; | |||||
} | |||||
return 0; | |||||
} | } | ||||
int JackPort::UnsetAlias(const char* alias) | int JackPort::UnsetAlias(const char* alias) | ||||
{ | { | ||||
if (strcmp(fAlias1, alias) == 0) { | |||||
fAlias1[0] = '\0'; | |||||
} else if (strcmp(fAlias2, alias) == 0) { | |||||
fAlias2[0] = '\0'; | |||||
} else { | |||||
return -1; | |||||
} | |||||
return 0; | |||||
if (strcmp(fAlias1, alias) == 0) { | |||||
fAlias1[0] = '\0'; | |||||
} else if (strcmp(fAlias2, alias) == 0) { | |||||
fAlias2[0] = '\0'; | |||||
} else { | |||||
return -1; | |||||
} | |||||
return 0; | |||||
} | } | ||||
void JackPort::ClearBuffer(jack_nframes_t frames) | void JackPort::ClearBuffer(jack_nframes_t frames) | ||||
@@ -1,6 +1,6 @@ | |||||
/* | /* | ||||
Copyright (C) 2001 Paul Davis | Copyright (C) 2001 Paul Davis | ||||
Copyright (C) 2004-2008 Grame | |||||
Copyright (C) 2004-2008 Grame | |||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
it under the terms of the GNU General Public License as published by | it under the terms of the GNU General Public License as published by | ||||
@@ -31,7 +31,7 @@ namespace Jack | |||||
#define NO_PORT 0xFFFE | #define NO_PORT 0xFFFE | ||||
/*! | /*! | ||||
\brief Base class for port. | |||||
\brief Base class for port. | |||||
*/ | */ | ||||
class JackPort | class JackPort | ||||
@@ -44,30 +44,30 @@ class JackPort | |||||
int fTypeId; | int fTypeId; | ||||
enum JackPortFlags fFlags; | enum JackPortFlags fFlags; | ||||
char fName[JACK_CLIENT_NAME_SIZE + JACK_PORT_NAME_SIZE]; | char fName[JACK_CLIENT_NAME_SIZE + JACK_PORT_NAME_SIZE]; | ||||
char fAlias1[JACK_CLIENT_NAME_SIZE + JACK_PORT_NAME_SIZE]; | |||||
char fAlias2[JACK_CLIENT_NAME_SIZE + JACK_PORT_NAME_SIZE]; | |||||
char fAlias1[JACK_CLIENT_NAME_SIZE + JACK_PORT_NAME_SIZE]; | |||||
char fAlias2[JACK_CLIENT_NAME_SIZE + JACK_PORT_NAME_SIZE]; | |||||
int fRefNum; | int fRefNum; | ||||
jack_nframes_t fLatency; | jack_nframes_t fLatency; | ||||
jack_nframes_t fTotalLatency; | |||||
jack_nframes_t fTotalLatency; | |||||
uint8_t fMonitorRequests; | uint8_t fMonitorRequests; | ||||
bool fInUse; | bool fInUse; | ||||
jack_port_id_t fTied; // Locally tied source port | jack_port_id_t fTied; // Locally tied source port | ||||
#ifdef WIN32 | |||||
#ifdef WIN32 | |||||
//__declspec(align(16)) float fBuffer[BUFFER_SIZE_MAX]; | //__declspec(align(16)) float fBuffer[BUFFER_SIZE_MAX]; | ||||
float fBuffer[BUFFER_SIZE_MAX]; | |||||
#elif __GNUC__ | |||||
float fBuffer[BUFFER_SIZE_MAX] __attribute__((aligned(64))); // 16 bytes alignment for vector code, 64 bytes better for cache loads/stores | |||||
#else | |||||
#warning Buffer will not be aligned on 16 bytes boundaries : vector based code (Altivec of SSE) will fail | |||||
float fBuffer[BUFFER_SIZE_MAX]; | |||||
#endif | |||||
float fBuffer[BUFFER_SIZE_MAX]; | |||||
#elif __GNUC__ | |||||
float fBuffer[BUFFER_SIZE_MAX] __attribute__((aligned(64))); // 16 bytes alignment for vector code, 64 bytes better for cache loads/stores | |||||
#else | |||||
#warning Buffer will not be aligned on 16 bytes boundaries : vector based code (Altivec of SSE) will fail | |||||
float fBuffer[BUFFER_SIZE_MAX]; | |||||
#endif | |||||
bool IsUsed() const; | bool IsUsed() const; | ||||
// RT | |||||
// RT | |||||
void ClearBuffer(jack_nframes_t frames); | void ClearBuffer(jack_nframes_t frames); | ||||
void MixBuffers(void** src_buffers, int src_count, jack_nframes_t frames); | void MixBuffers(void** src_buffers, int src_count, jack_nframes_t frames); | ||||
@@ -81,20 +81,20 @@ class JackPort | |||||
const char* GetName() const; | const char* GetName() const; | ||||
const char* GetShortName() const; | const char* GetShortName() const; | ||||
int SetName(const char* name); | int SetName(const char* name); | ||||
int GetAliases(char* const aliases[2]); | |||||
int SetAlias(const char* alias); | |||||
int UnsetAlias(const char* alias); | |||||
bool NameEquals(const char* target); | |||||
int GetAliases(char* const aliases[2]); | |||||
int SetAlias(const char* alias); | |||||
int UnsetAlias(const char* alias); | |||||
bool NameEquals(const char* target); | |||||
int GetFlags() const; | int GetFlags() const; | ||||
const char* GetType() const; | const char* GetType() const; | ||||
int Tie(jack_port_id_t port_index); | |||||
int Tie(jack_port_id_t port_index); | |||||
int UnTie(); | int UnTie(); | ||||
jack_nframes_t GetLatency() const; | jack_nframes_t GetLatency() const; | ||||
jack_nframes_t GetTotalLatency() const; | |||||
jack_nframes_t GetTotalLatency() const; | |||||
void SetLatency(jack_nframes_t latency); | void SetLatency(jack_nframes_t latency); | ||||
int RequestMonitor(bool onoff); | int RequestMonitor(bool onoff); | ||||
@@ -103,7 +103,7 @@ class JackPort | |||||
float* GetBuffer(); | float* GetBuffer(); | ||||
int GetRefNum() const; | int GetRefNum() const; | ||||
}; | }; | ||||
@@ -24,27 +24,31 @@ This program is free software; you can redistribute it and/or modify | |||||
namespace Jack | namespace Jack | ||||
{ | { | ||||
static const JackPortType* port_types[] = { | |||||
&gAudioPortType, | |||||
&gMidiPortType, | |||||
}; | |||||
static const JackPortType* port_types[] = | |||||
{ | |||||
&gAudioPortType, | |||||
&gMidiPortType, | |||||
}; | |||||
enum { PORT_TYPES_MAX = sizeof(port_types)/sizeof(port_types[0]) }; | |||||
enum | |||||
{ | |||||
PORT_TYPES_MAX = sizeof(port_types) / sizeof(port_types[0]) | |||||
}; | |||||
int GetPortTypeId(const char* port_type) | int GetPortTypeId(const char* port_type) | ||||
{ | { | ||||
for (int i = 0; i < PORT_TYPES_MAX; ++i) { | for (int i = 0; i < PORT_TYPES_MAX; ++i) { | ||||
const JackPortType* type = port_types[i]; | const JackPortType* type = port_types[i]; | ||||
assert(type != 0); | |||||
assert(type != 0); | |||||
if (strcmp(port_type, type->name) == 0) | if (strcmp(port_type, type->name) == 0) | ||||
return i; | |||||
return i; | |||||
} | } | ||||
return -1; | return -1; | ||||
} | } | ||||
const JackPortType* GetPortType(int type_id) | const JackPortType* GetPortType(int type_id) | ||||
{ | { | ||||
assert(type_id >= 0 && type_id <= PORT_TYPES_MAX); | |||||
assert(type_id >= 0 && type_id <= PORT_TYPES_MAX); | |||||
const JackPortType* type = port_types[type_id]; | const JackPortType* type = port_types[type_id]; | ||||
assert(type != 0); | assert(type != 0); | ||||
return type; | return type; | ||||
@@ -27,7 +27,8 @@ This program is free software; you can redistribute it and/or modify | |||||
namespace Jack | namespace Jack | ||||
{ | { | ||||
struct JackPortType { | |||||
struct JackPortType | |||||
{ | |||||
const char* name; | const char* name; | ||||
void (*init)(void* buffer, size_t buffer_size, jack_nframes_t nframes); | void (*init)(void* buffer, size_t buffer_size, jack_nframes_t nframes); | ||||
void (*mixdown)(void *mixbuffer, void** src_buffers, int src_count, jack_nframes_t nframes); | void (*mixdown)(void *mixbuffer, void** src_buffers, int src_count, jack_nframes_t nframes); | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2004-2008 Grame | |||||
Copyright (C) 2004-2008 Grame | |||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
it under the terms of the GNU General Public License as published by | it under the terms of the GNU General Public License as published by | ||||
@@ -34,11 +34,11 @@ void JackPosixSemaphore::BuildName(const char* name, const char* server_name, ch | |||||
bool JackPosixSemaphore::Signal() | bool JackPosixSemaphore::Signal() | ||||
{ | { | ||||
int res; | int res; | ||||
if (!fSemaphore) { | |||||
jack_error("JackPosixSemaphore::Signal name = %s already desallocated!!", fName); | |||||
return false; | |||||
} | |||||
if (!fSemaphore) { | |||||
jack_error("JackPosixSemaphore::Signal name = %s already desallocated!!", fName); | |||||
return false; | |||||
} | |||||
if (fFlush) | if (fFlush) | ||||
return true; | return true; | ||||
@@ -52,11 +52,11 @@ bool JackPosixSemaphore::Signal() | |||||
bool JackPosixSemaphore::SignalAll() | bool JackPosixSemaphore::SignalAll() | ||||
{ | { | ||||
int res; | int res; | ||||
if (!fSemaphore) { | if (!fSemaphore) { | ||||
jack_error("JackPosixSemaphore::SignalAll name = %s already desallocated!!", fName); | |||||
return false; | |||||
} | |||||
jack_error("JackPosixSemaphore::SignalAll name = %s already desallocated!!", fName); | |||||
return false; | |||||
} | |||||
if (fFlush) | if (fFlush) | ||||
return true; | return true; | ||||
@@ -71,7 +71,7 @@ bool JackPosixSemaphore::SignalAll() | |||||
bool JackPosixSemaphore::Wait() | bool JackPosixSemaphore::Wait() | ||||
{ | { | ||||
int res; | int res; | ||||
if (!fSemaphore) { | if (!fSemaphore) { | ||||
jack_error("JackPosixSemaphore::Wait name = %s already desallocated!!", fName); | jack_error("JackPosixSemaphore::Wait name = %s already desallocated!!", fName); | ||||
return false; | return false; | ||||
@@ -99,13 +99,13 @@ bool JackPosixSemaphore::Wait() | |||||
/* | /* | ||||
#ifdef __linux__ | #ifdef __linux__ | ||||
bool JackPosixSemaphore::TimedWait(long usec) // unusable semantic !! | bool JackPosixSemaphore::TimedWait(long usec) // unusable semantic !! | ||||
{ | { | ||||
int res; | int res; | ||||
struct timeval now; | struct timeval now; | ||||
timespec time; | timespec time; | ||||
if (!fSemaphore) { | if (!fSemaphore) { | ||||
jack_error("JackPosixSemaphore::TimedWait name = %s already desallocated!!", fName); | jack_error("JackPosixSemaphore::TimedWait name = %s already desallocated!!", fName); | ||||
return false; | return false; | ||||
@@ -113,7 +113,7 @@ bool JackPosixSemaphore::TimedWait(long usec) // unusable semantic !! | |||||
gettimeofday(&now, 0); | gettimeofday(&now, 0); | ||||
time.tv_sec = now.tv_sec + usec / 1000000; | time.tv_sec = now.tv_sec + usec / 1000000; | ||||
time.tv_nsec = (now.tv_usec + (usec % 1000000)) * 1000; | time.tv_nsec = (now.tv_usec + (usec % 1000000)) * 1000; | ||||
if ((res = sem_timedwait(fSemaphore, &time)) != 0) { | if ((res = sem_timedwait(fSemaphore, &time)) != 0) { | ||||
jack_error("JackPosixSemaphore::TimedWait err = %s", strerror(errno)); | jack_error("JackPosixSemaphore::TimedWait err = %s", strerror(errno)); | ||||
JackLog("now %ld %ld \n", now.tv_sec, now.tv_usec); | JackLog("now %ld %ld \n", now.tv_sec, now.tv_usec); | ||||
@@ -121,15 +121,15 @@ bool JackPosixSemaphore::TimedWait(long usec) // unusable semantic !! | |||||
} | } | ||||
return (res == 0); | return (res == 0); | ||||
} | } | ||||
#else | |||||
#else | |||||
#warning "JackPosixSemaphore::TimedWait is not supported: Jack in SYNC mode with JackPosixSemaphore will not run properly !!" | #warning "JackPosixSemaphore::TimedWait is not supported: Jack in SYNC mode with JackPosixSemaphore will not run properly !!" | ||||
bool JackPosixSemaphore::TimedWait(long usec) | bool JackPosixSemaphore::TimedWait(long usec) | ||||
{ | { | ||||
return Wait(); | return Wait(); | ||||
} | } | ||||
#endif | |||||
#endif | |||||
*/ | */ | ||||
#warning JackPosixSemaphore::TimedWait not available : synchronous mode may not work correctly if POSIX semaphore are used | #warning JackPosixSemaphore::TimedWait not available : synchronous mode may not work correctly if POSIX semaphore are used | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2004-2008 Grame | |||||
Copyright (C) 2004-2008 Grame | |||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
it under the terms of the GNU General Public License as published by | it under the terms of the GNU General Public License as published by | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2004-2008 Grame | Copyright (C) 2004-2008 Grame | ||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
@@ -43,8 +43,8 @@ void* JackPosixThread::ThreadHandler(void* arg) | |||||
JackLog("ThreadHandler: start\n"); | JackLog("ThreadHandler: start\n"); | ||||
// If Init succeed, start the thread loop | |||||
bool res = true; | |||||
// If Init succeed, start the thread loop | |||||
bool res = true; | |||||
while (obj->fRunning && res) { | while (obj->fRunning && res) { | ||||
res = runnable->Execute(); | res = runnable->Execute(); | ||||
} | } | ||||
@@ -55,21 +55,21 @@ void* JackPosixThread::ThreadHandler(void* arg) | |||||
int JackPosixThread::Start() | int JackPosixThread::Start() | ||||
{ | { | ||||
fRunning = true; | |||||
// Check if the thread was correctly started | |||||
if (StartImp(&fThread, fPriority, fRealTime, ThreadHandler, this) < 0) { | |||||
fRunning = false; | |||||
return -1; | |||||
} else { | |||||
return 0; | |||||
} | |||||
fRunning = true; | |||||
// Check if the thread was correctly started | |||||
if (StartImp(&fThread, fPriority, fRealTime, ThreadHandler, this) < 0) { | |||||
fRunning = false; | |||||
return -1; | |||||
} else { | |||||
return 0; | |||||
} | |||||
} | } | ||||
int JackPosixThread::StartImp(pthread_t* thread, int priority, int realtime, void*(*start_routine)(void*), void* arg) | int JackPosixThread::StartImp(pthread_t* thread, int priority, int realtime, void*(*start_routine)(void*), void* arg) | ||||
{ | { | ||||
int res; | int res; | ||||
if (realtime) { | if (realtime) { | ||||
JackLog("Create RT thread\n"); | JackLog("Create RT thread\n"); | ||||
@@ -80,17 +80,17 @@ int JackPosixThread::StartImp(pthread_t* thread, int priority, int realtime, voi | |||||
pthread_attr_t attributes; | pthread_attr_t attributes; | ||||
struct sched_param rt_param; | struct sched_param rt_param; | ||||
pthread_attr_init(&attributes); | pthread_attr_init(&attributes); | ||||
if ((res = pthread_attr_setinheritsched(&attributes, PTHREAD_EXPLICIT_SCHED))) { | |||||
if ((res = pthread_attr_setinheritsched(&attributes, PTHREAD_EXPLICIT_SCHED))) { | |||||
jack_error("Cannot request explicit scheduling for RT thread %d %s", res, strerror(errno)); | jack_error("Cannot request explicit scheduling for RT thread %d %s", res, strerror(errno)); | ||||
return -1; | return -1; | ||||
} | } | ||||
if ((res = pthread_attr_setdetachstate(&attributes, PTHREAD_CREATE_JOINABLE))) { | if ((res = pthread_attr_setdetachstate(&attributes, PTHREAD_CREATE_JOINABLE))) { | ||||
jack_error("Cannot request joinable thread creation for RT thread %d %s", res, strerror(errno)); | jack_error("Cannot request joinable thread creation for RT thread %d %s", res, strerror(errno)); | ||||
return -1; | return -1; | ||||
} | } | ||||
if ((res = pthread_attr_setscope(&attributes, PTHREAD_SCOPE_SYSTEM))) { | if ((res = pthread_attr_setscope(&attributes, PTHREAD_SCOPE_SYSTEM))) { | ||||
jack_error("Cannot set scheduling scope for RT thread %d %s", res, strerror(errno)); | jack_error("Cannot set scheduling scope for RT thread %d %s", res, strerror(errno)); | ||||
return -1; | return -1; | ||||
@@ -102,18 +102,18 @@ int JackPosixThread::StartImp(pthread_t* thread, int priority, int realtime, voi | |||||
jack_error("Cannot set RR scheduling class for RT thread %d %s", res, strerror(errno)); | jack_error("Cannot set RR scheduling class for RT thread %d %s", res, strerror(errno)); | ||||
return -1; | return -1; | ||||
} | } | ||||
memset(&rt_param, 0, sizeof(rt_param)); | |||||
memset(&rt_param, 0, sizeof(rt_param)); | |||||
rt_param.sched_priority = priority; | rt_param.sched_priority = priority; | ||||
if ((res = pthread_attr_setschedparam(&attributes, &rt_param))) { | if ((res = pthread_attr_setschedparam(&attributes, &rt_param))) { | ||||
jack_error("Cannot set scheduling priority for RT thread %d %s", res, strerror(errno)); | jack_error("Cannot set scheduling priority for RT thread %d %s", res, strerror(errno)); | ||||
return -1; | return -1; | ||||
} | } | ||||
if ((res = pthread_attr_setstacksize(&attributes, THREAD_STACK))) { | |||||
jack_error("setting thread stack size%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; | |||||
} | } | ||||
if ((res = pthread_create(thread, &attributes, start_routine, arg))) { | if ((res = pthread_create(thread, &attributes, start_routine, arg))) { | ||||
@@ -146,8 +146,8 @@ int JackPosixThread::Kill() | |||||
void* status; | void* status; | ||||
pthread_cancel(fThread); | pthread_cancel(fThread); | ||||
pthread_join(fThread, &status); | pthread_join(fThread, &status); | ||||
fRunning = false; | |||||
fThread = (pthread_t)NULL; | |||||
fRunning = false; | |||||
fThread = (pthread_t)NULL; | |||||
return 0; | return 0; | ||||
} else { | } else { | ||||
return -1; | return -1; | ||||
@@ -161,7 +161,7 @@ int JackPosixThread::Stop() | |||||
void* status; | void* status; | ||||
fRunning = false; // Request for the thread to stop | fRunning = false; // Request for the thread to stop | ||||
pthread_join(fThread, &status); | pthread_join(fThread, &status); | ||||
fThread = (pthread_t)NULL; | |||||
fThread = (pthread_t)NULL; | |||||
return 0; | return 0; | ||||
} else { | } else { | ||||
return -1; | return -1; | ||||
@@ -170,18 +170,18 @@ int JackPosixThread::Stop() | |||||
int JackPosixThread::AcquireRealTime() | int JackPosixThread::AcquireRealTime() | ||||
{ | { | ||||
return (fThread) ? AcquireRealTimeImp(fThread, fPriority) : -1; | |||||
return (fThread) ? AcquireRealTimeImp(fThread, fPriority) : -1; | |||||
} | } | ||||
int JackPosixThread::AcquireRealTime(int priority) | int JackPosixThread::AcquireRealTime(int priority) | ||||
{ | { | ||||
fPriority = priority; | |||||
fPriority = priority; | |||||
return AcquireRealTime(); | return AcquireRealTime(); | ||||
} | } | ||||
int JackPosixThread::AcquireRealTimeImp(pthread_t thread, int priority) | int JackPosixThread::AcquireRealTimeImp(pthread_t thread, int priority) | ||||
{ | { | ||||
struct sched_param rtparam; | |||||
struct sched_param rtparam; | |||||
int res; | int res; | ||||
memset(&rtparam, 0, sizeof(rtparam)); | memset(&rtparam, 0, sizeof(rtparam)); | ||||
rtparam.sched_priority = priority; | rtparam.sched_priority = priority; | ||||
@@ -204,7 +204,7 @@ int JackPosixThread::DropRealTime() | |||||
int JackPosixThread::DropRealTimeImp(pthread_t thread) | int JackPosixThread::DropRealTimeImp(pthread_t thread) | ||||
{ | { | ||||
struct sched_param rtparam; | |||||
struct sched_param rtparam; | |||||
int res; | int res; | ||||
memset(&rtparam, 0, sizeof(rtparam)); | memset(&rtparam, 0, sizeof(rtparam)); | ||||
rtparam.sched_priority = 0; | rtparam.sched_priority = 0; | ||||
@@ -223,8 +223,8 @@ pthread_t JackPosixThread::GetThreadID() | |||||
void JackPosixThread::Terminate() | void JackPosixThread::Terminate() | ||||
{ | { | ||||
JackLog("JackPosixThread::Terminate\n"); | |||||
pthread_exit(0); | |||||
JackLog("JackPosixThread::Terminate\n"); | |||||
pthread_exit(0); | |||||
} | } | ||||
} // end of namespace | } // end of namespace | ||||
@@ -27,7 +27,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||||
namespace Jack | namespace Jack | ||||
{ | { | ||||
/* use 512KB stack per thread - the default is way too high to be feasible | |||||
/* use 512KB stack per thread - the default is way too high to be feasible | |||||
* with mlockall() on many systems */ | * with mlockall() on many systems */ | ||||
#define THREAD_STACK 524288 | #define THREAD_STACK 524288 | ||||
@@ -62,17 +62,17 @@ class JackPosixThread : public JackThread | |||||
virtual int StartSync(); | virtual int StartSync(); | ||||
virtual int Kill(); | virtual int Kill(); | ||||
virtual int Stop(); | virtual int Stop(); | ||||
virtual void Terminate(); | |||||
virtual void Terminate(); | |||||
virtual int AcquireRealTime(); | virtual int AcquireRealTime(); | ||||
virtual int AcquireRealTime(int priority); | virtual int AcquireRealTime(int priority); | ||||
virtual int DropRealTime(); | virtual int DropRealTime(); | ||||
pthread_t GetThreadID(); | pthread_t GetThreadID(); | ||||
static int AcquireRealTimeImp(pthread_t thread, int priority); | |||||
static int DropRealTimeImp(pthread_t thread); | |||||
static int StartImp(pthread_t* thread, int priority, int realtime, void*(*start_routine)(void*), void* arg); | |||||
static int AcquireRealTimeImp(pthread_t thread, int priority); | |||||
static int DropRealTimeImp(pthread_t thread); | |||||
static int StartImp(pthread_t* thread, int priority, int realtime, void*(*start_routine)(void*), void* arg); | |||||
}; | }; | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2004-2006 Grame | |||||
Copyright (C) 2004-2006 Grame | |||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
it under the terms of the GNU General Public License as published by | it under the terms of the GNU General Public License as published by | ||||
@@ -1,22 +1,22 @@ | |||||
/* | /* | ||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2001 Paul Davis | |||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
it under the terms of the GNU General Public License as published by | it under the terms of the GNU General Public License as published by | ||||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | ||||
(at your option) any later version. | (at your option) any later version. | ||||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | ||||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
GNU General Public License for more details. | GNU General Public License for more details. | ||||
You should have received a copy of the GNU General Public License | You should have received a copy of the GNU General Public License | ||||
along with this program; if not, write to the Free Software | along with this program; if not, write to the Free Software | ||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||||
*/ | */ | ||||
#ifndef __JackRequest__ | #ifndef __JackRequest__ | ||||
@@ -55,15 +55,15 @@ struct JackRequest | |||||
kSetTimebaseCallback = 13, | kSetTimebaseCallback = 13, | ||||
kSetBufferSize = 20, | kSetBufferSize = 20, | ||||
kSetFreeWheel = 21, | kSetFreeWheel = 21, | ||||
kClientCheck = 22, | |||||
kClientCheck = 22, | |||||
kClientOpen = 23, | kClientOpen = 23, | ||||
kClientClose = 24, | kClientClose = 24, | ||||
kConnectNamePorts = 25, | kConnectNamePorts = 25, | ||||
kDisconnectNamePorts = 26, | kDisconnectNamePorts = 26, | ||||
kGetInternalClientName = 27, | |||||
kInternalClientHandle = 28, | |||||
kInternalClientLoad = 29, | |||||
kInternalClientUnload = 30, | |||||
kGetInternalClientName = 27, | |||||
kInternalClientHandle = 28, | |||||
kInternalClientLoad = 29, | |||||
kInternalClientUnload = 30, | |||||
kNotification = 31 | kNotification = 31 | ||||
}; | }; | ||||
@@ -75,17 +75,17 @@ struct JackRequest | |||||
JackRequest(RequestType type): fType(type) | JackRequest(RequestType type): fType(type) | ||||
{} | {} | ||||
virtual ~JackRequest() | |||||
virtual ~JackRequest() | |||||
{} | {} | ||||
virtual int Read(JackChannelTransaction* trans) | |||||
virtual int Read(JackChannelTransaction* trans) | |||||
{ | { | ||||
return trans->Read(&fType, sizeof(RequestType)); | |||||
return trans->Read(&fType, sizeof(RequestType)); | |||||
} | } | ||||
virtual int Write(JackChannelTransaction* trans) | |||||
virtual int Write(JackChannelTransaction* trans) | |||||
{ | { | ||||
return trans->Write(&fType, sizeof(RequestType)); | |||||
return trans->Write(&fType, sizeof(RequestType)); | |||||
} | } | ||||
}; | }; | ||||
@@ -108,12 +108,12 @@ struct JackResult | |||||
virtual int Read(JackChannelTransaction* trans) | virtual int Read(JackChannelTransaction* trans) | ||||
{ | { | ||||
return trans->Read(&fResult, sizeof(int)); | |||||
return trans->Read(&fResult, sizeof(int)); | |||||
} | } | ||||
virtual int Write(JackChannelTransaction* trans) | virtual int Write(JackChannelTransaction* trans) | ||||
{ | { | ||||
return trans->Write(&fResult, sizeof(int)); | |||||
return trans->Write(&fResult, sizeof(int)); | |||||
} | } | ||||
}; | }; | ||||
@@ -125,29 +125,29 @@ struct JackClientCheckRequest : public JackRequest | |||||
{ | { | ||||
char fName[JACK_CLIENT_NAME_SIZE + 1]; | char fName[JACK_CLIENT_NAME_SIZE + 1]; | ||||
int fProtocol; | |||||
int fProtocol; | |||||
int fOptions; | int fOptions; | ||||
JackClientCheckRequest() | JackClientCheckRequest() | ||||
{} | {} | ||||
JackClientCheckRequest(const char* name, int protocol, int options): JackRequest(JackRequest::kClientCheck),fProtocol(protocol),fOptions(options) | |||||
JackClientCheckRequest(const char* name, int protocol, int options): JackRequest(JackRequest::kClientCheck), fProtocol(protocol), fOptions(options) | |||||
{ | { | ||||
snprintf(fName, sizeof(fName), "%s", name); | snprintf(fName, sizeof(fName), "%s", name); | ||||
} | } | ||||
int Read(JackChannelTransaction* trans) | int Read(JackChannelTransaction* trans) | ||||
{ | { | ||||
CheckRes(trans->Read(&fName, JACK_CLIENT_NAME_SIZE + 1)); | |||||
CheckRes(trans->Read(&fProtocol, sizeof(int))); | |||||
return trans->Read(&fOptions, sizeof(int)); | |||||
CheckRes(trans->Read(&fName, JACK_CLIENT_NAME_SIZE + 1)); | |||||
CheckRes(trans->Read(&fProtocol, sizeof(int))); | |||||
return trans->Read(&fOptions, sizeof(int)); | |||||
} | } | ||||
int Write(JackChannelTransaction* trans) | int Write(JackChannelTransaction* trans) | ||||
{ | { | ||||
CheckRes(JackRequest::Write(trans)); | |||||
CheckRes(trans->Write(&fName, JACK_CLIENT_NAME_SIZE + 1)); | |||||
CheckRes(trans->Write(&fProtocol, sizeof(int))); | |||||
return trans->Write(&fOptions, sizeof(int)); | |||||
CheckRes(JackRequest::Write(trans)); | |||||
CheckRes(trans->Write(&fName, JACK_CLIENT_NAME_SIZE + 1)); | |||||
CheckRes(trans->Write(&fProtocol, sizeof(int))); | |||||
return trans->Write(&fOptions, sizeof(int)); | |||||
} | } | ||||
}; | }; | ||||
@@ -158,31 +158,31 @@ struct JackClientCheckRequest : public JackRequest | |||||
struct JackClientCheckResult : public JackResult | struct JackClientCheckResult : public JackResult | ||||
{ | { | ||||
char fName[JACK_CLIENT_NAME_SIZE + 1]; | |||||
int fStatus; | |||||
char fName[JACK_CLIENT_NAME_SIZE + 1]; | |||||
int fStatus; | |||||
JackClientCheckResult():JackResult(),fStatus(0) | |||||
JackClientCheckResult(): JackResult(), fStatus(0) | |||||
{} | {} | ||||
JackClientCheckResult(int32_t result, const char* name, int status) | JackClientCheckResult(int32_t result, const char* name, int status) | ||||
: JackResult(result), fStatus(status) | |||||
: JackResult(result), fStatus(status) | |||||
{ | { | ||||
snprintf(fName, sizeof(fName), "%s", name); | |||||
} | |||||
snprintf(fName, sizeof(fName), "%s", name); | |||||
} | |||||
int Read(JackChannelTransaction* trans) | |||||
int Read(JackChannelTransaction* trans) | |||||
{ | { | ||||
CheckRes(JackResult::Read(trans)); | |||||
CheckRes(trans->Read(&fName, JACK_CLIENT_NAME_SIZE + 1)); | |||||
CheckRes(trans->Read(&fStatus, sizeof(int))); | |||||
return 0; | |||||
CheckRes(JackResult::Read(trans)); | |||||
CheckRes(trans->Read(&fName, JACK_CLIENT_NAME_SIZE + 1)); | |||||
CheckRes(trans->Read(&fStatus, sizeof(int))); | |||||
return 0; | |||||
} | } | ||||
int Write(JackChannelTransaction* trans) | int Write(JackChannelTransaction* trans) | ||||
{ | { | ||||
CheckRes(JackResult::Write(trans)); | |||||
CheckRes(trans->Write(&fName, JACK_CLIENT_NAME_SIZE + 1)); | |||||
CheckRes(trans->Write(&fStatus, sizeof(int))); | |||||
return 0; | |||||
CheckRes(JackResult::Write(trans)); | |||||
CheckRes(trans->Write(&fName, JACK_CLIENT_NAME_SIZE + 1)); | |||||
CheckRes(trans->Write(&fStatus, sizeof(int))); | |||||
return 0; | |||||
} | } | ||||
}; | }; | ||||
@@ -204,13 +204,13 @@ struct JackClientOpenRequest : public JackRequest | |||||
int Read(JackChannelTransaction* trans) | int Read(JackChannelTransaction* trans) | ||||
{ | { | ||||
return trans->Read(&fName, JACK_CLIENT_NAME_SIZE + 1); | |||||
return trans->Read(&fName, JACK_CLIENT_NAME_SIZE + 1); | |||||
} | } | ||||
int Write(JackChannelTransaction* trans) | int Write(JackChannelTransaction* trans) | ||||
{ | { | ||||
CheckRes(JackRequest::Write(trans)); | |||||
return trans->Write(&fName, JACK_CLIENT_NAME_SIZE + 1); | |||||
CheckRes(JackRequest::Write(trans)); | |||||
return trans->Write(&fName, JACK_CLIENT_NAME_SIZE + 1); | |||||
} | } | ||||
}; | }; | ||||
@@ -227,30 +227,30 @@ struct JackClientOpenResult : public JackResult | |||||
uint32_t fProtocolVersion; | uint32_t fProtocolVersion; | ||||
JackClientOpenResult() | JackClientOpenResult() | ||||
:JackResult(),fSharedEngine(-1), fSharedClient(-1), fSharedGraph(-1), fProtocolVersion(0) | |||||
: JackResult(), fSharedEngine(-1), fSharedClient(-1), fSharedGraph(-1), fProtocolVersion(0) | |||||
{} | {} | ||||
JackClientOpenResult(int32_t result, int index1, int index2, int index3) | JackClientOpenResult(int32_t result, int index1, int index2, int index3) | ||||
: JackResult(result), fSharedEngine(index1), fSharedClient(index2), fSharedGraph(index3), fProtocolVersion(0) | |||||
: JackResult(result), fSharedEngine(index1), fSharedClient(index2), fSharedGraph(index3), fProtocolVersion(0) | |||||
{} | {} | ||||
int Read(JackChannelTransaction* trans) | |||||
int Read(JackChannelTransaction* trans) | |||||
{ | { | ||||
CheckRes(JackResult::Read(trans)); | |||||
CheckRes(trans->Read(&fSharedEngine, sizeof(int))); | |||||
CheckRes(trans->Read(&fSharedClient, sizeof(int))); | |||||
CheckRes(trans->Read(&fSharedGraph, sizeof(int))); | |||||
CheckRes(trans->Read(&fProtocolVersion, sizeof(uint32_t))); | |||||
return 0; | |||||
CheckRes(JackResult::Read(trans)); | |||||
CheckRes(trans->Read(&fSharedEngine, sizeof(int))); | |||||
CheckRes(trans->Read(&fSharedClient, sizeof(int))); | |||||
CheckRes(trans->Read(&fSharedGraph, sizeof(int))); | |||||
CheckRes(trans->Read(&fProtocolVersion, sizeof(uint32_t))); | |||||
return 0; | |||||
} | } | ||||
int Write(JackChannelTransaction* trans) | int Write(JackChannelTransaction* trans) | ||||
{ | { | ||||
CheckRes(JackResult::Write(trans)); | |||||
CheckRes(trans->Write(&fSharedEngine, sizeof(int))); | |||||
CheckRes(trans->Write(&fSharedClient, sizeof(int))); | |||||
CheckRes(trans->Write(&fSharedGraph, sizeof(int))); | |||||
CheckRes(trans->Write(&fProtocolVersion, sizeof(uint32_t))); | |||||
return 0; | |||||
CheckRes(JackResult::Write(trans)); | |||||
CheckRes(trans->Write(&fSharedEngine, sizeof(int))); | |||||
CheckRes(trans->Write(&fSharedClient, sizeof(int))); | |||||
CheckRes(trans->Write(&fSharedGraph, sizeof(int))); | |||||
CheckRes(trans->Write(&fProtocolVersion, sizeof(uint32_t))); | |||||
return 0; | |||||
} | } | ||||
}; | }; | ||||
@@ -270,13 +270,13 @@ struct JackClientCloseRequest : public JackRequest | |||||
int Read(JackChannelTransaction* trans) | int Read(JackChannelTransaction* trans) | ||||
{ | { | ||||
return trans->Read(&fRefNum, sizeof(int)); | |||||
return trans->Read(&fRefNum, sizeof(int)); | |||||
} | } | ||||
int Write(JackChannelTransaction* trans) | int Write(JackChannelTransaction* trans) | ||||
{ | { | ||||
CheckRes(JackRequest::Write(trans)); | |||||
return trans->Write(&fRefNum, sizeof(int)); | |||||
CheckRes(JackRequest::Write(trans)); | |||||
return trans->Write(&fRefNum, sizeof(int)); | |||||
} | } | ||||
}; | }; | ||||
@@ -296,13 +296,13 @@ struct JackActivateRequest : public JackRequest | |||||
int Read(JackChannelTransaction* trans) | int Read(JackChannelTransaction* trans) | ||||
{ | { | ||||
return trans->Read(&fRefNum, sizeof(int)); | |||||
return trans->Read(&fRefNum, sizeof(int)); | |||||
} | } | ||||
int Write(JackChannelTransaction* trans) | int Write(JackChannelTransaction* trans) | ||||
{ | { | ||||
CheckRes(JackRequest::Write(trans)); | |||||
return trans->Write(&fRefNum, sizeof(int)); | |||||
CheckRes(JackRequest::Write(trans)); | |||||
return trans->Write(&fRefNum, sizeof(int)); | |||||
} | } | ||||
}; | }; | ||||
@@ -323,13 +323,13 @@ struct JackDeactivateRequest : public JackRequest | |||||
int Read(JackChannelTransaction* trans) | int Read(JackChannelTransaction* trans) | ||||
{ | { | ||||
return trans->Read(&fRefNum, sizeof(int)); | |||||
return trans->Read(&fRefNum, sizeof(int)); | |||||
} | } | ||||
int Write(JackChannelTransaction* trans) | int Write(JackChannelTransaction* trans) | ||||
{ | { | ||||
CheckRes(JackRequest::Write(trans)); | |||||
return trans->Write(&fRefNum, sizeof(int)); | |||||
CheckRes(JackRequest::Write(trans)); | |||||
return trans->Write(&fRefNum, sizeof(int)); | |||||
} | } | ||||
}; | }; | ||||
@@ -358,23 +358,23 @@ struct JackPortRegisterRequest : public JackRequest | |||||
int Read(JackChannelTransaction* trans) | int Read(JackChannelTransaction* trans) | ||||
{ | { | ||||
CheckRes(trans->Read(&fRefNum, sizeof(int))); | |||||
CheckRes(trans->Read(&fName, JACK_PORT_NAME_SIZE + 1)); | |||||
CheckRes(trans->Read(&fPortType, JACK_PORT_TYPE_SIZE + 1)); | |||||
CheckRes(trans->Read(&fFlags, sizeof(unsigned int))); | |||||
CheckRes(trans->Read(&fBufferSize, sizeof(unsigned int))); | |||||
return 0; | |||||
CheckRes(trans->Read(&fRefNum, sizeof(int))); | |||||
CheckRes(trans->Read(&fName, JACK_PORT_NAME_SIZE + 1)); | |||||
CheckRes(trans->Read(&fPortType, JACK_PORT_TYPE_SIZE + 1)); | |||||
CheckRes(trans->Read(&fFlags, sizeof(unsigned int))); | |||||
CheckRes(trans->Read(&fBufferSize, sizeof(unsigned int))); | |||||
return 0; | |||||
} | } | ||||
int Write(JackChannelTransaction* trans) | int Write(JackChannelTransaction* trans) | ||||
{ | { | ||||
CheckRes(JackRequest::Write(trans)); | |||||
CheckRes(trans->Write(&fRefNum, sizeof(int))); | |||||
CheckRes(trans->Write(&fName, JACK_PORT_NAME_SIZE + 1)); | |||||
CheckRes(trans->Write(&fPortType, JACK_PORT_TYPE_SIZE + 1)); | |||||
CheckRes(trans->Write(&fFlags, sizeof(unsigned int))); | |||||
CheckRes(trans->Write(&fBufferSize, sizeof(unsigned int))); | |||||
return 0; | |||||
CheckRes(JackRequest::Write(trans)); | |||||
CheckRes(trans->Write(&fRefNum, sizeof(int))); | |||||
CheckRes(trans->Write(&fName, JACK_PORT_NAME_SIZE + 1)); | |||||
CheckRes(trans->Write(&fPortType, JACK_PORT_TYPE_SIZE + 1)); | |||||
CheckRes(trans->Write(&fFlags, sizeof(unsigned int))); | |||||
CheckRes(trans->Write(&fBufferSize, sizeof(unsigned int))); | |||||
return 0; | |||||
} | } | ||||
}; | }; | ||||
@@ -387,19 +387,19 @@ struct JackPortRegisterResult : public JackResult | |||||
unsigned int fPortIndex; | unsigned int fPortIndex; | ||||
JackPortRegisterResult():JackResult(),fPortIndex(NO_PORT) | |||||
JackPortRegisterResult(): JackResult(), fPortIndex(NO_PORT) | |||||
{} | {} | ||||
int Read(JackChannelTransaction* trans) | int Read(JackChannelTransaction* trans) | ||||
{ | { | ||||
CheckRes(JackResult::Read(trans)); | |||||
return trans->Read(&fPortIndex, sizeof(jack_port_id_t)); | |||||
CheckRes(JackResult::Read(trans)); | |||||
return trans->Read(&fPortIndex, sizeof(jack_port_id_t)); | |||||
} | } | ||||
int Write(JackChannelTransaction* trans) | int Write(JackChannelTransaction* trans) | ||||
{ | { | ||||
CheckRes(JackResult::Write(trans)); | |||||
return trans->Write(&fPortIndex, sizeof(jack_port_id_t)); | |||||
CheckRes(JackResult::Write(trans)); | |||||
return trans->Write(&fPortIndex, sizeof(jack_port_id_t)); | |||||
} | } | ||||
}; | }; | ||||
@@ -420,17 +420,17 @@ struct JackPortUnRegisterRequest : public JackRequest | |||||
int Read(JackChannelTransaction* trans) | int Read(JackChannelTransaction* trans) | ||||
{ | { | ||||
CheckRes(trans->Read(&fRefNum, sizeof(int))); | |||||
CheckRes(trans->Read(&fPortIndex, sizeof(int))); | |||||
return 0; | |||||
CheckRes(trans->Read(&fRefNum, sizeof(int))); | |||||
CheckRes(trans->Read(&fPortIndex, sizeof(int))); | |||||
return 0; | |||||
} | } | ||||
int Write(JackChannelTransaction* trans) | int Write(JackChannelTransaction* trans) | ||||
{ | { | ||||
CheckRes(JackRequest::Write(trans)); | |||||
CheckRes(trans->Write(&fRefNum, sizeof(int))); | |||||
CheckRes(trans->Write(&fPortIndex, sizeof(int))); | |||||
return 0; | |||||
CheckRes(JackRequest::Write(trans)); | |||||
CheckRes(trans->Write(&fRefNum, sizeof(int))); | |||||
CheckRes(trans->Write(&fPortIndex, sizeof(int))); | |||||
return 0; | |||||
} | } | ||||
}; | }; | ||||
@@ -440,7 +440,7 @@ struct JackPortUnRegisterRequest : public JackRequest | |||||
struct JackPortConnectNameRequest : public JackRequest | struct JackPortConnectNameRequest : public JackRequest | ||||
{ | { | ||||
int fRefNum; | int fRefNum; | ||||
char fSrc[JACK_PORT_NAME_SIZE + 1]; | char fSrc[JACK_PORT_NAME_SIZE + 1]; | ||||
char fDst[JACK_PORT_NAME_SIZE + 1]; | char fDst[JACK_PORT_NAME_SIZE + 1]; | ||||
@@ -455,20 +455,20 @@ struct JackPortConnectNameRequest : public JackRequest | |||||
int Read(JackChannelTransaction* trans) | int Read(JackChannelTransaction* trans) | ||||
{ | { | ||||
CheckRes(trans->Read(&fRefNum, sizeof(int))); | |||||
CheckRes(trans->Read(&fSrc, JACK_PORT_NAME_SIZE + 1)); | |||||
CheckRes(trans->Read(&fDst, JACK_PORT_NAME_SIZE + 1)); | |||||
return 0; | |||||
CheckRes(trans->Read(&fRefNum, sizeof(int))); | |||||
CheckRes(trans->Read(&fSrc, JACK_PORT_NAME_SIZE + 1)); | |||||
CheckRes(trans->Read(&fDst, JACK_PORT_NAME_SIZE + 1)); | |||||
return 0; | |||||
} | } | ||||
int Write(JackChannelTransaction* trans) | int Write(JackChannelTransaction* trans) | ||||
{ | { | ||||
CheckRes(JackRequest::Write(trans)); | |||||
CheckRes(trans->Write(&fRefNum, sizeof(int))); | |||||
CheckRes(trans->Write(&fSrc, JACK_PORT_NAME_SIZE + 1)); | |||||
CheckRes(trans->Write(&fDst, JACK_PORT_NAME_SIZE + 1)); | |||||
return 0; | |||||
CheckRes(JackRequest::Write(trans)); | |||||
CheckRes(trans->Write(&fRefNum, sizeof(int))); | |||||
CheckRes(trans->Write(&fSrc, JACK_PORT_NAME_SIZE + 1)); | |||||
CheckRes(trans->Write(&fDst, JACK_PORT_NAME_SIZE + 1)); | |||||
return 0; | |||||
} | } | ||||
}; | }; | ||||
@@ -493,19 +493,19 @@ struct JackPortDisconnectNameRequest : public JackRequest | |||||
int Read(JackChannelTransaction* trans) | int Read(JackChannelTransaction* trans) | ||||
{ | { | ||||
CheckRes(trans->Read(&fRefNum, sizeof(int))); | |||||
CheckRes(trans->Read(&fSrc, JACK_PORT_NAME_SIZE + 1)); | |||||
CheckRes(trans->Read(&fDst, JACK_PORT_NAME_SIZE + 1)); | |||||
return 0; | |||||
CheckRes(trans->Read(&fRefNum, sizeof(int))); | |||||
CheckRes(trans->Read(&fSrc, JACK_PORT_NAME_SIZE + 1)); | |||||
CheckRes(trans->Read(&fDst, JACK_PORT_NAME_SIZE + 1)); | |||||
return 0; | |||||
} | } | ||||
int Write(JackChannelTransaction* trans) | int Write(JackChannelTransaction* trans) | ||||
{ | { | ||||
CheckRes(JackRequest::Write(trans)); | |||||
CheckRes(trans->Write(&fRefNum, sizeof(int))); | |||||
CheckRes(trans->Write(&fSrc, JACK_PORT_NAME_SIZE + 1)); | |||||
CheckRes(trans->Write(&fDst, JACK_PORT_NAME_SIZE + 1)); | |||||
return 0; | |||||
CheckRes(JackRequest::Write(trans)); | |||||
CheckRes(trans->Write(&fRefNum, sizeof(int))); | |||||
CheckRes(trans->Write(&fSrc, JACK_PORT_NAME_SIZE + 1)); | |||||
CheckRes(trans->Write(&fDst, JACK_PORT_NAME_SIZE + 1)); | |||||
return 0; | |||||
} | } | ||||
}; | }; | ||||
@@ -527,19 +527,19 @@ struct JackPortConnectRequest : public JackRequest | |||||
int Read(JackChannelTransaction* trans) | int Read(JackChannelTransaction* trans) | ||||
{ | { | ||||
CheckRes(trans->Read(&fRefNum, sizeof(int))); | |||||
CheckRes(trans->Read(&fSrc, sizeof(jack_port_id_t))); | |||||
CheckRes(trans->Read(&fDst, sizeof(jack_port_id_t))); | |||||
return 0; | |||||
CheckRes(trans->Read(&fRefNum, sizeof(int))); | |||||
CheckRes(trans->Read(&fSrc, sizeof(jack_port_id_t))); | |||||
CheckRes(trans->Read(&fDst, sizeof(jack_port_id_t))); | |||||
return 0; | |||||
} | } | ||||
int Write(JackChannelTransaction* trans) | int Write(JackChannelTransaction* trans) | ||||
{ | { | ||||
CheckRes(JackRequest::Write(trans)); | |||||
CheckRes(trans->Write(&fRefNum, sizeof(int))); | |||||
CheckRes(trans->Write(&fSrc, sizeof(jack_port_id_t))); | |||||
CheckRes(trans->Write(&fDst, sizeof(jack_port_id_t))); | |||||
return 0; | |||||
CheckRes(JackRequest::Write(trans)); | |||||
CheckRes(trans->Write(&fRefNum, sizeof(int))); | |||||
CheckRes(trans->Write(&fSrc, sizeof(jack_port_id_t))); | |||||
CheckRes(trans->Write(&fDst, sizeof(jack_port_id_t))); | |||||
return 0; | |||||
} | } | ||||
}; | }; | ||||
@@ -562,19 +562,19 @@ struct JackPortDisconnectRequest : public JackRequest | |||||
int Read(JackChannelTransaction* trans) | int Read(JackChannelTransaction* trans) | ||||
{ | { | ||||
CheckRes(trans->Read(&fRefNum, sizeof(int))); | |||||
CheckRes(trans->Read(&fSrc, sizeof(jack_port_id_t))); | |||||
CheckRes(trans->Read(&fDst, sizeof(jack_port_id_t))); | |||||
return 0; | |||||
CheckRes(trans->Read(&fRefNum, sizeof(int))); | |||||
CheckRes(trans->Read(&fSrc, sizeof(jack_port_id_t))); | |||||
CheckRes(trans->Read(&fDst, sizeof(jack_port_id_t))); | |||||
return 0; | |||||
} | } | ||||
int Write(JackChannelTransaction* trans) | int Write(JackChannelTransaction* trans) | ||||
{ | { | ||||
CheckRes(JackRequest::Write(trans)); | |||||
CheckRes(trans->Write(&fRefNum, sizeof(int))); | |||||
CheckRes(trans->Write(&fSrc, sizeof(jack_port_id_t))); | |||||
CheckRes(trans->Write(&fDst, sizeof(jack_port_id_t))); | |||||
return 0; | |||||
CheckRes(JackRequest::Write(trans)); | |||||
CheckRes(trans->Write(&fRefNum, sizeof(int))); | |||||
CheckRes(trans->Write(&fSrc, sizeof(jack_port_id_t))); | |||||
CheckRes(trans->Write(&fDst, sizeof(jack_port_id_t))); | |||||
return 0; | |||||
} | } | ||||
}; | }; | ||||
@@ -595,13 +595,13 @@ struct JackSetBufferSizeRequest : public JackRequest | |||||
int Read(JackChannelTransaction* trans) | int Read(JackChannelTransaction* trans) | ||||
{ | { | ||||
return trans->Read(&fBufferSize, sizeof(jack_nframes_t)); | |||||
return trans->Read(&fBufferSize, sizeof(jack_nframes_t)); | |||||
} | } | ||||
int Write(JackChannelTransaction* trans) | int Write(JackChannelTransaction* trans) | ||||
{ | { | ||||
CheckRes(JackRequest::Write(trans)); | |||||
return trans->Write(&fBufferSize, sizeof(jack_nframes_t)); | |||||
CheckRes(JackRequest::Write(trans)); | |||||
return trans->Write(&fBufferSize, sizeof(jack_nframes_t)); | |||||
} | } | ||||
}; | }; | ||||
@@ -621,13 +621,13 @@ struct JackSetFreeWheelRequest : public JackRequest | |||||
int Read(JackChannelTransaction* trans) | int Read(JackChannelTransaction* trans) | ||||
{ | { | ||||
return trans->Read(&fOnOff, sizeof(int)); | |||||
return trans->Read(&fOnOff, sizeof(int)); | |||||
} | } | ||||
int Write(JackChannelTransaction* trans) | int Write(JackChannelTransaction* trans) | ||||
{ | { | ||||
CheckRes(JackRequest::Write(trans)); | |||||
return trans->Write(&fOnOff, sizeof(int)); | |||||
CheckRes(JackRequest::Write(trans)); | |||||
return trans->Write(&fOnOff, sizeof(int)); | |||||
} | } | ||||
}; | }; | ||||
@@ -647,13 +647,13 @@ struct JackReleaseTimebaseRequest : public JackRequest | |||||
int Read(JackChannelTransaction* trans) | int Read(JackChannelTransaction* trans) | ||||
{ | { | ||||
return trans->Read(&fRefNum, sizeof(int)); | |||||
return trans->Read(&fRefNum, sizeof(int)); | |||||
} | } | ||||
int Write(JackChannelTransaction* trans) | int Write(JackChannelTransaction* trans) | ||||
{ | { | ||||
CheckRes(JackRequest::Write(trans)); | |||||
return trans->Write(&fRefNum, sizeof(int)); | |||||
CheckRes(JackRequest::Write(trans)); | |||||
return trans->Write(&fRefNum, sizeof(int)); | |||||
} | } | ||||
}; | }; | ||||
@@ -674,15 +674,15 @@ struct JackSetTimebaseCallbackRequest : public JackRequest | |||||
int Read(JackChannelTransaction* trans) | int Read(JackChannelTransaction* trans) | ||||
{ | { | ||||
CheckRes(trans->Read(&fRefNum, sizeof(int))); | |||||
return trans->Read(&fConditionnal, sizeof(int)); | |||||
CheckRes(trans->Read(&fRefNum, sizeof(int))); | |||||
return trans->Read(&fConditionnal, sizeof(int)); | |||||
} | } | ||||
int Write(JackChannelTransaction* trans) | int Write(JackChannelTransaction* trans) | ||||
{ | { | ||||
CheckRes(JackRequest::Write(trans)); | |||||
CheckRes(trans->Write(&fRefNum, sizeof(int))); | |||||
return trans->Write(&fConditionnal, sizeof(int)); | |||||
CheckRes(JackRequest::Write(trans)); | |||||
CheckRes(trans->Write(&fRefNum, sizeof(int))); | |||||
return trans->Write(&fConditionnal, sizeof(int)); | |||||
} | } | ||||
}; | }; | ||||
@@ -693,26 +693,26 @@ struct JackSetTimebaseCallbackRequest : public JackRequest | |||||
struct JackGetInternalClientNameRequest : public JackRequest | struct JackGetInternalClientNameRequest : public JackRequest | ||||
{ | { | ||||
int fRefNum; | |||||
int fRefNum; | |||||
int fIntRefNum; | int fIntRefNum; | ||||
JackGetInternalClientNameRequest() | JackGetInternalClientNameRequest() | ||||
{} | {} | ||||
JackGetInternalClientNameRequest(int refnum, int int_ref) | JackGetInternalClientNameRequest(int refnum, int int_ref) | ||||
: JackRequest(JackRequest::kGetInternalClientName),fRefNum(refnum),fIntRefNum(int_ref) | |||||
: JackRequest(JackRequest::kGetInternalClientName), fRefNum(refnum), fIntRefNum(int_ref) | |||||
{} | {} | ||||
int Read(JackChannelTransaction* trans) | int Read(JackChannelTransaction* trans) | ||||
{ | { | ||||
CheckRes(trans->Read(&fRefNum, sizeof(int))); | |||||
return trans->Read(&fIntRefNum, sizeof(int)); | |||||
CheckRes(trans->Read(&fRefNum, sizeof(int))); | |||||
return trans->Read(&fIntRefNum, sizeof(int)); | |||||
} | } | ||||
int Write(JackChannelTransaction* trans) | int Write(JackChannelTransaction* trans) | ||||
{ | { | ||||
CheckRes(JackRequest::Write(trans)); | |||||
CheckRes(trans->Write(&fRefNum, sizeof(int))); | |||||
return trans->Write(&fIntRefNum, sizeof(int)); | |||||
CheckRes(JackRequest::Write(trans)); | |||||
CheckRes(trans->Write(&fRefNum, sizeof(int))); | |||||
return trans->Write(&fIntRefNum, sizeof(int)); | |||||
} | } | ||||
}; | }; | ||||
@@ -723,28 +723,28 @@ struct JackGetInternalClientNameRequest : public JackRequest | |||||
struct JackGetInternalClientNameResult : public JackResult | struct JackGetInternalClientNameResult : public JackResult | ||||
{ | { | ||||
char fName[JACK_CLIENT_NAME_SIZE + 1]; | |||||
char fName[JACK_CLIENT_NAME_SIZE + 1]; | |||||
JackGetInternalClientNameResult():JackResult() | |||||
JackGetInternalClientNameResult(): JackResult() | |||||
{} | {} | ||||
JackGetInternalClientNameResult(int32_t result, const char* name) | JackGetInternalClientNameResult(int32_t result, const char* name) | ||||
: JackResult(result) | |||||
: JackResult(result) | |||||
{ | { | ||||
snprintf(fName, sizeof(fName), "%s", name); | |||||
} | |||||
snprintf(fName, sizeof(fName), "%s", name); | |||||
} | |||||
int Read(JackChannelTransaction* trans) | |||||
int Read(JackChannelTransaction* trans) | |||||
{ | { | ||||
CheckRes(JackResult::Read(trans)); | |||||
CheckRes(trans->Read(&fName, JACK_CLIENT_NAME_SIZE + 1)); | |||||
return 0; | |||||
CheckRes(JackResult::Read(trans)); | |||||
CheckRes(trans->Read(&fName, JACK_CLIENT_NAME_SIZE + 1)); | |||||
return 0; | |||||
} | } | ||||
int Write(JackChannelTransaction* trans) | int Write(JackChannelTransaction* trans) | ||||
{ | { | ||||
CheckRes(JackResult::Write(trans)); | |||||
CheckRes(trans->Write(&fName, JACK_CLIENT_NAME_SIZE + 1)); | |||||
return 0; | |||||
CheckRes(JackResult::Write(trans)); | |||||
CheckRes(trans->Write(&fName, JACK_CLIENT_NAME_SIZE + 1)); | |||||
return 0; | |||||
} | } | ||||
}; | }; | ||||
@@ -755,28 +755,28 @@ struct JackGetInternalClientNameResult : public JackResult | |||||
struct JackInternalClientHandleRequest : public JackRequest | struct JackInternalClientHandleRequest : public JackRequest | ||||
{ | { | ||||
int fRefNum; | |||||
int fRefNum; | |||||
char fName[JACK_CLIENT_NAME_SIZE + 1]; | char fName[JACK_CLIENT_NAME_SIZE + 1]; | ||||
JackInternalClientHandleRequest() | JackInternalClientHandleRequest() | ||||
{} | {} | ||||
JackInternalClientHandleRequest(int refnum, const char* client_name) | JackInternalClientHandleRequest(int refnum, const char* client_name) | ||||
: JackRequest(JackRequest::kInternalClientHandle),fRefNum(refnum) | |||||
: JackRequest(JackRequest::kInternalClientHandle), fRefNum(refnum) | |||||
{ | { | ||||
snprintf(fName, sizeof(fName), "%s", client_name); | |||||
} | |||||
snprintf(fName, sizeof(fName), "%s", client_name); | |||||
} | |||||
int Read(JackChannelTransaction* trans) | int Read(JackChannelTransaction* trans) | ||||
{ | { | ||||
CheckRes(trans->Read(&fRefNum, sizeof(int))); | |||||
return trans->Read(&fName, JACK_CLIENT_NAME_SIZE + 1); | |||||
CheckRes(trans->Read(&fRefNum, sizeof(int))); | |||||
return trans->Read(&fName, JACK_CLIENT_NAME_SIZE + 1); | |||||
} | } | ||||
int Write(JackChannelTransaction* trans) | int Write(JackChannelTransaction* trans) | ||||
{ | { | ||||
CheckRes(JackRequest::Write(trans)); | |||||
CheckRes(trans->Write(&fRefNum, sizeof(int))); | |||||
return trans->Write(&fName, JACK_CLIENT_NAME_SIZE + 1); | |||||
CheckRes(JackRequest::Write(trans)); | |||||
CheckRes(trans->Write(&fRefNum, sizeof(int))); | |||||
return trans->Write(&fName, JACK_CLIENT_NAME_SIZE + 1); | |||||
} | } | ||||
}; | }; | ||||
@@ -787,29 +787,29 @@ struct JackInternalClientHandleRequest : public JackRequest | |||||
struct JackInternalClientHandleResult : public JackResult | struct JackInternalClientHandleResult : public JackResult | ||||
{ | { | ||||
int fStatus; | |||||
int fIntRefNum; | |||||
int fStatus; | |||||
int fIntRefNum; | |||||
JackInternalClientHandleResult():JackResult() | |||||
JackInternalClientHandleResult(): JackResult() | |||||
{} | {} | ||||
JackInternalClientHandleResult(int32_t result, int status, int int_ref) | JackInternalClientHandleResult(int32_t result, int status, int int_ref) | ||||
: JackResult(result),fStatus(status),fIntRefNum(int_ref) | |||||
: JackResult(result), fStatus(status), fIntRefNum(int_ref) | |||||
{} | {} | ||||
int Read(JackChannelTransaction* trans) | |||||
int Read(JackChannelTransaction* trans) | |||||
{ | { | ||||
CheckRes(JackResult::Read(trans)); | |||||
CheckRes(trans->Read(&fStatus, sizeof(int))); | |||||
CheckRes(trans->Read(&fIntRefNum, sizeof(int))); | |||||
return 0; | |||||
CheckRes(JackResult::Read(trans)); | |||||
CheckRes(trans->Read(&fStatus, sizeof(int))); | |||||
CheckRes(trans->Read(&fIntRefNum, sizeof(int))); | |||||
return 0; | |||||
} | } | ||||
int Write(JackChannelTransaction* trans) | int Write(JackChannelTransaction* trans) | ||||
{ | { | ||||
CheckRes(JackResult::Write(trans)); | |||||
CheckRes(trans->Write(&fStatus, sizeof(int))); | |||||
CheckRes(trans->Write(&fIntRefNum, sizeof(int))); | |||||
return 0; | |||||
CheckRes(JackResult::Write(trans)); | |||||
CheckRes(trans->Write(&fStatus, sizeof(int))); | |||||
CheckRes(trans->Write(&fIntRefNum, sizeof(int))); | |||||
return 0; | |||||
} | } | ||||
}; | }; | ||||
@@ -820,41 +820,41 @@ struct JackInternalClientHandleResult : public JackResult | |||||
struct JackInternalClientLoadRequest : public JackRequest | struct JackInternalClientLoadRequest : public JackRequest | ||||
{ | { | ||||
#define MAX_PATH 256 | |||||
int fRefNum; | |||||
#define MAX_PATH 256 | |||||
int fRefNum; | |||||
char fName[JACK_CLIENT_NAME_SIZE + 1]; | char fName[JACK_CLIENT_NAME_SIZE + 1]; | ||||
char fDllName[MAX_PATH + 1]; | |||||
char fLoadInitName[JACK_LOAD_INIT_LIMIT + 1]; | |||||
int fOptions; | |||||
char fDllName[MAX_PATH + 1]; | |||||
char fLoadInitName[JACK_LOAD_INIT_LIMIT + 1]; | |||||
int fOptions; | |||||
JackInternalClientLoadRequest() | JackInternalClientLoadRequest() | ||||
{} | {} | ||||
JackInternalClientLoadRequest(int refnum, const char* client_name, const char* so_name, const char* objet_data, int options) | JackInternalClientLoadRequest(int refnum, const char* client_name, const char* so_name, const char* objet_data, int options) | ||||
: JackRequest(JackRequest::kInternalClientLoad),fRefNum(refnum),fOptions(options) | |||||
: JackRequest(JackRequest::kInternalClientLoad), fRefNum(refnum), fOptions(options) | |||||
{ | { | ||||
snprintf(fName, sizeof(fName), "%s", client_name); | |||||
snprintf(fDllName, sizeof(fDllName), "%s", so_name); | |||||
snprintf(fLoadInitName, sizeof(fLoadInitName), "%s", objet_data); | |||||
} | |||||
snprintf(fName, sizeof(fName), "%s", client_name); | |||||
snprintf(fDllName, sizeof(fDllName), "%s", so_name); | |||||
snprintf(fLoadInitName, sizeof(fLoadInitName), "%s", objet_data); | |||||
} | |||||
int Read(JackChannelTransaction* trans) | int Read(JackChannelTransaction* trans) | ||||
{ | { | ||||
CheckRes(trans->Read(&fRefNum, sizeof(int))); | |||||
CheckRes(trans->Read(&fName, JACK_CLIENT_NAME_SIZE + 1)); | |||||
CheckRes(trans->Read(&fDllName, MAX_PATH + 1)); | |||||
CheckRes(trans->Read(&fLoadInitName, JACK_LOAD_INIT_LIMIT + 1)); | |||||
return trans->Read(&fOptions, sizeof(int)); | |||||
CheckRes(trans->Read(&fRefNum, sizeof(int))); | |||||
CheckRes(trans->Read(&fName, JACK_CLIENT_NAME_SIZE + 1)); | |||||
CheckRes(trans->Read(&fDllName, MAX_PATH + 1)); | |||||
CheckRes(trans->Read(&fLoadInitName, JACK_LOAD_INIT_LIMIT + 1)); | |||||
return trans->Read(&fOptions, sizeof(int)); | |||||
} | } | ||||
int Write(JackChannelTransaction* trans) | int Write(JackChannelTransaction* trans) | ||||
{ | { | ||||
CheckRes(JackRequest::Write(trans)); | |||||
CheckRes(trans->Write(&fRefNum, sizeof(int))); | |||||
CheckRes(trans->Write(&fName, JACK_CLIENT_NAME_SIZE + 1)); | |||||
CheckRes(trans->Write(&fDllName, MAX_PATH + 1)); | |||||
CheckRes(trans->Write(&fLoadInitName, JACK_LOAD_INIT_LIMIT + 1)); | |||||
return trans->Write(&fOptions, sizeof(int)); | |||||
CheckRes(JackRequest::Write(trans)); | |||||
CheckRes(trans->Write(&fRefNum, sizeof(int))); | |||||
CheckRes(trans->Write(&fName, JACK_CLIENT_NAME_SIZE + 1)); | |||||
CheckRes(trans->Write(&fDllName, MAX_PATH + 1)); | |||||
CheckRes(trans->Write(&fLoadInitName, JACK_LOAD_INIT_LIMIT + 1)); | |||||
return trans->Write(&fOptions, sizeof(int)); | |||||
} | } | ||||
}; | }; | ||||
@@ -865,29 +865,29 @@ struct JackInternalClientLoadRequest : public JackRequest | |||||
struct JackInternalClientLoadResult : public JackResult | struct JackInternalClientLoadResult : public JackResult | ||||
{ | { | ||||
int fStatus; | |||||
int fIntRefNum; | |||||
int fStatus; | |||||
int fIntRefNum; | |||||
JackInternalClientLoadResult():JackResult() | |||||
JackInternalClientLoadResult(): JackResult() | |||||
{} | {} | ||||
JackInternalClientLoadResult(int32_t result, int status, int int_ref) | JackInternalClientLoadResult(int32_t result, int status, int int_ref) | ||||
: JackResult(result),fStatus(status),fIntRefNum(int_ref) | |||||
: JackResult(result), fStatus(status), fIntRefNum(int_ref) | |||||
{} | {} | ||||
int Read(JackChannelTransaction* trans) | |||||
int Read(JackChannelTransaction* trans) | |||||
{ | { | ||||
CheckRes(JackResult::Read(trans)); | |||||
CheckRes(trans->Read(&fStatus, sizeof(int))); | |||||
CheckRes(trans->Read(&fIntRefNum, sizeof(int))); | |||||
return 0; | |||||
CheckRes(JackResult::Read(trans)); | |||||
CheckRes(trans->Read(&fStatus, sizeof(int))); | |||||
CheckRes(trans->Read(&fIntRefNum, sizeof(int))); | |||||
return 0; | |||||
} | } | ||||
int Write(JackChannelTransaction* trans) | int Write(JackChannelTransaction* trans) | ||||
{ | { | ||||
CheckRes(JackResult::Write(trans)); | |||||
CheckRes(trans->Write(&fStatus, sizeof(int))); | |||||
CheckRes(trans->Write(&fIntRefNum, sizeof(int))); | |||||
return 0; | |||||
CheckRes(JackResult::Write(trans)); | |||||
CheckRes(trans->Write(&fStatus, sizeof(int))); | |||||
CheckRes(trans->Write(&fIntRefNum, sizeof(int))); | |||||
return 0; | |||||
} | } | ||||
}; | }; | ||||
@@ -898,26 +898,26 @@ struct JackInternalClientLoadResult : public JackResult | |||||
struct JackInternalClientUnloadRequest : public JackRequest | struct JackInternalClientUnloadRequest : public JackRequest | ||||
{ | { | ||||
int fRefNum; | |||||
int fRefNum; | |||||
int fIntRefNum; | int fIntRefNum; | ||||
JackInternalClientUnloadRequest() | JackInternalClientUnloadRequest() | ||||
{} | {} | ||||
JackInternalClientUnloadRequest(int refnum, int int_ref) | JackInternalClientUnloadRequest(int refnum, int int_ref) | ||||
: JackRequest(JackRequest::kInternalClientUnload),fRefNum(refnum),fIntRefNum(int_ref) | |||||
: JackRequest(JackRequest::kInternalClientUnload), fRefNum(refnum), fIntRefNum(int_ref) | |||||
{} | {} | ||||
int Read(JackChannelTransaction* trans) | int Read(JackChannelTransaction* trans) | ||||
{ | { | ||||
CheckRes(trans->Read(&fRefNum, sizeof(int))); | |||||
return trans->Read(&fIntRefNum, sizeof(int)); | |||||
CheckRes(trans->Read(&fRefNum, sizeof(int))); | |||||
return trans->Read(&fIntRefNum, sizeof(int)); | |||||
} | } | ||||
int Write(JackChannelTransaction* trans) | int Write(JackChannelTransaction* trans) | ||||
{ | { | ||||
CheckRes(JackRequest::Write(trans)); | |||||
CheckRes(trans->Write(&fRefNum, sizeof(int))); | |||||
return trans->Write(&fIntRefNum, sizeof(int)); | |||||
CheckRes(JackRequest::Write(trans)); | |||||
CheckRes(trans->Write(&fRefNum, sizeof(int))); | |||||
return trans->Write(&fIntRefNum, sizeof(int)); | |||||
} | } | ||||
}; | }; | ||||
@@ -929,26 +929,26 @@ struct JackInternalClientUnloadRequest : public JackRequest | |||||
struct JackInternalClientUnloadResult : public JackResult | struct JackInternalClientUnloadResult : public JackResult | ||||
{ | { | ||||
int fStatus; | |||||
int fStatus; | |||||
JackInternalClientUnloadResult():JackResult() | |||||
JackInternalClientUnloadResult(): JackResult() | |||||
{} | {} | ||||
JackInternalClientUnloadResult(int32_t result, int status) | JackInternalClientUnloadResult(int32_t result, int status) | ||||
: JackResult(result),fStatus(status) | |||||
: JackResult(result), fStatus(status) | |||||
{} | {} | ||||
int Read(JackChannelTransaction* trans) | |||||
int Read(JackChannelTransaction* trans) | |||||
{ | { | ||||
CheckRes(JackResult::Read(trans)); | |||||
CheckRes(trans->Read(&fStatus, sizeof(int))); | |||||
return 0; | |||||
CheckRes(JackResult::Read(trans)); | |||||
CheckRes(trans->Read(&fStatus, sizeof(int))); | |||||
return 0; | |||||
} | } | ||||
int Write(JackChannelTransaction* trans) | int Write(JackChannelTransaction* trans) | ||||
{ | { | ||||
CheckRes(JackResult::Write(trans)); | |||||
CheckRes(trans->Write(&fStatus, sizeof(int))); | |||||
return 0; | |||||
CheckRes(JackResult::Write(trans)); | |||||
CheckRes(trans->Write(&fStatus, sizeof(int))); | |||||
return 0; | |||||
} | } | ||||
}; | }; | ||||
@@ -958,7 +958,7 @@ struct JackInternalClientUnloadResult : public JackResult | |||||
struct JackClientNotificationRequest : public JackRequest | struct JackClientNotificationRequest : public JackRequest | ||||
{ | { | ||||
int fRefNum; | int fRefNum; | ||||
int fNotify; | int fNotify; | ||||
int fValue; | int fValue; | ||||
@@ -971,19 +971,19 @@ struct JackClientNotificationRequest : public JackRequest | |||||
int Read(JackChannelTransaction* trans) | int Read(JackChannelTransaction* trans) | ||||
{ | { | ||||
CheckRes(trans->Read(&fRefNum, sizeof(int))); | |||||
CheckRes(trans->Read(&fNotify, sizeof(int))); | |||||
CheckRes(trans->Read(&fValue, sizeof(int))); | |||||
return 0; | |||||
CheckRes(trans->Read(&fRefNum, sizeof(int))); | |||||
CheckRes(trans->Read(&fNotify, sizeof(int))); | |||||
CheckRes(trans->Read(&fValue, sizeof(int))); | |||||
return 0; | |||||
} | } | ||||
int Write(JackChannelTransaction* trans) | int Write(JackChannelTransaction* trans) | ||||
{ | { | ||||
CheckRes(JackRequest::Write(trans)); | |||||
CheckRes(trans->Write(&fRefNum, sizeof(int))); | |||||
CheckRes(trans->Write(&fNotify, sizeof(int))); | |||||
CheckRes(trans->Write(&fValue, sizeof(int))); | |||||
return 0; | |||||
CheckRes(JackRequest::Write(trans)); | |||||
CheckRes(trans->Write(&fRefNum, sizeof(int))); | |||||
CheckRes(trans->Write(&fNotify, sizeof(int))); | |||||
CheckRes(trans->Write(&fValue, sizeof(int))); | |||||
return 0; | |||||
} | } | ||||
}; | }; | ||||
@@ -998,7 +998,7 @@ struct JackClientNotification | |||||
int fRefNum; | int fRefNum; | ||||
int fNotify; | int fNotify; | ||||
int fValue1; | int fValue1; | ||||
int fValue2; | |||||
int fValue2; | |||||
int fSync; | int fSync; | ||||
JackClientNotification(): fNotify(-1), fValue1(-1), fValue2(-1) | JackClientNotification(): fNotify(-1), fValue1(-1), fValue2(-1) | ||||
@@ -1011,24 +1011,24 @@ struct JackClientNotification | |||||
int Read(JackChannelTransaction* trans) | int Read(JackChannelTransaction* trans) | ||||
{ | { | ||||
CheckRes(trans->Read(&fName, JACK_CLIENT_NAME_SIZE + 1)); | |||||
CheckRes(trans->Read(&fRefNum, sizeof(int))); | |||||
CheckRes(trans->Read(&fNotify, sizeof(int))); | |||||
CheckRes(trans->Read(&fValue1, sizeof(int))); | |||||
CheckRes(trans->Read(&fValue2, sizeof(int))); | |||||
CheckRes(trans->Read(&fSync, sizeof(int))); | |||||
return 0; | |||||
CheckRes(trans->Read(&fName, JACK_CLIENT_NAME_SIZE + 1)); | |||||
CheckRes(trans->Read(&fRefNum, sizeof(int))); | |||||
CheckRes(trans->Read(&fNotify, sizeof(int))); | |||||
CheckRes(trans->Read(&fValue1, sizeof(int))); | |||||
CheckRes(trans->Read(&fValue2, sizeof(int))); | |||||
CheckRes(trans->Read(&fSync, sizeof(int))); | |||||
return 0; | |||||
} | } | ||||
int Write(JackChannelTransaction* trans) | int Write(JackChannelTransaction* trans) | ||||
{ | { | ||||
CheckRes(trans->Write(&fName, JACK_CLIENT_NAME_SIZE + 1)); | |||||
CheckRes(trans->Write(&fRefNum, sizeof(int))); | |||||
CheckRes(trans->Write(&fNotify, sizeof(int))); | |||||
CheckRes(trans->Write(&fValue1, sizeof(int))); | |||||
CheckRes(trans->Write(&fValue2, sizeof(int))); | |||||
CheckRes(trans->Write(&fSync, sizeof(int))); | |||||
return 0; | |||||
CheckRes(trans->Write(&fName, JACK_CLIENT_NAME_SIZE + 1)); | |||||
CheckRes(trans->Write(&fRefNum, sizeof(int))); | |||||
CheckRes(trans->Write(&fNotify, sizeof(int))); | |||||
CheckRes(trans->Write(&fValue1, sizeof(int))); | |||||
CheckRes(trans->Write(&fValue2, sizeof(int))); | |||||
CheckRes(trans->Write(&fSync, sizeof(int))); | |||||
return 0; | |||||
} | } | ||||
}; | }; | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2004-2008 Grame | Copyright (C) 2004-2008 Grame | ||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
@@ -18,7 +18,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||||
*/ | */ | ||||
#ifdef WIN32 | |||||
#ifdef WIN32 | |||||
#pragma warning (disable : 4786) | #pragma warning (disable : 4786) | ||||
#endif | #endif | ||||
@@ -53,12 +53,12 @@ JackServer::JackServer(bool sync, bool temporary, long timeout, bool rt, long p | |||||
fFreewheelDriver = new JackThreadedDriver(new JackFreewheelDriver("freewheel", fEngine, fSynchroTable)); | fFreewheelDriver = new JackThreadedDriver(new JackFreewheelDriver("freewheel", fEngine, fSynchroTable)); | ||||
fLoopbackDriver = new JackLoopbackDriver("loopback", fEngine, fSynchroTable); | fLoopbackDriver = new JackLoopbackDriver("loopback", fEngine, fSynchroTable); | ||||
fChannel = JackGlobals::MakeServerChannel(); | fChannel = JackGlobals::MakeServerChannel(); | ||||
fFreewheel = false; | |||||
fFreewheel = false; | |||||
fLoopback = loopback; | fLoopback = loopback; | ||||
fDriverInfo = NULL; | fDriverInfo = NULL; | ||||
fAudioDriver = NULL; | fAudioDriver = NULL; | ||||
fInstance = this; // Unique instance | fInstance = this; // Unique instance | ||||
jack_verbose = verbose; | |||||
jack_verbose = verbose; | |||||
} | } | ||||
JackServer::~JackServer() | JackServer::~JackServer() | ||||
@@ -117,7 +117,7 @@ int JackServer::Open(jack_driver_desc_t* driver_desc, JSList* driver_params) | |||||
jack_error("Cannot attach audio driver"); | jack_error("Cannot attach audio driver"); | ||||
return -1; | return -1; | ||||
} | } | ||||
if (fLoopback > 0 && fLoopbackDriver->Attach() != 0) { | if (fLoopback > 0 && fLoopbackDriver->Attach() != 0) { | ||||
jack_error("Cannot attach loopback driver"); | jack_error("Cannot attach loopback driver"); | ||||
return -1; | return -1; | ||||
@@ -148,25 +148,25 @@ int JackServer::Close() | |||||
int JackServer::InternalClientLoad(const char* client_name, const char* so_name, const char* objet_data, int options, int* int_ref, int* status) | int JackServer::InternalClientLoad(const char* client_name, const char* so_name, const char* objet_data, int options, int* int_ref, int* status) | ||||
{ | { | ||||
try { | |||||
// Clear status | |||||
*status = 0; | |||||
JackLoadableInternalClient* client = new JackLoadableInternalClient(fInstance, GetSynchroTable(), so_name, objet_data); | |||||
assert(client); | |||||
int res = client->Open("unused", client_name, (jack_options_t)options, (jack_status_t*)status); | |||||
if (res < 0) { | |||||
delete client; | |||||
*int_ref = 0; | |||||
} else { | |||||
*int_ref = client->GetClientControl()->fRefNum; | |||||
} | |||||
} catch (...) { | |||||
int my_status1 = *status | JackFailure; | |||||
*status = (jack_status_t)my_status1; | |||||
*int_ref = 0; | |||||
} | |||||
return 0; | |||||
try { | |||||
// Clear status | |||||
*status = 0; | |||||
JackLoadableInternalClient* client = new JackLoadableInternalClient(fInstance, GetSynchroTable(), so_name, objet_data); | |||||
assert(client); | |||||
int res = client->Open("unused", client_name, (jack_options_t)options, (jack_status_t*)status); | |||||
if (res < 0) { | |||||
delete client; | |||||
*int_ref = 0; | |||||
} else { | |||||
*int_ref = client->GetClientControl()->fRefNum; | |||||
} | |||||
} catch (...) { | |||||
int my_status1 = *status | JackFailure; | |||||
*status = (jack_status_t)my_status1; | |||||
*int_ref = 0; | |||||
} | |||||
return 0; | |||||
} | } | ||||
int JackServer::Start() | int JackServer::Start() | ||||
@@ -185,7 +185,7 @@ int JackServer::Stop() | |||||
int JackServer::SetBufferSize(jack_nframes_t buffer_size) | int JackServer::SetBufferSize(jack_nframes_t buffer_size) | ||||
{ | { | ||||
JackLog("JackServer::SetBufferSize nframes = %ld\n", buffer_size); | JackLog("JackServer::SetBufferSize nframes = %ld\n", buffer_size); | ||||
jack_nframes_t current_buffer_size = fEngineControl->fBufferSize; | |||||
jack_nframes_t current_buffer_size = fEngineControl->fBufferSize; | |||||
if (fAudioDriver->Stop() != 0) { | if (fAudioDriver->Stop() != 0) { | ||||
jack_error("Cannot stop audio driver"); | jack_error("Cannot stop audio driver"); | ||||
@@ -193,27 +193,27 @@ int JackServer::SetBufferSize(jack_nframes_t buffer_size) | |||||
} | } | ||||
if (fAudioDriver->SetBufferSize(buffer_size) == 0) { | if (fAudioDriver->SetBufferSize(buffer_size) == 0) { | ||||
fFreewheelDriver->SetBufferSize(buffer_size); | |||||
fEngine->NotifyBufferSize(buffer_size); | |||||
fEngineControl->InitFrameTime(); | |||||
return fAudioDriver->Start(); | |||||
} else { // Failure: try to restore current value | |||||
jack_error("Cannot SetBufferSize for audio driver, restore current value %ld", current_buffer_size); | |||||
fFreewheelDriver->SetBufferSize(current_buffer_size); | |||||
fEngineControl->InitFrameTime(); | |||||
return fAudioDriver->Start(); | |||||
} | |||||
fFreewheelDriver->SetBufferSize(buffer_size); | |||||
fEngine->NotifyBufferSize(buffer_size); | |||||
fEngineControl->InitFrameTime(); | |||||
return fAudioDriver->Start(); | |||||
} else { // Failure: try to restore current value | |||||
jack_error("Cannot SetBufferSize for audio driver, restore current value %ld", current_buffer_size); | |||||
fFreewheelDriver->SetBufferSize(current_buffer_size); | |||||
fEngineControl->InitFrameTime(); | |||||
return fAudioDriver->Start(); | |||||
} | |||||
} | } | ||||
/* | /* | ||||
Freewheel mode is implemented by switching from the (audio + freewheel) driver to the freewheel driver only: | Freewheel mode is implemented by switching from the (audio + freewheel) driver to the freewheel driver only: | ||||
- "global" connection state is saved | - "global" connection state is saved | ||||
- all audio driver ports are deconnected, thus there is no more dependancies with the audio driver | - all audio driver ports are deconnected, thus there is no more dependancies with the audio driver | ||||
- the freewheel driver will be synchronized with the end of graph execution : all clients are connected to the freewheel driver | - the freewheel driver will be synchronized with the end of graph execution : all clients are connected to the freewheel driver | ||||
- the freewheel driver becomes the "master" | - the freewheel driver becomes the "master" | ||||
Normal mode is restored with the connections state valid before freewheel mode was done. Thus one consider that | |||||
Normal mode is restored with the connections state valid before freewheel mode was done. Thus one consider that | |||||
no graph state change can be done during freewheel mode. | no graph state change can be done during freewheel mode. | ||||
*/ | */ | ||||
@@ -231,7 +231,7 @@ int JackServer::SetFreewheel(bool onoff) | |||||
fEngine->NotifyFreewheel(onoff); | fEngine->NotifyFreewheel(onoff); | ||||
fFreewheelDriver->SetMaster(false); | fFreewheelDriver->SetMaster(false); | ||||
fEngineControl->InitFrameTime(); | fEngineControl->InitFrameTime(); | ||||
return fAudioDriver->Start(); | |||||
return fAudioDriver->Start(); | |||||
} | } | ||||
} else { | } else { | ||||
if (onoff) { | if (onoff) { | ||||
@@ -241,7 +241,7 @@ int JackServer::SetFreewheel(bool onoff) | |||||
fGraphManager->DisconnectAllPorts(fAudioDriver->GetClientControl()->fRefNum); | fGraphManager->DisconnectAllPorts(fAudioDriver->GetClientControl()->fRefNum); | ||||
fEngine->NotifyFreewheel(onoff); | fEngine->NotifyFreewheel(onoff); | ||||
fFreewheelDriver->SetMaster(true); | fFreewheelDriver->SetMaster(true); | ||||
return fFreewheelDriver->Start(); | |||||
return fFreewheelDriver->Start(); | |||||
} else { | } else { | ||||
return -1; | return -1; | ||||
} | } | ||||
@@ -263,10 +263,10 @@ void JackServer::Notify(int refnum, int notify, int value) | |||||
case kDeadClient: | case kDeadClient: | ||||
JackLog("JackServer: kDeadClient ref = %ld\n", refnum); | JackLog("JackServer: kDeadClient ref = %ld\n", refnum); | ||||
if (fEngine->ClientDeactivate(refnum) < 0) | |||||
jack_error("JackServer: DeadClient ref = %ld cannot be removed from the graph !!", refnum); | |||||
fEngine->ClientExternalClose(refnum); | |||||
break; | |||||
if (fEngine->ClientDeactivate(refnum) < 0) | |||||
jack_error("JackServer: DeadClient ref = %ld cannot be removed from the graph !!", refnum); | |||||
fEngine->ClientExternalClose(refnum); | |||||
break; | |||||
} | } | ||||
} | } | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2004-2008 Grame | Copyright (C) 2004-2008 Grame | ||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
@@ -55,8 +55,8 @@ class EXPORT JackServer | |||||
JackGraphManager* fGraphManager; | JackGraphManager* fGraphManager; | ||||
JackServerChannelInterface* fChannel; | JackServerChannelInterface* fChannel; | ||||
//JackConnectionManager* fConnectionState; | //JackConnectionManager* fConnectionState; | ||||
JackConnectionManager fConnectionState; | |||||
JackSynchro* fSynchroTable[CLIENT_NUM]; | |||||
JackConnectionManager fConnectionState; | |||||
JackSynchro* fSynchroTable[CLIENT_NUM]; | |||||
bool fFreewheel; | bool fFreewheel; | ||||
long fLoopback; | long fLoopback; | ||||
@@ -66,7 +66,7 @@ class EXPORT JackServer | |||||
virtual ~JackServer(); | virtual ~JackServer(); | ||||
int Open(jack_driver_desc_t* driver_desc, JSList* driver_params); | int Open(jack_driver_desc_t* driver_desc, JSList* driver_params); | ||||
int Close(); | |||||
int Close(); | |||||
int Start(); | int Start(); | ||||
int Stop(); | int Stop(); | ||||
@@ -74,14 +74,14 @@ class EXPORT JackServer | |||||
int SetBufferSize(jack_nframes_t buffer_size); | int SetBufferSize(jack_nframes_t buffer_size); | ||||
int SetFreewheel(bool onoff); | int SetFreewheel(bool onoff); | ||||
void Notify(int refnum, int notify, int value); | void Notify(int refnum, int notify, int value); | ||||
int InternalClientLoad(const char* client_name, const char* so_name, const char* objet_data, int options, int* int_ref, int* status); | |||||
// Transport management | |||||
int InternalClientLoad(const char* client_name, const char* so_name, const char* objet_data, int options, int* int_ref, int* status); | |||||
// Transport management | |||||
int ReleaseTimebase(int refnum); | int ReleaseTimebase(int refnum); | ||||
int SetTimebaseCallback(int refnum, int conditional); | int SetTimebaseCallback(int refnum, int conditional); | ||||
// Object access | |||||
// Object access | |||||
JackEngine* GetEngine(); | JackEngine* GetEngine(); | ||||
JackEngineControl* GetEngineControl(); | JackEngineControl* GetEngineControl(); | ||||
JackSynchro** GetSynchroTable(); | JackSynchro** GetSynchroTable(); | ||||
@@ -18,7 +18,7 @@ This program is free software; you can redistribute it and/or modify | |||||
*/ | */ | ||||
#ifdef WIN32 | |||||
#ifdef WIN32 | |||||
#pragma warning (disable : 4786) | #pragma warning (disable : 4786) | ||||
#endif | #endif | ||||
@@ -32,9 +32,9 @@ This program is free software; you can redistribute it and/or modify | |||||
#include "JackTools.h" | #include "JackTools.h" | ||||
#ifdef WIN32 | #ifdef WIN32 | ||||
#define EXPORT __declspec(dllexport) | |||||
#define EXPORT __declspec(dllexport) | |||||
#else | #else | ||||
#define EXPORT | |||||
#define EXPORT | |||||
#endif | #endif | ||||
#ifdef __cplusplus | #ifdef __cplusplus | ||||
@@ -58,10 +58,10 @@ EXPORT jack_client_t* jack_client_open(const char* ext_client_name, jack_options | |||||
va_list ap; /* variable argument pointer */ | va_list ap; /* variable argument pointer */ | ||||
jack_varargs_t va; /* variable arguments */ | jack_varargs_t va; /* variable arguments */ | ||||
jack_status_t my_status; | jack_status_t my_status; | ||||
JackClient* client; | |||||
char client_name[JACK_CLIENT_NAME_SIZE]; | |||||
JackTools::RewriteName(ext_client_name, client_name); | |||||
JackClient* client; | |||||
char client_name[JACK_CLIENT_NAME_SIZE]; | |||||
JackTools::RewriteName(ext_client_name, client_name); | |||||
if (status == NULL) /* no status from caller? */ | if (status == NULL) /* no status from caller? */ | ||||
status = &my_status; /* use local status word */ | status = &my_status; /* use local status word */ | ||||
@@ -86,26 +86,26 @@ EXPORT jack_client_t* jack_client_open(const char* ext_client_name, jack_options | |||||
} | } | ||||
if (!JackServerGlobals::Init()) { // jack server initialisation | if (!JackServerGlobals::Init()) { // jack server initialisation | ||||
int my_status1 = (JackFailure | JackServerError); | |||||
int my_status1 = (JackFailure | JackServerError); | |||||
*status = (jack_status_t)my_status1; | *status = (jack_status_t)my_status1; | ||||
return NULL; | |||||
} | |||||
return NULL; | |||||
} | |||||
#ifndef WIN32 | #ifndef WIN32 | ||||
char* jack_debug = getenv("JACK_CLIENT_DEBUG"); | |||||
if (jack_debug && strcmp(jack_debug, "on") == 0) | |||||
client = new JackDebugClient(new JackInternalClient(JackServer::fInstance, GetSynchroTable())); // Debug mode | |||||
else | |||||
client = new JackInternalClient(JackServer::fInstance, GetSynchroTable()); | |||||
char* jack_debug = getenv("JACK_CLIENT_DEBUG"); | |||||
if (jack_debug && strcmp(jack_debug, "on") == 0) | |||||
client = new JackDebugClient(new JackInternalClient(JackServer::fInstance, GetSynchroTable())); // Debug mode | |||||
else | |||||
client = new JackInternalClient(JackServer::fInstance, GetSynchroTable()); | |||||
#else | #else | ||||
client = new JackInternalClient(JackServer::fInstance, GetSynchroTable()); | |||||
#endif | |||||
client = new JackInternalClient(JackServer::fInstance, GetSynchroTable()); | |||||
#endif | |||||
int res = client->Open(va.server_name, client_name, options, status); | int res = client->Open(va.server_name, client_name, options, status); | ||||
if (res < 0) { | if (res < 0) { | ||||
delete client; | delete client; | ||||
JackServerGlobals::Destroy(); // jack server destruction | JackServerGlobals::Destroy(); // jack server destruction | ||||
int my_status1 = (JackFailure | JackServerError); | |||||
int my_status1 = (JackFailure | JackServerError); | |||||
*status = (jack_status_t)my_status1; | *status = (jack_status_t)my_status1; | ||||
return NULL; | return NULL; | ||||
} else { | } else { | ||||
@@ -121,11 +121,11 @@ EXPORT int jack_client_close(jack_client_t* ext_client) | |||||
jack_error("jack_client_close called with a NULL client"); | jack_error("jack_client_close called with a NULL client"); | ||||
return -1; | return -1; | ||||
} else { | } else { | ||||
int res = client->Close(); | |||||
delete client; | |||||
JackLog("jack_client_close OK\n"); | |||||
JackServerGlobals::Destroy(); // jack server destruction | |||||
return res; | |||||
} | |||||
int res = client->Close(); | |||||
delete client; | |||||
JackLog("jack_client_close OK\n"); | |||||
JackServerGlobals::Destroy(); // jack server destruction | |||||
return res; | |||||
} | |||||
} | } | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2005 Grame | |||||
Copyright (C) 2005 Grame | |||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
it under the terms of the GNU General Public License as published by | it under the terms of the GNU General Public License as published by | ||||
@@ -17,7 +17,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||||
*/ | */ | ||||
#ifdef WIN32 | |||||
#ifdef WIN32 | |||||
#pragma warning (disable : 4786) | #pragma warning (disable : 4786) | ||||
#endif | #endif | ||||
@@ -28,7 +28,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||||
#include <getopt.h> | #include <getopt.h> | ||||
#ifndef WIN32 | #ifndef WIN32 | ||||
#include <dirent.h> | |||||
#include <dirent.h> | |||||
#endif | #endif | ||||
static char* server_name = NULL; | static char* server_name = NULL; | ||||
@@ -39,19 +39,19 @@ namespace Jack | |||||
unsigned int JackServerGlobals::fClientCount = 0; | unsigned int JackServerGlobals::fClientCount = 0; | ||||
JackServer* JackServerGlobals::fServer = NULL; | JackServer* JackServerGlobals::fServer = NULL; | ||||
int JackServerGlobals::Start(const char* server_name, | |||||
jack_driver_desc_t* driver_desc, | |||||
JSList* driver_params, | |||||
int sync, | |||||
int temporary, | |||||
int time_out_ms, | |||||
int rt, | |||||
int priority, | |||||
int loopback, | |||||
int verbose) | |||||
int JackServerGlobals::Start(const char* server_name, | |||||
jack_driver_desc_t* driver_desc, | |||||
JSList* driver_params, | |||||
int sync, | |||||
int temporary, | |||||
int time_out_ms, | |||||
int rt, | |||||
int priority, | |||||
int loopback, | |||||
int verbose) | |||||
{ | { | ||||
JackLog("Jackdmp: sync = %ld timeout = %ld rt = %ld priority = %ld verbose = %ld \n", sync, time_out_ms, rt, priority, verbose); | JackLog("Jackdmp: sync = %ld timeout = %ld rt = %ld priority = %ld verbose = %ld \n", sync, time_out_ms, rt, priority, verbose); | ||||
fServer = new JackServer(sync, temporary, time_out_ms, rt, priority, loopback, verbose, server_name); | |||||
fServer = new JackServer(sync, temporary, time_out_ms, rt, priority, loopback, verbose, server_name); | |||||
int res = fServer->Open(driver_desc, driver_params); | int res = fServer->Open(driver_desc, driver_params); | ||||
return (res < 0) ? res : fServer->Start(); | return (res < 0) ? res : fServer->Start(); | ||||
} | } | ||||
@@ -75,253 +75,254 @@ int JackServerGlobals::Delete() | |||||
bool JackServerGlobals::Init() | bool JackServerGlobals::Init() | ||||
{ | { | ||||
if (fClientCount++ == 0) { | |||||
if (fClientCount++ == 0) { | |||||
JackLog("JackServerGlobals Init\n"); | JackLog("JackServerGlobals Init\n"); | ||||
int realtime = 0; | |||||
int client_timeout = 0; /* msecs; if zero, use period size. */ | |||||
int realtime_priority = 10; | |||||
int verbose_aux = 0; | |||||
int do_mlock = 1; | |||||
unsigned int port_max = 128; | |||||
int loopback = 0; | |||||
int do_unlock = 0; | |||||
int temporary = 0; | |||||
jack_driver_desc_t* driver_desc; | |||||
const char *options = "-ad:P:uvshVRL:STFl:t:mn:p:"; | |||||
static struct option long_options[] = { | |||||
{ "driver", 1, 0, 'd'}, | |||||
{ "verbose", 0, 0, 'v' }, | |||||
{ "help", 0, 0, 'h' }, | |||||
{ "port-max", 1, 0, 'p' }, | |||||
{ "no-mlock", 0, 0, 'm' }, | |||||
{ "name", 0, 0, 'n' }, | |||||
{ "unlock", 0, 0, 'u' }, | |||||
{ "realtime", 0, 0, 'R' }, | |||||
{ "loopback", 0, 0, 'L' }, | |||||
{ "realtime-priority", 1, 0, 'P' }, | |||||
{ "timeout", 1, 0, 't' }, | |||||
{ "temporary", 0, 0, 'T' }, | |||||
{ "version", 0, 0, 'V' }, | |||||
{ "silent", 0, 0, 's' }, | |||||
{ "sync", 0, 0, 'S' }, | |||||
{ 0, 0, 0, 0 } | |||||
}; | |||||
int opt = 0; | |||||
int option_index = 0; | |||||
int seen_driver = 0; | |||||
char *driver_name = NULL; | |||||
char **driver_args = NULL; | |||||
JSList* driver_params; | |||||
int driver_nargs = 1; | |||||
JSList* drivers = NULL; | |||||
int show_version = 0; | |||||
int sync = 0; | |||||
int rc, i; | |||||
int ret; | |||||
FILE* fp = 0; | |||||
char filename[255]; | |||||
char buffer[255]; | |||||
int argc = 0; | |||||
char* argv[32]; | |||||
snprintf(filename, 255, "%s/.jackdrc", getenv("HOME")); | |||||
fp = fopen(filename, "r"); | |||||
if (!fp) { | |||||
fp = fopen("/etc/jackdrc", "r"); | |||||
} | |||||
// if still not found, check old config name for backwards compatability | |||||
if (!fp) { | |||||
fp = fopen("/etc/jackd.conf", "r"); | |||||
} | |||||
argc = 0; | |||||
if (fp) { | |||||
ret = fscanf(fp, "%s", buffer); | |||||
while (ret != 0 && ret != EOF) { | |||||
argv[argc] = (char*)malloc(64); | |||||
strcpy(argv[argc], buffer); | |||||
ret = fscanf(fp, "%s", buffer); | |||||
argc++; | |||||
} | |||||
fclose(fp); | |||||
} | |||||
/* | |||||
For testing | |||||
int argc = 15; | |||||
char* argv[] = {"jackdmp", "-R", "-v", "-d", "coreaudio", "-p", "512", "-d", "~:Aggregate:0", "-r", "48000", "-i", "2", "-o", "2" }; | |||||
*/ | |||||
opterr = 0; | |||||
optind = 1; // Important : to reset argv parsing | |||||
while (!seen_driver && | |||||
(opt = getopt_long(argc, argv, options, long_options, &option_index)) != EOF) { | |||||
switch (opt) { | |||||
case 'd': | |||||
seen_driver = 1; | |||||
driver_name = optarg; | |||||
break; | |||||
case 'v': | |||||
verbose_aux = 1; | |||||
break; | |||||
case 'S': | |||||
sync = 1; | |||||
break; | |||||
case 'n': | |||||
server_name = optarg; | |||||
break; | |||||
case 'm': | |||||
do_mlock = 0; | |||||
break; | |||||
case 'p': | |||||
port_max = (unsigned int)atol(optarg); | |||||
break; | |||||
case 'P': | |||||
realtime_priority = atoi(optarg); | |||||
break; | |||||
case 'R': | |||||
realtime = 1; | |||||
break; | |||||
case 'L': | |||||
loopback = atoi(optarg); | |||||
break; | |||||
case 'T': | |||||
temporary = 1; | |||||
break; | |||||
case 't': | |||||
client_timeout = atoi(optarg); | |||||
break; | |||||
case 'u': | |||||
do_unlock = 1; | |||||
break; | |||||
case 'V': | |||||
show_version = 1; | |||||
break; | |||||
default: | |||||
fprintf(stderr, "unknown option character %c\n", optopt); | |||||
break; | |||||
} | |||||
} | |||||
drivers = jack_drivers_load(drivers); | |||||
if (!drivers) { | |||||
fprintf(stderr, "jackdmp: no drivers found; exiting\n"); | |||||
goto error; | |||||
} | |||||
driver_desc = jack_find_driver_descriptor(drivers, driver_name); | |||||
if (!driver_desc) { | |||||
fprintf(stderr, "jackdmp: unknown driver '%s'\n", driver_name); | |||||
goto error; | |||||
} | |||||
if (optind < argc) { | |||||
driver_nargs = 1 + argc - optind; | |||||
} else { | |||||
driver_nargs = 1; | |||||
} | |||||
if (driver_nargs == 0) { | |||||
fprintf(stderr, "No driver specified ... hmm. JACK won't do" | |||||
" anything when run like this.\n"); | |||||
goto error; | |||||
} | |||||
driver_args = (char**)malloc(sizeof(char*) * driver_nargs); | |||||
driver_args[0] = driver_name; | |||||
for (i = 1; i < driver_nargs; i++) { | |||||
driver_args[i] = argv[optind++]; | |||||
} | |||||
if (jack_parse_driver_params(driver_desc, driver_nargs, driver_args, &driver_params)) { | |||||
goto error; | |||||
} | |||||
#ifndef WIN32 | |||||
if (server_name == NULL) | |||||
server_name = (char*)JackTools::DefaultServerName(); | |||||
#endif | |||||
rc = jack_register_server(server_name, false); | |||||
switch (rc) { | |||||
case EEXIST: | |||||
fprintf(stderr, "`%s' server already active\n", server_name); | |||||
goto error; | |||||
case ENOSPC: | |||||
fprintf(stderr, "too many servers already active\n"); | |||||
goto error; | |||||
case ENOMEM: | |||||
fprintf(stderr, "no access to shm registry\n"); | |||||
goto error; | |||||
default: | |||||
if (jack_verbose) | |||||
fprintf(stderr, "server `%s' registered\n", server_name); | |||||
} | |||||
/* clean up shared memory and files from any previous instance of this server name */ | |||||
jack_cleanup_shm(); | |||||
#ifndef WIN32 | |||||
JackTools::CleanupFiles(server_name); | |||||
#endif | |||||
if (!realtime && client_timeout == 0) | |||||
client_timeout = 500; /* 0.5 sec; usable when non realtime. */ | |||||
for (i = 0; i < argc; i++) { | |||||
free(argv[i]); | |||||
} | |||||
int res = Start(server_name, driver_desc, driver_params, sync, temporary, client_timeout, realtime, realtime_priority, loopback, verbose_aux); | |||||
if (res < 0) { | |||||
jack_error("Cannot start server... exit"); | |||||
Delete(); | |||||
jack_cleanup_shm(); | |||||
#ifndef WIN32 | |||||
JackTools::CleanupFiles(server_name); | |||||
#endif | |||||
jack_unregister_server(server_name); | |||||
goto error; | |||||
} | |||||
} | |||||
return true; | |||||
int realtime = 0; | |||||
int client_timeout = 0; /* msecs; if zero, use period size. */ | |||||
int realtime_priority = 10; | |||||
int verbose_aux = 0; | |||||
int do_mlock = 1; | |||||
unsigned int port_max = 128; | |||||
int loopback = 0; | |||||
int do_unlock = 0; | |||||
int temporary = 0; | |||||
jack_driver_desc_t* driver_desc; | |||||
const char *options = "-ad:P:uvshVRL:STFl:t:mn:p:"; | |||||
static struct option long_options[] = { | |||||
{ "driver", 1, 0, 'd' | |||||
}, | |||||
{ "verbose", 0, 0, 'v' }, | |||||
{ "help", 0, 0, 'h' }, | |||||
{ "port-max", 1, 0, 'p' }, | |||||
{ "no-mlock", 0, 0, 'm' }, | |||||
{ "name", 0, 0, 'n' }, | |||||
{ "unlock", 0, 0, 'u' }, | |||||
{ "realtime", 0, 0, 'R' }, | |||||
{ "loopback", 0, 0, 'L' }, | |||||
{ "realtime-priority", 1, 0, 'P' }, | |||||
{ "timeout", 1, 0, 't' }, | |||||
{ "temporary", 0, 0, 'T' }, | |||||
{ "version", 0, 0, 'V' }, | |||||
{ "silent", 0, 0, 's' }, | |||||
{ "sync", 0, 0, 'S' }, | |||||
{ 0, 0, 0, 0 } | |||||
}; | |||||
int opt = 0; | |||||
int option_index = 0; | |||||
int seen_driver = 0; | |||||
char *driver_name = NULL; | |||||
char **driver_args = NULL; | |||||
JSList* driver_params; | |||||
int driver_nargs = 1; | |||||
JSList* drivers = NULL; | |||||
int show_version = 0; | |||||
int sync = 0; | |||||
int rc, i; | |||||
int ret; | |||||
FILE* fp = 0; | |||||
char filename[255]; | |||||
char buffer[255]; | |||||
int argc = 0; | |||||
char* argv[32]; | |||||
snprintf(filename, 255, "%s/.jackdrc", getenv("HOME")); | |||||
fp = fopen(filename, "r"); | |||||
if (!fp) { | |||||
fp = fopen("/etc/jackdrc", "r"); | |||||
} | |||||
// if still not found, check old config name for backwards compatability | |||||
if (!fp) { | |||||
fp = fopen("/etc/jackd.conf", "r"); | |||||
} | |||||
argc = 0; | |||||
if (fp) { | |||||
ret = fscanf(fp, "%s", buffer); | |||||
while (ret != 0 && ret != EOF) { | |||||
argv[argc] = (char*)malloc(64); | |||||
strcpy(argv[argc], buffer); | |||||
ret = fscanf(fp, "%s", buffer); | |||||
argc++; | |||||
} | |||||
fclose(fp); | |||||
} | |||||
/* | |||||
For testing | |||||
int argc = 15; | |||||
char* argv[] = {"jackdmp", "-R", "-v", "-d", "coreaudio", "-p", "512", "-d", "~:Aggregate:0", "-r", "48000", "-i", "2", "-o", "2" }; | |||||
*/ | |||||
opterr = 0; | |||||
optind = 1; // Important : to reset argv parsing | |||||
while (!seen_driver && | |||||
(opt = getopt_long(argc, argv, options, long_options, &option_index)) != EOF) { | |||||
switch (opt) { | |||||
case 'd': | |||||
seen_driver = 1; | |||||
driver_name = optarg; | |||||
break; | |||||
case 'v': | |||||
verbose_aux = 1; | |||||
break; | |||||
case 'S': | |||||
sync = 1; | |||||
break; | |||||
case 'n': | |||||
server_name = optarg; | |||||
break; | |||||
case 'm': | |||||
do_mlock = 0; | |||||
break; | |||||
case 'p': | |||||
port_max = (unsigned int)atol(optarg); | |||||
break; | |||||
case 'P': | |||||
realtime_priority = atoi(optarg); | |||||
break; | |||||
case 'R': | |||||
realtime = 1; | |||||
break; | |||||
case 'L': | |||||
loopback = atoi(optarg); | |||||
break; | |||||
case 'T': | |||||
temporary = 1; | |||||
break; | |||||
case 't': | |||||
client_timeout = atoi(optarg); | |||||
break; | |||||
case 'u': | |||||
do_unlock = 1; | |||||
break; | |||||
case 'V': | |||||
show_version = 1; | |||||
break; | |||||
default: | |||||
fprintf(stderr, "unknown option character %c\n", optopt); | |||||
break; | |||||
} | |||||
} | |||||
drivers = jack_drivers_load(drivers); | |||||
if (!drivers) { | |||||
fprintf(stderr, "jackdmp: no drivers found; exiting\n"); | |||||
goto error; | |||||
} | |||||
driver_desc = jack_find_driver_descriptor(drivers, driver_name); | |||||
if (!driver_desc) { | |||||
fprintf(stderr, "jackdmp: unknown driver '%s'\n", driver_name); | |||||
goto error; | |||||
} | |||||
if (optind < argc) { | |||||
driver_nargs = 1 + argc - optind; | |||||
} else { | |||||
driver_nargs = 1; | |||||
} | |||||
if (driver_nargs == 0) { | |||||
fprintf(stderr, "No driver specified ... hmm. JACK won't do" | |||||
" anything when run like this.\n"); | |||||
goto error; | |||||
} | |||||
driver_args = (char**)malloc(sizeof(char*) * driver_nargs); | |||||
driver_args[0] = driver_name; | |||||
for (i = 1; i < driver_nargs; i++) { | |||||
driver_args[i] = argv[optind++]; | |||||
} | |||||
if (jack_parse_driver_params(driver_desc, driver_nargs, driver_args, &driver_params)) { | |||||
goto error; | |||||
} | |||||
#ifndef WIN32 | |||||
if (server_name == NULL) | |||||
server_name = (char*)JackTools::DefaultServerName(); | |||||
#endif | |||||
rc = jack_register_server(server_name, false); | |||||
switch (rc) { | |||||
case EEXIST: | |||||
fprintf(stderr, "`%s' server already active\n", server_name); | |||||
goto error; | |||||
case ENOSPC: | |||||
fprintf(stderr, "too many servers already active\n"); | |||||
goto error; | |||||
case ENOMEM: | |||||
fprintf(stderr, "no access to shm registry\n"); | |||||
goto error; | |||||
default: | |||||
if (jack_verbose) | |||||
fprintf(stderr, "server `%s' registered\n", server_name); | |||||
} | |||||
/* clean up shared memory and files from any previous instance of this server name */ | |||||
jack_cleanup_shm(); | |||||
#ifndef WIN32 | |||||
JackTools::CleanupFiles(server_name); | |||||
#endif | |||||
if (!realtime && client_timeout == 0) | |||||
client_timeout = 500; /* 0.5 sec; usable when non realtime. */ | |||||
for (i = 0; i < argc; i++) { | |||||
free(argv[i]); | |||||
} | |||||
int res = Start(server_name, driver_desc, driver_params, sync, temporary, client_timeout, realtime, realtime_priority, loopback, verbose_aux); | |||||
if (res < 0) { | |||||
jack_error("Cannot start server... exit"); | |||||
Delete(); | |||||
jack_cleanup_shm(); | |||||
#ifndef WIN32 | |||||
JackTools::CleanupFiles(server_name); | |||||
#endif | |||||
jack_unregister_server(server_name); | |||||
goto error; | |||||
} | |||||
} | |||||
return true; | |||||
error: | error: | ||||
fClientCount--; | |||||
return false; | |||||
fClientCount--; | |||||
return false; | |||||
} | } | ||||
void JackServerGlobals::Destroy() | void JackServerGlobals::Destroy() | ||||
{ | { | ||||
if (--fClientCount == 0) { | if (--fClientCount == 0) { | ||||
JackLog("JackServerGlobals Destroy\n"); | JackLog("JackServerGlobals Destroy\n"); | ||||
Stop(); | |||||
jack_cleanup_shm(); | |||||
#ifndef WIN32 | |||||
JackTools::CleanupFiles(server_name); | |||||
#endif | |||||
jack_unregister_server(server_name); | |||||
Stop(); | |||||
jack_cleanup_shm(); | |||||
#ifndef WIN32 | |||||
JackTools::CleanupFiles(server_name); | |||||
#endif | |||||
jack_unregister_server(server_name); | |||||
} | } | ||||
} | } | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2005 Grame | |||||
Copyright (C) 2005 Grame | |||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
it under the terms of the GNU General Public License as published by | it under the terms of the GNU General Public License as published by | ||||
@@ -37,7 +37,7 @@ class JackClient; | |||||
struct JackServerGlobals | struct JackServerGlobals | ||||
{ | { | ||||
static unsigned int fClientCount; | |||||
static unsigned int fClientCount; | |||||
static JackServer* fServer; | static JackServer* fServer; | ||||
JackServerGlobals(); | JackServerGlobals(); | ||||
@@ -45,16 +45,16 @@ struct JackServerGlobals | |||||
static bool Init(); | static bool Init(); | ||||
static void Destroy(); | static void Destroy(); | ||||
static int Start(const char* server_name, | |||||
jack_driver_desc_t* driver_desc, | |||||
JSList* driver_params, | |||||
int sync, | |||||
int temporary, | |||||
int time_out_ms, | |||||
int rt, | |||||
int priority, | |||||
int loopback, | |||||
int verbose); | |||||
static int Start(const char* server_name, | |||||
jack_driver_desc_t* driver_desc, | |||||
JSList* driver_params, | |||||
int sync, | |||||
int temporary, | |||||
int time_out_ms, | |||||
int rt, | |||||
int priority, | |||||
int loopback, | |||||
int verbose); | |||||
static int Stop(); | static int Stop(); | ||||
static int Delete(); | static int Delete(); | ||||
}; | }; | ||||
@@ -13,7 +13,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
GNU Lesser General Public License for more details. | GNU Lesser General Public License for more details. | ||||
You should have received a copy of the GNU Lesser General Public License | You should have received a copy of the GNU Lesser General Public License | ||||
along with this program; if not, write to the Free Software | |||||
along with this program; if not, write to the Free Software | |||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||||
*/ | */ | ||||
@@ -33,153 +33,153 @@ using namespace Jack; | |||||
/* Exec the JACK server in this process. Does not return. */ | /* Exec the JACK server in this process. Does not return. */ | ||||
static void start_server_aux(const char* server_name) | static void start_server_aux(const char* server_name) | ||||
{ | { | ||||
FILE* fp = 0; | |||||
char filename[255]; | |||||
char arguments[255]; | |||||
char buffer[255]; | |||||
char* command = 0; | |||||
size_t pos = 0; | |||||
size_t result = 0; | |||||
char** argv = 0; | |||||
int i = 0; | |||||
int good = 0; | |||||
int ret; | |||||
snprintf(filename, 255, "%s/.jackdrc", getenv("HOME")); | |||||
fp = fopen(filename, "r"); | |||||
if (!fp) { | |||||
fp = fopen("/etc/jackdrc", "r"); | |||||
} | |||||
/* if still not found, check old config name for backwards compatability */ | |||||
if (!fp) { | |||||
fp = fopen("/etc/jackd.conf", "r"); | |||||
} | |||||
if (fp) { | |||||
arguments[0] = '\0'; | |||||
ret = fscanf(fp, "%s", buffer); | |||||
while (ret != 0 && ret != EOF) { | |||||
strcat(arguments, buffer); | |||||
strcat(arguments, " "); | |||||
ret = fscanf(fp, "%s", buffer); | |||||
} | |||||
if (strlen(arguments) > 0) { | |||||
good = 1; | |||||
} | |||||
fclose(fp); | |||||
} | |||||
if (!good) { | |||||
command = (char*)(JACK_LOCATION "/jackd"); | |||||
strncpy(arguments, JACK_LOCATION "/jackd -T -d "JACK_DEFAULT_DRIVER, 255); | |||||
} else { | |||||
result = strcspn(arguments, " "); | |||||
command = (char*)malloc(result + 1); | |||||
strncpy(command, arguments, result); | |||||
command[result] = '\0'; | |||||
} | |||||
argv = (char**)malloc(255); | |||||
while (1) { | |||||
/* insert -T and -nserver_name in front of arguments */ | |||||
if (i == 1) { | |||||
argv[i] = (char*)malloc(strlen ("-T") + 1); | |||||
strcpy (argv[i++], "-T"); | |||||
if (server_name) { | |||||
size_t optlen = strlen("-n"); | |||||
char* buf = (char*)malloc(optlen + strlen(server_name) + 1); | |||||
strcpy(buf, "-n"); | |||||
strcpy(buf + optlen, server_name); | |||||
argv[i++] = buf; | |||||
} | |||||
} | |||||
result = strcspn(arguments + pos, " "); | |||||
if (result == 0) { | |||||
break; | |||||
} | |||||
argv[i] = (char*)malloc(result + 1); | |||||
strncpy(argv[i], arguments + pos, result); | |||||
argv[i][result] = '\0'; | |||||
pos += result + 1; | |||||
++i; | |||||
} | |||||
argv[i] = 0; | |||||
execv(command, argv); | |||||
/* If execv() succeeds, it does not return. There's no point | |||||
* in calling jack_error() here in the child process. */ | |||||
fprintf(stderr, "exec of JACK server (command = \"%s\") failed: %s\n", command, strerror(errno)); | |||||
FILE* fp = 0; | |||||
char filename[255]; | |||||
char arguments[255]; | |||||
char buffer[255]; | |||||
char* command = 0; | |||||
size_t pos = 0; | |||||
size_t result = 0; | |||||
char** argv = 0; | |||||
int i = 0; | |||||
int good = 0; | |||||
int ret; | |||||
snprintf(filename, 255, "%s/.jackdrc", getenv("HOME")); | |||||
fp = fopen(filename, "r"); | |||||
if (!fp) { | |||||
fp = fopen("/etc/jackdrc", "r"); | |||||
} | |||||
/* if still not found, check old config name for backwards compatability */ | |||||
if (!fp) { | |||||
fp = fopen("/etc/jackd.conf", "r"); | |||||
} | |||||
if (fp) { | |||||
arguments[0] = '\0'; | |||||
ret = fscanf(fp, "%s", buffer); | |||||
while (ret != 0 && ret != EOF) { | |||||
strcat(arguments, buffer); | |||||
strcat(arguments, " "); | |||||
ret = fscanf(fp, "%s", buffer); | |||||
} | |||||
if (strlen(arguments) > 0) { | |||||
good = 1; | |||||
} | |||||
fclose(fp); | |||||
} | |||||
if (!good) { | |||||
command = (char*)(JACK_LOCATION "/jackd"); | |||||
strncpy(arguments, JACK_LOCATION "/jackd -T -d "JACK_DEFAULT_DRIVER, 255); | |||||
} else { | |||||
result = strcspn(arguments, " "); | |||||
command = (char*)malloc(result + 1); | |||||
strncpy(command, arguments, result); | |||||
command[result] = '\0'; | |||||
} | |||||
argv = (char**)malloc(255); | |||||
while (1) { | |||||
/* insert -T and -nserver_name in front of arguments */ | |||||
if (i == 1) { | |||||
argv[i] = (char*)malloc(strlen ("-T") + 1); | |||||
strcpy (argv[i++], "-T"); | |||||
if (server_name) { | |||||
size_t optlen = strlen("-n"); | |||||
char* buf = (char*)malloc(optlen + strlen(server_name) + 1); | |||||
strcpy(buf, "-n"); | |||||
strcpy(buf + optlen, server_name); | |||||
argv[i++] = buf; | |||||
} | |||||
} | |||||
result = strcspn(arguments + pos, " "); | |||||
if (result == 0) { | |||||
break; | |||||
} | |||||
argv[i] = (char*)malloc(result + 1); | |||||
strncpy(argv[i], arguments + pos, result); | |||||
argv[i][result] = '\0'; | |||||
pos += result + 1; | |||||
++i; | |||||
} | |||||
argv[i] = 0; | |||||
execv(command, argv); | |||||
/* If execv() succeeds, it does not return. There's no point | |||||
* in calling jack_error() here in the child process. */ | |||||
fprintf(stderr, "exec of JACK server (command = \"%s\") failed: %s\n", command, strerror(errno)); | |||||
} | } | ||||
static int start_server(const char* server_name, jack_options_t options) | static int start_server(const char* server_name, jack_options_t options) | ||||
{ | { | ||||
if ((options & JackNoStartServer) || getenv("JACK_NO_START_SERVER")) { | |||||
return 1; | |||||
} | |||||
/* The double fork() forces the server to become a child of | |||||
* init, which will always clean up zombie process state on | |||||
* termination. This even works in cases where the server | |||||
* terminates but this client does not. | |||||
* | |||||
* Since fork() is usually implemented using copy-on-write | |||||
* virtual memory tricks, the overhead of the second fork() is | |||||
* probably relatively small. | |||||
*/ | |||||
switch (fork()) { | |||||
case 0: /* child process */ | |||||
switch (fork()) { | |||||
case 0: /* grandchild process */ | |||||
start_server_aux(server_name); | |||||
_exit(99); /* exec failed */ | |||||
case -1: | |||||
_exit(98); | |||||
default: | |||||
_exit(0); | |||||
} | |||||
case -1: /* fork() error */ | |||||
return 1; /* failed to start server */ | |||||
} | |||||
/* only the original parent process goes here */ | |||||
return 0; /* (probably) successful */ | |||||
if ((options & JackNoStartServer) || getenv("JACK_NO_START_SERVER")) { | |||||
return 1; | |||||
} | |||||
/* The double fork() forces the server to become a child of | |||||
* init, which will always clean up zombie process state on | |||||
* termination. This even works in cases where the server | |||||
* terminates but this client does not. | |||||
* | |||||
* Since fork() is usually implemented using copy-on-write | |||||
* virtual memory tricks, the overhead of the second fork() is | |||||
* probably relatively small. | |||||
*/ | |||||
switch (fork()) { | |||||
case 0: /* child process */ | |||||
switch (fork()) { | |||||
case 0: /* grandchild process */ | |||||
start_server_aux(server_name); | |||||
_exit(99); /* exec failed */ | |||||
case - 1: | |||||
_exit(98); | |||||
default: | |||||
_exit(0); | |||||
} | |||||
case - 1: /* fork() error */ | |||||
return 1; /* failed to start server */ | |||||
} | |||||
/* only the original parent process goes here */ | |||||
return 0; /* (probably) successful */ | |||||
} | } | ||||
int server_connect(char* server_name) | int server_connect(char* server_name) | ||||
{ | { | ||||
JackClientChannelInterface* channel = JackGlobals::MakeClientChannel(); | |||||
int res = channel->ServerCheck(server_name); | |||||
channel->Close(); | |||||
delete channel; | |||||
return res; | |||||
JackClientChannelInterface* channel = JackGlobals::MakeClientChannel(); | |||||
int res = channel->ServerCheck(server_name); | |||||
channel->Close(); | |||||
delete channel; | |||||
return res; | |||||
} | } | ||||
int try_start_server(jack_varargs_t* va, jack_options_t options, jack_status_t* status) | int try_start_server(jack_varargs_t* va, jack_options_t options, jack_status_t* status) | ||||
{ | { | ||||
if (server_connect(va->server_name) < 0) { | |||||
int trys; | |||||
if (start_server(va->server_name, options)) { | |||||
int my_status1 = *status | JackFailure | JackServerFailed; | |||||
*status = (jack_status_t)my_status1; | |||||
return -1; | |||||
} | |||||
trys = 5; | |||||
do { | |||||
sleep(1); | |||||
if (--trys < 0) { | |||||
int my_status1 = *status | JackFailure | JackServerFailed; | |||||
*status = (jack_status_t)my_status1; | |||||
return -1; | |||||
} | |||||
} while (server_connect(va->server_name) < 0); | |||||
int my_status1 = *status | JackServerStarted; | |||||
*status = (jack_status_t)my_status1; | |||||
} | |||||
return 0; | |||||
if (server_connect(va->server_name) < 0) { | |||||
int trys; | |||||
if (start_server(va->server_name, options)) { | |||||
int my_status1 = *status | JackFailure | JackServerFailed; | |||||
*status = (jack_status_t)my_status1; | |||||
return -1; | |||||
} | |||||
trys = 5; | |||||
do { | |||||
sleep(1); | |||||
if (--trys < 0) { | |||||
int my_status1 = *status | JackFailure | JackServerFailed; | |||||
*status = (jack_status_t)my_status1; | |||||
return -1; | |||||
} | |||||
} while (server_connect(va->server_name) < 0); | |||||
int my_status1 = *status | JackServerStarted; | |||||
*status = (jack_status_t)my_status1; | |||||
} | |||||
return 0; | |||||
} | } | ||||
#endif | #endif |
@@ -13,7 +13,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
GNU Lesser General Public License for more details. | GNU Lesser General Public License for more details. | ||||
You should have received a copy of the GNU Lesser General Public License | You should have received a copy of the GNU Lesser General Public License | ||||
along with this program; if not, write to the Free Software | |||||
along with this program; if not, write to the Free Software | |||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||||
*/ | */ | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2004-2008 Grame | Copyright (C) 2004-2008 Grame | ||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
@@ -52,9 +52,9 @@ void* JackShmMem::operator new(size_t size) | |||||
// It is unsafe to set object fields directly (may be overwritten during object initialization), | // It is unsafe to set object fields directly (may be overwritten during object initialization), | ||||
// so use an intermediate global data | // so use an intermediate global data | ||||
gInfo.index = info.index; | gInfo.index = info.index; | ||||
gInfo.size = size; | |||||
gInfo.size = size; | |||||
gInfo.attached_at = info.attached_at; | gInfo.attached_at = info.attached_at; | ||||
JackLog("JackShmMem::new index = %ld attached = %x size = %ld \n", info.index, info.attached_at, size); | JackLog("JackShmMem::new index = %ld attached = %x size = %ld \n", info.index, info.attached_at, size); | ||||
return obj; | return obj; | ||||
@@ -76,40 +76,40 @@ void JackShmMem::operator delete(void* p, size_t size) | |||||
jack_destroy_shm(&info); | jack_destroy_shm(&info); | ||||
} | } | ||||
void LockMemoryImp(void* ptr, size_t size) | |||||
void LockMemoryImp(void* ptr, size_t size) | |||||
{ | { | ||||
if (CHECK_MLOCK(ptr, size)) { | |||||
JackLog("Succeeded in locking %u byte memory area\n", size); | |||||
} else { | |||||
jack_error("Cannot lock down memory area (%s)", strerror(errno)); | |||||
} | |||||
if (CHECK_MLOCK(ptr, size)) { | |||||
JackLog("Succeeded in locking %u byte memory area\n", size); | |||||
} else { | |||||
jack_error("Cannot lock down memory area (%s)", strerror(errno)); | |||||
} | |||||
} | } | ||||
void UnlockMemoryImp(void* ptr, size_t size) | |||||
void UnlockMemoryImp(void* ptr, size_t size) | |||||
{ | { | ||||
if (CHECK_MUNLOCK(ptr, size)) { | |||||
JackLog("Succeeded in unlocking %u byte memory area\n", size); | |||||
} else { | |||||
jack_error("Cannot unlock down memory area (%s)", strerror(errno)); | |||||
} | |||||
if (CHECK_MUNLOCK(ptr, size)) { | |||||
JackLog("Succeeded in unlocking %u byte memory area\n", size); | |||||
} else { | |||||
jack_error("Cannot unlock down memory area (%s)", strerror(errno)); | |||||
} | |||||
} | } | ||||
void LockAllMemory() | |||||
void LockAllMemory() | |||||
{ | { | ||||
if (CHECK_MLOCKALL()) { | |||||
JackLog("Succeeded in locking all memory\n"); | |||||
} else { | |||||
jack_error("Cannot lock down memory area (%s)", strerror(errno)); | |||||
} | |||||
if (CHECK_MLOCKALL()) { | |||||
JackLog("Succeeded in locking all memory\n"); | |||||
} else { | |||||
jack_error("Cannot lock down memory area (%s)", strerror(errno)); | |||||
} | |||||
} | } | ||||
void UnlockAllMemory() | |||||
void UnlockAllMemory() | |||||
{ | { | ||||
if (CHECK_MUNLOCKALL()) { | |||||
JackLog("Succeeded in unlocking all memory\n"); | |||||
} else { | |||||
jack_error("Cannot unlock down memory area (%s)", strerror(errno)); | |||||
} | |||||
if (CHECK_MUNLOCKALL()) { | |||||
JackLog("Succeeded in unlocking all memory\n"); | |||||
} else { | |||||
jack_error("Cannot unlock down memory area (%s)", strerror(errno)); | |||||
} | |||||
} | } | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2004-2008 Grame | Copyright (C) 2004-2008 Grame | ||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
@@ -25,24 +25,24 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||||
#include "JackError.h" | #include "JackError.h" | ||||
#include <new> // GCC 4.0 | #include <new> // GCC 4.0 | ||||
#include <errno.h> | |||||
#include <errno.h> | |||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#ifdef WIN32 | #ifdef WIN32 | ||||
#include <windows.h> | |||||
#define CHECK_MLOCK(ptr, size) (VirtualLock((ptr), (size)) != 0) | |||||
#define CHECK_MUNLOCK(ptr, size) (VirtualUnlock((ptr), (size)) != 0) | |||||
#define CHECK_MLOCKALL()(false) | |||||
#define CHECK_MUNLOCKALL()(false) | |||||
#include <windows.h> | |||||
#define CHECK_MLOCK(ptr, size) (VirtualLock((ptr), (size)) != 0) | |||||
#define CHECK_MUNLOCK(ptr, size) (VirtualUnlock((ptr), (size)) != 0) | |||||
#define CHECK_MLOCKALL()(false) | |||||
#define CHECK_MUNLOCKALL()(false) | |||||
#else | #else | ||||
#include <sys/types.h> | |||||
#include <sys/mman.h> | |||||
#define CHECK_MLOCK(ptr, size) (mlock((ptr), (size)) == 0) | |||||
#define CHECK_MUNLOCK(ptr, size) (munlock((ptr), (size)) == 0) | |||||
#define CHECK_MLOCKALL() (mlockall(MCL_CURRENT | MCL_FUTURE) == 0) | |||||
#define CHECK_MUNLOCKALL() (munlockall() == 0) | |||||
#include <sys/types.h> | |||||
#include <sys/mman.h> | |||||
#define CHECK_MLOCK(ptr, size) (mlock((ptr), (size)) == 0) | |||||
#define CHECK_MUNLOCK(ptr, size) (munlock((ptr), (size)) == 0) | |||||
#define CHECK_MLOCKALL() (mlockall(MCL_CURRENT | MCL_FUTURE) == 0) | |||||
#define CHECK_MUNLOCKALL() (munlockall() == 0) | |||||
#endif | #endif | ||||
namespace Jack | namespace Jack | ||||
{ | { | ||||
@@ -51,55 +51,55 @@ void UnlockMemoryImp(void* ptr, size_t size); | |||||
class JackMem | class JackMem | ||||
{ | { | ||||
private: | |||||
private: | |||||
size_t fSize; | |||||
static size_t gSize; | |||||
public: | |||||
size_t fSize; | |||||
static size_t gSize; | |||||
public: | |||||
void* operator new(size_t size) | void* operator new(size_t size) | ||||
{ | |||||
gSize = size; | |||||
return calloc(1, size); | |||||
} | |||||
{ | |||||
gSize = size; | |||||
return calloc(1, size); | |||||
} | |||||
void operator delete(void* ptr, size_t size) | void operator delete(void* ptr, size_t size) | ||||
{ | |||||
free(ptr); | |||||
} | |||||
{ | |||||
free(ptr); | |||||
} | |||||
JackMem():fSize(gSize) | |||||
JackMem(): fSize(gSize) | |||||
{} | {} | ||||
virtual ~JackMem() | virtual ~JackMem() | ||||
{} | {} | ||||
void LockMemory() | |||||
{ | |||||
LockMemoryImp(this, fSize); | |||||
} | |||||
void UnlockMemory() | |||||
{ | |||||
UnlockMemoryImp(this, fSize); | |||||
} | |||||
void LockMemory() | |||||
{ | |||||
LockMemoryImp(this, fSize); | |||||
} | |||||
void UnlockMemory() | |||||
{ | |||||
UnlockMemoryImp(this, fSize); | |||||
} | |||||
}; | }; | ||||
/*! | /*! | ||||
\brief The base class for shared memory management. | \brief The base class for shared memory management. | ||||
A class which objects need to be allocated in shared memory derives from this class. | A class which objects need to be allocated in shared memory derives from this class. | ||||
*/ | */ | ||||
class JackShmMem | |||||
class JackShmMem | |||||
{ | { | ||||
protected: | protected: | ||||
jack_shm_info_t fInfo; | jack_shm_info_t fInfo; | ||||
static unsigned int fSegmentNum; | |||||
static unsigned int fSegmentNum; | |||||
static jack_shm_info_t gInfo; | static jack_shm_info_t gInfo; | ||||
public: | public: | ||||
@@ -110,9 +110,9 @@ class JackShmMem | |||||
JackShmMem() | JackShmMem() | ||||
{ | { | ||||
fInfo.index = gInfo.index; | fInfo.index = gInfo.index; | ||||
fInfo.attached_at = gInfo.attached_at; | |||||
fInfo.size = gInfo.size; | |||||
} | |||||
fInfo.attached_at = gInfo.attached_at; | |||||
fInfo.size = gInfo.size; | |||||
} | |||||
virtual ~JackShmMem() | virtual ~JackShmMem() | ||||
{} | {} | ||||
@@ -126,16 +126,16 @@ class JackShmMem | |||||
{ | { | ||||
return (char*)fInfo.attached_at; | return (char*)fInfo.attached_at; | ||||
} | } | ||||
void LockMemory() | |||||
{ | |||||
LockMemoryImp(this, fInfo.size); | |||||
} | |||||
void UnlockMemory() | |||||
{ | |||||
UnlockMemoryImp(this, fInfo.size); | |||||
} | |||||
void LockMemory() | |||||
{ | |||||
LockMemoryImp(this, fInfo.size); | |||||
} | |||||
void UnlockMemory() | |||||
{ | |||||
UnlockMemoryImp(this, fInfo.size); | |||||
} | |||||
}; | }; | ||||
@@ -153,16 +153,16 @@ class JackShmReadWritePtr | |||||
void Init(int index, const char* server_name = "default") | void Init(int index, const char* server_name = "default") | ||||
{ | { | ||||
if (fInfo.index < 0 && index >= 0) { | |||||
if (fInfo.index < 0 && index >= 0) { | |||||
JackLog("JackShmReadWritePtr::Init %ld %ld\n", index, fInfo.index); | JackLog("JackShmReadWritePtr::Init %ld %ld\n", index, fInfo.index); | ||||
if (jack_initialize_shm(server_name) < 0) | if (jack_initialize_shm(server_name) < 0) | ||||
throw -1; | |||||
throw - 1; | |||||
fInfo.index = index; | fInfo.index = index; | ||||
if (jack_attach_shm(&fInfo)) { | if (jack_attach_shm(&fInfo)) { | ||||
//jack_error("cannot attach shared memory segment", strerror(errno)); | //jack_error("cannot attach shared memory segment", strerror(errno)); | ||||
throw -2; | |||||
throw - 2; | |||||
} | } | ||||
} | |||||
} | |||||
} | } | ||||
public: | public: | ||||
@@ -189,12 +189,12 @@ class JackShmReadWritePtr | |||||
T* operator->() const | T* operator->() const | ||||
{ | { | ||||
return (T*)fInfo.attached_at; | |||||
return (T*)fInfo.attached_at; | |||||
} | } | ||||
operator T*() const | operator T*() const | ||||
{ | { | ||||
return (T*)fInfo.attached_at; | |||||
return (T*)fInfo.attached_at; | |||||
} | } | ||||
JackShmReadWritePtr& operator=(int index) | JackShmReadWritePtr& operator=(int index) | ||||
@@ -202,8 +202,8 @@ class JackShmReadWritePtr | |||||
Init(index); | Init(index); | ||||
return *this; | return *this; | ||||
} | } | ||||
void SetShmIndex(int index, const char* server_name) | |||||
void SetShmIndex(int index, const char* server_name) | |||||
{ | { | ||||
Init(index, server_name); | Init(index, server_name); | ||||
} | } | ||||
@@ -215,7 +215,7 @@ class JackShmReadWritePtr | |||||
T* GetShmAddress() | T* GetShmAddress() | ||||
{ | { | ||||
return (T*)fInfo.attached_at; | |||||
return (T*)fInfo.attached_at; | |||||
} | } | ||||
}; | }; | ||||
@@ -236,17 +236,17 @@ class JackShmReadWritePtr1 | |||||
if (fInfo.index < 0 && index >= 0) { | if (fInfo.index < 0 && index >= 0) { | ||||
JackLog("JackShmReadWritePtr1::Init %ld %ld\n", index, fInfo.index); | JackLog("JackShmReadWritePtr1::Init %ld %ld\n", index, fInfo.index); | ||||
if (jack_initialize_shm(server_name) < 0) | if (jack_initialize_shm(server_name) < 0) | ||||
throw -1; | |||||
throw - 1; | |||||
fInfo.index = index; | fInfo.index = index; | ||||
if (jack_attach_shm(&fInfo)) { | if (jack_attach_shm(&fInfo)) { | ||||
//jack_error("cannot attach shared memory segment", strerror(errno)); | //jack_error("cannot attach shared memory segment", strerror(errno)); | ||||
throw -2; | |||||
throw - 2; | |||||
} | } | ||||
/* | |||||
nobody else needs to access this shared memory any more, so | |||||
destroy it. because we have our own attachment to it, it won't | |||||
vanish till we exit (and release it). | |||||
*/ | |||||
/* | |||||
nobody else needs to access this shared memory any more, so | |||||
destroy it. because we have our own attachment to it, it won't | |||||
vanish till we exit (and release it). | |||||
*/ | |||||
jack_destroy_shm(&fInfo); | jack_destroy_shm(&fInfo); | ||||
} | } | ||||
} | } | ||||
@@ -275,7 +275,7 @@ class JackShmReadWritePtr1 | |||||
T* operator->() const | T* operator->() const | ||||
{ | { | ||||
return (T*)fInfo.attached_at; | |||||
return (T*)fInfo.attached_at; | |||||
} | } | ||||
operator T*() const | operator T*() const | ||||
@@ -288,11 +288,11 @@ class JackShmReadWritePtr1 | |||||
Init(index); | Init(index); | ||||
return *this; | return *this; | ||||
} | } | ||||
void SetShmIndex(int index, const char* server_name) | |||||
void SetShmIndex(int index, const char* server_name) | |||||
{ | { | ||||
Init(index, server_name); | Init(index, server_name); | ||||
} | |||||
} | |||||
int GetShmIndex() | int GetShmIndex() | ||||
{ | { | ||||
@@ -301,7 +301,7 @@ class JackShmReadWritePtr1 | |||||
T* GetShmAddress() | T* GetShmAddress() | ||||
{ | { | ||||
return (T*)fInfo.attached_at; | |||||
return (T*)fInfo.attached_at; | |||||
} | } | ||||
}; | }; | ||||
@@ -368,20 +368,20 @@ class JackShmReadPtr | |||||
Init(index); | Init(index); | ||||
return *this; | return *this; | ||||
} | } | ||||
void SetShmIndex(int index, const char* server_name) | |||||
void SetShmIndex(int index, const char* server_name) | |||||
{ | { | ||||
Init(index, server_name); | Init(index, server_name); | ||||
} | } | ||||
int GetShmIndex() | |||||
int GetShmIndex() | |||||
{ | { | ||||
return fInfo.index; | return fInfo.index; | ||||
} | } | ||||
T* GetShmAddress() | T* GetShmAddress() | ||||
{ | { | ||||
return (T*)fInfo.attached_at; | |||||
return (T*)fInfo.attached_at; | |||||
} | } | ||||
}; | }; | ||||
@@ -1,18 +1,18 @@ | |||||
/* | /* | ||||
Copyright (C) 2004-2008 Grame | |||||
Copyright (C) 2004-2008 Grame | |||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
it under the terms of the GNU Lesser General Public License as published by | it under the terms of the GNU Lesser General Public License as published by | ||||
the Free Software Foundation; either version 2.1 of the License, or | the Free Software Foundation; either version 2.1 of the License, or | ||||
(at your option) any later version. | (at your option) any later version. | ||||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | ||||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
GNU Lesser General Public License for more details. | GNU Lesser General Public License for more details. | ||||
You should have received a copy of the GNU Lesser General Public License | You should have received a copy of the GNU Lesser General Public License | ||||
along with this program; if not, write to the Free Software | |||||
along with this program; if not, write to the Free Software | |||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||||
*/ | */ | ||||
@@ -158,7 +158,7 @@ int JackServerSocket::Bind(const char* dir, const char* name, int which) // A re | |||||
// TO CORRECT: always reuse the same name for now... | // TO CORRECT: always reuse the same name for now... | ||||
snprintf(fName, sizeof(addr.sun_path) - 1, "%s/jack_%s_%d", dir, name, which); | snprintf(fName, sizeof(addr.sun_path) - 1, "%s/jack_%s_%d", dir, name, which); | ||||
strncpy(addr.sun_path, fName, sizeof(addr.sun_path) - 1); | |||||
strncpy(addr.sun_path, fName, sizeof(addr.sun_path) - 1); | |||||
/* | /* | ||||
if (access(addr.sun_path, F_OK) == 0) { | if (access(addr.sun_path, F_OK) == 0) { | ||||
goto error; | goto error; | ||||
@@ -209,7 +209,7 @@ int JackServerSocket::Bind(const char* dir, int which) // A revoir : utilisation | |||||
// TO CORRECT: always reuse the same name for now... | // TO CORRECT: always reuse the same name for now... | ||||
snprintf(fName, sizeof(addr.sun_path) - 1, "%s/jack_%d", dir, which); | snprintf(fName, sizeof(addr.sun_path) - 1, "%s/jack_%d", dir, which); | ||||
strncpy(addr.sun_path, fName, sizeof(addr.sun_path) - 1); | |||||
strncpy(addr.sun_path, fName, sizeof(addr.sun_path) - 1); | |||||
/* | /* | ||||
if (access(addr.sun_path, F_OK) == 0) { | if (access(addr.sun_path, F_OK) == 0) { | ||||
goto error; | goto error; | ||||
@@ -1,18 +1,18 @@ | |||||
/* | /* | ||||
Copyright (C) 2004-2008 Grame | |||||
Copyright (C) 2004-2008 Grame | |||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
it under the terms of the GNU Lesser General Public License as published by | it under the terms of the GNU Lesser General Public License as published by | ||||
the Free Software Foundation; either version 2.1 of the License, or | the Free Software Foundation; either version 2.1 of the License, or | ||||
(at your option) any later version. | (at your option) any later version. | ||||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | ||||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
GNU Lesser General Public License for more details. | GNU Lesser General Public License for more details. | ||||
You should have received a copy of the GNU Lesser General Public License | You should have received a copy of the GNU Lesser General Public License | ||||
along with this program; if not, write to the Free Software | |||||
along with this program; if not, write to the Free Software | |||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||||
*/ | */ | ||||
@@ -1,18 +1,18 @@ | |||||
/* | /* | ||||
Copyright (C) 2004-2008 Grame | |||||
Copyright (C) 2004-2008 Grame | |||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
it under the terms of the GNU Lesser General Public License as published by | it under the terms of the GNU Lesser General Public License as published by | ||||
the Free Software Foundation; either version 2.1 of the License, or | the Free Software Foundation; either version 2.1 of the License, or | ||||
(at your option) any later version. | (at your option) any later version. | ||||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | ||||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
GNU Lesser General Public License for more details. | GNU Lesser General Public License for more details. | ||||
You should have received a copy of the GNU Lesser General Public License | You should have received a copy of the GNU Lesser General Public License | ||||
along with this program; if not, write to the Free Software | |||||
along with this program; if not, write to the Free Software | |||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||||
*/ | */ | ||||
@@ -40,37 +40,37 @@ JackSocketClientChannel::~JackSocketClientChannel() | |||||
int JackSocketClientChannel::ServerCheck(const char* server_name) | int JackSocketClientChannel::ServerCheck(const char* server_name) | ||||
{ | { | ||||
JackLog("JackSocketClientChannel::ServerCheck = %s\n", server_name); | |||||
JackLog("JackSocketClientChannel::ServerCheck = %s\n", server_name); | |||||
// Connect to server | // Connect to server | ||||
if (fRequestSocket.Connect(jack_server_dir, server_name, 0) < 0) { | if (fRequestSocket.Connect(jack_server_dir, server_name, 0) < 0) { | ||||
jack_error("Cannot connect to server socket"); | |||||
fRequestSocket.Close(); | |||||
jack_error("Cannot connect to server socket"); | |||||
fRequestSocket.Close(); | |||||
return -1; | return -1; | ||||
} else { | } else { | ||||
return 0; | |||||
} | |||||
return 0; | |||||
} | |||||
} | } | ||||
int JackSocketClientChannel::Open(const char* server_name, const char* name, char* name_res, JackClient* obj, jack_options_t options, jack_status_t* status) | int JackSocketClientChannel::Open(const char* server_name, const char* name, char* name_res, JackClient* obj, jack_options_t options, jack_status_t* status) | ||||
{ | { | ||||
int result = 0; | |||||
int result = 0; | |||||
JackLog("JackSocketClientChannel::Open name = %s\n", name); | JackLog("JackSocketClientChannel::Open name = %s\n", name); | ||||
if (fRequestSocket.Connect(jack_server_dir, server_name, 0) < 0) { | if (fRequestSocket.Connect(jack_server_dir, server_name, 0) < 0) { | ||||
jack_error("Cannot connect to server socket"); | jack_error("Cannot connect to server socket"); | ||||
goto error; | goto error; | ||||
} | } | ||||
// Check name in server | |||||
ClientCheck(name, name_res, JACK_PROTOCOL_VERSION, (int)options, (int*)status, &result); | |||||
// Check name in server | |||||
ClientCheck(name, name_res, JACK_PROTOCOL_VERSION, (int)options, (int*)status, &result); | |||||
if (result < 0) { | if (result < 0) { | ||||
int status1 = *status; | int status1 = *status; | ||||
if (status1 & JackVersionError) | if (status1 & JackVersionError) | ||||
jack_error("JACK protocol mismatch %d", JACK_PROTOCOL_VERSION); | |||||
jack_error("JACK protocol mismatch %d", JACK_PROTOCOL_VERSION); | |||||
else | else | ||||
jack_error("Client name = %s conflits with another running client", name); | |||||
goto error; | |||||
jack_error("Client name = %s conflits with another running client", name); | |||||
goto error; | |||||
} | } | ||||
if (fNotificationListenSocket.Bind(jack_client_dir, name_res, 0) < 0) { | if (fNotificationListenSocket.Bind(jack_client_dir, name_res, 0) < 0) { | ||||
@@ -141,11 +141,11 @@ void JackSocketClientChannel::ServerAsyncCall(JackRequest* req, JackResult* res, | |||||
void JackSocketClientChannel::ClientCheck(const char* name, char* name_res, int protocol, int options, int* status, int* result) | void JackSocketClientChannel::ClientCheck(const char* name, char* name_res, int protocol, int options, int* status, int* result) | ||||
{ | { | ||||
JackClientCheckRequest req(name, protocol, options); | |||||
JackClientCheckRequest req(name, protocol, options); | |||||
JackClientCheckResult res; | JackClientCheckResult res; | ||||
ServerSyncCall(&req, &res, result); | ServerSyncCall(&req, &res, result); | ||||
*status = res.fStatus; | |||||
strcpy(name_res, res.fName); | |||||
*status = res.fStatus; | |||||
strcpy(name_res, res.fName); | |||||
} | } | ||||
void JackSocketClientChannel::ClientOpen(const char* name, int* shared_engine, int* shared_client, int* shared_graph, int* result) | void JackSocketClientChannel::ClientOpen(const char* name, int* shared_engine, int* shared_client, int* shared_graph, int* result) | ||||
@@ -255,7 +255,7 @@ void JackSocketClientChannel::GetInternalClientName(int refnum, int int_ref, cha | |||||
JackGetInternalClientNameRequest req(refnum, int_ref); | JackGetInternalClientNameRequest req(refnum, int_ref); | ||||
JackGetInternalClientNameResult res; | JackGetInternalClientNameResult res; | ||||
ServerSyncCall(&req, &res, result); | ServerSyncCall(&req, &res, result); | ||||
strcpy(name_res, res.fName); | |||||
strcpy(name_res, res.fName); | |||||
} | } | ||||
void JackSocketClientChannel::InternalClientHandle(int refnum, const char* client_name, int* status, int* int_ref, int* result) | void JackSocketClientChannel::InternalClientHandle(int refnum, const char* client_name, int* status, int* int_ref, int* result) | ||||
@@ -263,8 +263,8 @@ void JackSocketClientChannel::InternalClientHandle(int refnum, const char* clien | |||||
JackInternalClientHandleRequest req(refnum, client_name); | JackInternalClientHandleRequest req(refnum, client_name); | ||||
JackInternalClientHandleResult res; | JackInternalClientHandleResult res; | ||||
ServerSyncCall(&req, &res, result); | ServerSyncCall(&req, &res, result); | ||||
*int_ref = res.fIntRefNum; | |||||
*status = res.fStatus; | |||||
*int_ref = res.fIntRefNum; | |||||
*status = res.fStatus; | |||||
} | } | ||||
void JackSocketClientChannel::InternalClientLoad(int refnum, const char* client_name, const char* so_name, const char* objet_data, int options, int* status, int* int_ref, int* result) | void JackSocketClientChannel::InternalClientLoad(int refnum, const char* client_name, const char* so_name, const char* objet_data, int options, int* status, int* int_ref, int* result) | ||||
@@ -272,8 +272,8 @@ void JackSocketClientChannel::InternalClientLoad(int refnum, const char* client_ | |||||
JackInternalClientLoadRequest req(refnum, client_name, so_name, objet_data, options); | JackInternalClientLoadRequest req(refnum, client_name, so_name, objet_data, options); | ||||
JackInternalClientLoadResult res; | JackInternalClientLoadResult res; | ||||
ServerSyncCall(&req, &res, result); | ServerSyncCall(&req, &res, result); | ||||
*int_ref = res.fIntRefNum; | |||||
*status = res.fStatus; | |||||
*int_ref = res.fIntRefNum; | |||||
*status = res.fStatus; | |||||
} | } | ||||
void JackSocketClientChannel::InternalClientUnload(int refnum, int int_ref, int* status, int* result) | void JackSocketClientChannel::InternalClientUnload(int refnum, int int_ref, int* status, int* result) | ||||
@@ -281,7 +281,7 @@ void JackSocketClientChannel::InternalClientUnload(int refnum, int int_ref, int* | |||||
JackInternalClientUnloadRequest req(refnum, int_ref); | JackInternalClientUnloadRequest req(refnum, int_ref); | ||||
JackInternalClientUnloadResult res; | JackInternalClientUnloadResult res; | ||||
ServerSyncCall(&req, &res, result); | ServerSyncCall(&req, &res, result); | ||||
*status = res.fStatus; | |||||
*status = res.fStatus; | |||||
} | } | ||||
bool JackSocketClientChannel::Init() | bool JackSocketClientChannel::Init() | ||||
@@ -1,18 +1,18 @@ | |||||
/* | /* | ||||
Copyright (C) 2004-2008 Grame | |||||
Copyright (C) 2004-2008 Grame | |||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
it under the terms of the GNU Lesser General Public License as published by | it under the terms of the GNU Lesser General Public License as published by | ||||
the Free Software Foundation; either version 2.1 of the License, or | the Free Software Foundation; either version 2.1 of the License, or | ||||
(at your option) any later version. | (at your option) any later version. | ||||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | ||||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
GNU Lesser General Public License for more details. | GNU Lesser General Public License for more details. | ||||
You should have received a copy of the GNU Lesser General Public License | You should have received a copy of the GNU Lesser General Public License | ||||
along with this program; if not, write to the Free Software | |||||
along with this program; if not, write to the Free Software | |||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||||
*/ | */ | ||||
@@ -56,10 +56,10 @@ class JackSocketClientChannel : public JackClientChannelInterface, public JackRu | |||||
int Start(); | int Start(); | ||||
void Stop(); | void Stop(); | ||||
int ServerCheck(const char* server_name); | |||||
void ClientCheck(const char* name, char* name_res, int protocol, int options, int* status, int* result); | |||||
int ServerCheck(const char* server_name); | |||||
void ClientCheck(const char* name, char* name_res, int protocol, int options, int* status, int* result); | |||||
void ClientOpen(const char* name, int* shared_engine, int* shared_client, int* shared_graph, int* result); | void ClientOpen(const char* name, int* shared_engine, int* shared_client, int* shared_graph, int* result); | ||||
void ClientClose(int refnum, int* result); | void ClientClose(int refnum, int* result); | ||||
@@ -80,12 +80,12 @@ class JackSocketClientChannel : public JackClientChannelInterface, public JackRu | |||||
void ReleaseTimebase(int refnum, int* result); | void ReleaseTimebase(int refnum, int* result); | ||||
void SetTimebaseCallback(int refnum, int conditional, int* result); | void SetTimebaseCallback(int refnum, int conditional, int* result); | ||||
void GetInternalClientName(int refnum, int int_ref, char* name_res, int* result); | |||||
void GetInternalClientName(int refnum, int int_ref, char* name_res, int* result); | |||||
void InternalClientHandle(int refnum, const char* client_name, int* status, int* int_ref, int* result); | void InternalClientHandle(int refnum, const char* client_name, int* status, int* int_ref, int* result); | ||||
void InternalClientLoad(int refnum, const char* client_name, const char* so_name, const char* objet_data, int options, int* status, int* int_ref, int* result); | void InternalClientLoad(int refnum, const char* client_name, const char* so_name, const char* objet_data, int options, int* status, int* int_ref, int* result); | ||||
void InternalClientUnload(int refnum, int int_ref, int* status, int* result); | void InternalClientUnload(int refnum, int int_ref, int* status, int* result); | ||||
// JackRunnableInterface interface | // JackRunnableInterface interface | ||||
bool Init(); | bool Init(); | ||||
bool Execute(); | bool Execute(); | ||||
@@ -1,18 +1,18 @@ | |||||
/* | /* | ||||
Copyright (C) 2004-2008 Grame | |||||
Copyright (C) 2004-2008 Grame | |||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
it under the terms of the GNU Lesser General Public License as published by | it under the terms of the GNU Lesser General Public License as published by | ||||
the Free Software Foundation; either version 2.1 of the License, or | the Free Software Foundation; either version 2.1 of the License, or | ||||
(at your option) any later version. | (at your option) any later version. | ||||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | ||||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
GNU Lesser General Public License for more details. | GNU Lesser General Public License for more details. | ||||
You should have received a copy of the GNU Lesser General Public License | You should have received a copy of the GNU Lesser General Public License | ||||
along with this program; if not, write to the Free Software | |||||
along with this program; if not, write to the Free Software | |||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||||
*/ | */ | ||||
@@ -1,18 +1,18 @@ | |||||
/* | /* | ||||
Copyright (C) 2004-2008 Grame | |||||
Copyright (C) 2004-2008 Grame | |||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
it under the terms of the GNU Lesser General Public License as published by | it under the terms of the GNU Lesser General Public License as published by | ||||
the Free Software Foundation; either version 2.1 of the License, or | the Free Software Foundation; either version 2.1 of the License, or | ||||
(at your option) any later version. | (at your option) any later version. | ||||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | ||||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
GNU Lesser General Public License for more details. | GNU Lesser General Public License for more details. | ||||
You should have received a copy of the GNU Lesser General Public License | You should have received a copy of the GNU Lesser General Public License | ||||
along with this program; if not, write to the Free Software | |||||
along with this program; if not, write to the Free Software | |||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||||
*/ | */ | ||||
@@ -1,18 +1,18 @@ | |||||
/* | /* | ||||
Copyright (C) 2004-2008 Grame | |||||
Copyright (C) 2004-2008 Grame | |||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
it under the terms of the GNU Lesser General Public License as published by | it under the terms of the GNU Lesser General Public License as published by | ||||
the Free Software Foundation; either version 2.1 of the License, or | the Free Software Foundation; either version 2.1 of the License, or | ||||
(at your option) any later version. | (at your option) any later version. | ||||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | ||||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
GNU Lesser General Public License for more details. | GNU Lesser General Public License for more details. | ||||
You should have received a copy of the GNU Lesser General Public License | You should have received a copy of the GNU Lesser General Public License | ||||
along with this program; if not, write to the Free Software | |||||
along with this program; if not, write to the Free Software | |||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||||
*/ | */ | ||||
@@ -47,7 +47,7 @@ JackSocketServerChannel::~JackSocketServerChannel() | |||||
int JackSocketServerChannel::Open(const char* server_name, JackServer* server) | int JackSocketServerChannel::Open(const char* server_name, JackServer* server) | ||||
{ | { | ||||
JackLog("JackSocketServerChannel::Open \n"); | JackLog("JackSocketServerChannel::Open \n"); | ||||
fServer = server; | |||||
fServer = server; | |||||
// Prepare request socket | // Prepare request socket | ||||
if (fRequestListenSocket.Bind(jack_server_dir, server_name, 0) < 0) { | if (fRequestListenSocket.Bind(jack_server_dir, server_name, 0) < 0) { | ||||
@@ -93,7 +93,7 @@ void JackSocketServerChannel::ClientAdd(int fd, char* name, int* shared_engine, | |||||
{ | { | ||||
JackLog("JackSocketServerChannel::ClientAdd\n"); | JackLog("JackSocketServerChannel::ClientAdd\n"); | ||||
int refnum = -1; | int refnum = -1; | ||||
*result = fServer->GetEngine()->ClientExternalOpen(name, &refnum, shared_engine, shared_client, shared_graph); | |||||
*result = fServer->GetEngine()->ClientExternalOpen(name, &refnum, shared_engine, shared_client, shared_graph); | |||||
if (*result == 0) { | if (*result == 0) { | ||||
fSocketTable[fd].first = refnum; | fSocketTable[fd].first = refnum; | ||||
fRebuild = true; | fRebuild = true; | ||||
@@ -150,223 +150,223 @@ int JackSocketServerChannel::HandleRequest(int fd) | |||||
// Read data | // Read data | ||||
switch (header.fType) { | switch (header.fType) { | ||||
case JackRequest::kClientCheck: { | |||||
JackLog("JackRequest::kClientCheck\n"); | |||||
JackClientCheckRequest req; | |||||
JackClientCheckResult res; | |||||
if (req.Read(socket) == 0) | |||||
res.fResult = fServer->GetEngine()->ClientCheck(req.fName, res.fName, req.fProtocol, req.fOptions, &res.fStatus); | |||||
if (res.Write(socket) < 0) | |||||
jack_error("JackRequest::kClientCheck write error name = %s", req.fName); | |||||
break; | |||||
} | |||||
case JackRequest::kClientCheck: { | |||||
JackLog("JackRequest::kClientCheck\n"); | |||||
JackClientCheckRequest req; | |||||
JackClientCheckResult res; | |||||
if (req.Read(socket) == 0) | |||||
res.fResult = fServer->GetEngine()->ClientCheck(req.fName, res.fName, req.fProtocol, req.fOptions, &res.fStatus); | |||||
if (res.Write(socket) < 0) | |||||
jack_error("JackRequest::kClientCheck write error name = %s", req.fName); | |||||
break; | |||||
} | |||||
case JackRequest::kClientOpen: { | case JackRequest::kClientOpen: { | ||||
JackLog("JackRequest::ClientOpen\n"); | |||||
JackClientOpenRequest req; | |||||
JackClientOpenResult res; | |||||
if (req.Read(socket) == 0) | |||||
ClientAdd(fd, req.fName, &res.fSharedEngine, &res.fSharedClient, &res.fSharedGraph, &res.fResult); | |||||
if (res.Write(socket) < 0) | |||||
jack_error("JackRequest::kClientOpen write error name = %s", req.fName); | |||||
break; | |||||
} | |||||
JackLog("JackRequest::ClientOpen\n"); | |||||
JackClientOpenRequest req; | |||||
JackClientOpenResult res; | |||||
if (req.Read(socket) == 0) | |||||
ClientAdd(fd, req.fName, &res.fSharedEngine, &res.fSharedClient, &res.fSharedGraph, &res.fResult); | |||||
if (res.Write(socket) < 0) | |||||
jack_error("JackRequest::kClientOpen write error name = %s", req.fName); | |||||
break; | |||||
} | |||||
case JackRequest::kClientClose: { | case JackRequest::kClientClose: { | ||||
JackLog("JackRequest::ClientClose\n"); | |||||
JackClientCloseRequest req; | |||||
JackResult res; | |||||
if (req.Read(socket) == 0) | |||||
res.fResult = fServer->GetEngine()->ClientExternalClose(req.fRefNum); | |||||
// No write: client is actually doing an "ServerAsyncCall", and not interested by the result | |||||
ClientRemove(fd, req.fRefNum); | |||||
break; | |||||
} | |||||
JackLog("JackRequest::ClientClose\n"); | |||||
JackClientCloseRequest req; | |||||
JackResult res; | |||||
if (req.Read(socket) == 0) | |||||
res.fResult = fServer->GetEngine()->ClientExternalClose(req.fRefNum); | |||||
// No write: client is actually doing an "ServerAsyncCall", and not interested by the result | |||||
ClientRemove(fd, req.fRefNum); | |||||
break; | |||||
} | |||||
case JackRequest::kActivateClient: { | case JackRequest::kActivateClient: { | ||||
JackActivateRequest req; | |||||
JackResult res; | |||||
JackLog("JackRequest::ActivateClient\n"); | |||||
if (req.Read(socket) == 0) | |||||
res.fResult = fServer->GetEngine()->ClientActivate(req.fRefNum); | |||||
if (res.Write(socket) < 0) | |||||
jack_error("JackRequest::kActivateClient write error ref = %d", req.fRefNum); | |||||
break; | |||||
} | |||||
JackActivateRequest req; | |||||
JackResult res; | |||||
JackLog("JackRequest::ActivateClient\n"); | |||||
if (req.Read(socket) == 0) | |||||
res.fResult = fServer->GetEngine()->ClientActivate(req.fRefNum); | |||||
if (res.Write(socket) < 0) | |||||
jack_error("JackRequest::kActivateClient write error ref = %d", req.fRefNum); | |||||
break; | |||||
} | |||||
case JackRequest::kDeactivateClient: { | case JackRequest::kDeactivateClient: { | ||||
JackLog("JackRequest::DeactivateClient\n"); | |||||
JackDeactivateRequest req; | |||||
JackResult res; | |||||
if (req.Read(socket) == 0) | |||||
res.fResult = fServer->GetEngine()->ClientDeactivate(req.fRefNum); | |||||
if (res.Write(socket) < 0) | |||||
jack_error("JackRequest::kDeactivateClient write error ref = %d", req.fRefNum); | |||||
break; | |||||
} | |||||
JackLog("JackRequest::DeactivateClient\n"); | |||||
JackDeactivateRequest req; | |||||
JackResult res; | |||||
if (req.Read(socket) == 0) | |||||
res.fResult = fServer->GetEngine()->ClientDeactivate(req.fRefNum); | |||||
if (res.Write(socket) < 0) | |||||
jack_error("JackRequest::kDeactivateClient write error ref = %d", req.fRefNum); | |||||
break; | |||||
} | |||||
case JackRequest::kRegisterPort: { | case JackRequest::kRegisterPort: { | ||||
JackLog("JackRequest::RegisterPort\n"); | |||||
JackPortRegisterRequest req; | |||||
JackPortRegisterResult res; | |||||
if (req.Read(socket) == 0) | |||||
res.fResult = fServer->GetEngine()->PortRegister(req.fRefNum, req.fName, req.fPortType, req.fFlags, req.fBufferSize, &res.fPortIndex); | |||||
if (res.Write(socket) < 0) | |||||
jack_error("JackRequest::kRegisterPort write error ref = %d", req.fRefNum); | |||||
break; | |||||
} | |||||
JackLog("JackRequest::RegisterPort\n"); | |||||
JackPortRegisterRequest req; | |||||
JackPortRegisterResult res; | |||||
if (req.Read(socket) == 0) | |||||
res.fResult = fServer->GetEngine()->PortRegister(req.fRefNum, req.fName, req.fPortType, req.fFlags, req.fBufferSize, &res.fPortIndex); | |||||
if (res.Write(socket) < 0) | |||||
jack_error("JackRequest::kRegisterPort write error ref = %d", req.fRefNum); | |||||
break; | |||||
} | |||||
case JackRequest::kUnRegisterPort: { | case JackRequest::kUnRegisterPort: { | ||||
JackLog("JackRequest::UnRegisterPort\n"); | |||||
JackPortUnRegisterRequest req; | |||||
JackResult res; | |||||
if (req.Read(socket) == 0) | |||||
res.fResult = fServer->GetEngine()->PortUnRegister(req.fRefNum, req.fPortIndex); | |||||
if (res.Write(socket) < 0) | |||||
jack_error("JackRequest::kUnRegisterPort write error ref = %d", req.fRefNum); | |||||
break; | |||||
} | |||||
JackLog("JackRequest::UnRegisterPort\n"); | |||||
JackPortUnRegisterRequest req; | |||||
JackResult res; | |||||
if (req.Read(socket) == 0) | |||||
res.fResult = fServer->GetEngine()->PortUnRegister(req.fRefNum, req.fPortIndex); | |||||
if (res.Write(socket) < 0) | |||||
jack_error("JackRequest::kUnRegisterPort write error ref = %d", req.fRefNum); | |||||
break; | |||||
} | |||||
case JackRequest::kConnectNamePorts: { | case JackRequest::kConnectNamePorts: { | ||||
JackLog("JackRequest::ConnectPorts\n"); | |||||
JackPortConnectNameRequest req; | |||||
JackResult res; | |||||
if (req.Read(socket) == 0) | |||||
res.fResult = fServer->GetEngine()->PortConnect(req.fRefNum, req.fSrc, req.fDst); | |||||
if (res.Write(socket) < 0) | |||||
jack_error("JackRequest::kConnectNamePorts write error ref = %d", req.fRefNum); | |||||
break; | |||||
} | |||||
JackLog("JackRequest::ConnectPorts\n"); | |||||
JackPortConnectNameRequest req; | |||||
JackResult res; | |||||
if (req.Read(socket) == 0) | |||||
res.fResult = fServer->GetEngine()->PortConnect(req.fRefNum, req.fSrc, req.fDst); | |||||
if (res.Write(socket) < 0) | |||||
jack_error("JackRequest::kConnectNamePorts write error ref = %d", req.fRefNum); | |||||
break; | |||||
} | |||||
case JackRequest::kDisconnectNamePorts: { | case JackRequest::kDisconnectNamePorts: { | ||||
JackLog("JackRequest::DisconnectPorts\n"); | |||||
JackPortDisconnectNameRequest req; | |||||
JackResult res; | |||||
if (req.Read(socket) == 0) | |||||
res.fResult = fServer->GetEngine()->PortDisconnect(req.fRefNum, req.fSrc, req.fDst); | |||||
if (res.Write(socket) < 0) | |||||
jack_error("JackRequest::kDisconnectNamePorts write error ref = %d", req.fRefNum); | |||||
break; | |||||
} | |||||
JackLog("JackRequest::DisconnectPorts\n"); | |||||
JackPortDisconnectNameRequest req; | |||||
JackResult res; | |||||
if (req.Read(socket) == 0) | |||||
res.fResult = fServer->GetEngine()->PortDisconnect(req.fRefNum, req.fSrc, req.fDst); | |||||
if (res.Write(socket) < 0) | |||||
jack_error("JackRequest::kDisconnectNamePorts write error ref = %d", req.fRefNum); | |||||
break; | |||||
} | |||||
case JackRequest::kConnectPorts: { | case JackRequest::kConnectPorts: { | ||||
JackLog("JackRequest::ConnectPorts\n"); | |||||
JackPortConnectRequest req; | |||||
JackResult res; | |||||
if (req.Read(socket) == 0) | |||||
res.fResult = fServer->GetEngine()->PortConnect(req.fRefNum, req.fSrc, req.fDst); | |||||
if (res.Write(socket) < 0) | |||||
jack_error("JackRequest::kConnectPorts write error ref = %d", req.fRefNum); | |||||
break; | |||||
} | |||||
JackLog("JackRequest::ConnectPorts\n"); | |||||
JackPortConnectRequest req; | |||||
JackResult res; | |||||
if (req.Read(socket) == 0) | |||||
res.fResult = fServer->GetEngine()->PortConnect(req.fRefNum, req.fSrc, req.fDst); | |||||
if (res.Write(socket) < 0) | |||||
jack_error("JackRequest::kConnectPorts write error ref = %d", req.fRefNum); | |||||
break; | |||||
} | |||||
case JackRequest::kDisconnectPorts: { | case JackRequest::kDisconnectPorts: { | ||||
JackLog("JackRequest::DisconnectPorts\n"); | |||||
JackPortDisconnectRequest req; | |||||
JackResult res; | |||||
if (req.Read(socket) == 0) | |||||
res.fResult = fServer->GetEngine()->PortDisconnect(req.fRefNum, req.fSrc, req.fDst); | |||||
if (res.Write(socket) < 0) | |||||
jack_error("JackRequest::kDisconnectPorts write error ref = %d", req.fRefNum); | |||||
break; | |||||
} | |||||
JackLog("JackRequest::DisconnectPorts\n"); | |||||
JackPortDisconnectRequest req; | |||||
JackResult res; | |||||
if (req.Read(socket) == 0) | |||||
res.fResult = fServer->GetEngine()->PortDisconnect(req.fRefNum, req.fSrc, req.fDst); | |||||
if (res.Write(socket) < 0) | |||||
jack_error("JackRequest::kDisconnectPorts write error ref = %d", req.fRefNum); | |||||
break; | |||||
} | |||||
case JackRequest::kSetBufferSize: { | case JackRequest::kSetBufferSize: { | ||||
JackLog("JackRequest::SetBufferSize\n"); | |||||
JackSetBufferSizeRequest req; | |||||
JackResult res; | |||||
if (req.Read(socket) == 0) | |||||
res.fResult = fServer->SetBufferSize(req.fBufferSize); | |||||
if (res.Write(socket) < 0) | |||||
jack_error("JackRequest::kSetBufferSize write error"); | |||||
break; | |||||
} | |||||
JackLog("JackRequest::SetBufferSize\n"); | |||||
JackSetBufferSizeRequest req; | |||||
JackResult res; | |||||
if (req.Read(socket) == 0) | |||||
res.fResult = fServer->SetBufferSize(req.fBufferSize); | |||||
if (res.Write(socket) < 0) | |||||
jack_error("JackRequest::kSetBufferSize write error"); | |||||
break; | |||||
} | |||||
case JackRequest::kSetFreeWheel: { | case JackRequest::kSetFreeWheel: { | ||||
JackLog("JackRequest::SetFreeWheel\n"); | |||||
JackSetFreeWheelRequest req; | |||||
JackResult res; | |||||
if (req.Read(socket) == 0) | |||||
res.fResult = fServer->SetFreewheel(req.fOnOff); | |||||
if (res.Write(socket) < 0) | |||||
jack_error("JackRequest::kSetFreeWheel write error"); | |||||
break; | |||||
} | |||||
JackLog("JackRequest::SetFreeWheel\n"); | |||||
JackSetFreeWheelRequest req; | |||||
JackResult res; | |||||
if (req.Read(socket) == 0) | |||||
res.fResult = fServer->SetFreewheel(req.fOnOff); | |||||
if (res.Write(socket) < 0) | |||||
jack_error("JackRequest::kSetFreeWheel write error"); | |||||
break; | |||||
} | |||||
case JackRequest::kReleaseTimebase: { | case JackRequest::kReleaseTimebase: { | ||||
JackLog("JackRequest::kReleaseTimebase\n"); | |||||
JackReleaseTimebaseRequest req; | |||||
JackResult res; | |||||
if (req.Read(socket) == 0) | |||||
res.fResult = fServer->ReleaseTimebase(req.fRefNum); | |||||
if (res.Write(socket) < 0) | |||||
jack_error("JackRequest::kReleaseTimebase write error ref = %d", req.fRefNum); | |||||
break; | |||||
} | |||||
JackLog("JackRequest::kReleaseTimebase\n"); | |||||
JackReleaseTimebaseRequest req; | |||||
JackResult res; | |||||
if (req.Read(socket) == 0) | |||||
res.fResult = fServer->ReleaseTimebase(req.fRefNum); | |||||
if (res.Write(socket) < 0) | |||||
jack_error("JackRequest::kReleaseTimebase write error ref = %d", req.fRefNum); | |||||
break; | |||||
} | |||||
case JackRequest::kSetTimebaseCallback: { | case JackRequest::kSetTimebaseCallback: { | ||||
JackLog("JackRequest::kSetTimebaseCallback\n"); | |||||
JackSetTimebaseCallbackRequest req; | |||||
JackResult res; | |||||
if (req.Read(socket) == 0) | |||||
res.fResult = fServer->SetTimebaseCallback(req.fRefNum, req.fConditionnal); | |||||
if (res.Write(socket) < 0) | |||||
jack_error("JackRequest::kSetTimebaseCallback write error ref = %d", req.fRefNum); | |||||
break; | |||||
} | |||||
case JackRequest::kGetInternalClientName: { | |||||
JackLog("JackRequest::kGetInternalClientName\n"); | |||||
JackGetInternalClientNameRequest req; | |||||
JackGetInternalClientNameResult res; | |||||
if (req.Read(socket) == 0) | |||||
res.fResult = fServer->GetEngine()->GetInternalClientName(req.fIntRefNum, res.fName); | |||||
if (res.Write(socket) < 0) | |||||
jack_error("JackRequest::kGetInternalClientName write error ref = %d", req.fRefNum); | |||||
break; | |||||
} | |||||
case JackRequest::kInternalClientHandle: { | |||||
JackLog("JackRequest::kInternalClientHandle\n"); | |||||
JackInternalClientHandleRequest req; | |||||
JackInternalClientHandleResult res; | |||||
if (req.Read(socket) == 0) | |||||
res.fResult = fServer->GetEngine()->InternalClientHandle(req.fName, &res.fStatus, &res.fIntRefNum); | |||||
if (res.Write(socket) < 0) | |||||
jack_error("JackRequest::kInternalClientHandle write error ref = %d", req.fRefNum); | |||||
break; | |||||
} | |||||
case JackRequest::kInternalClientLoad: { | |||||
JackLog("JackRequest::kInternalClientLoad\n"); | |||||
JackInternalClientLoadRequest req; | |||||
JackInternalClientLoadResult res; | |||||
if (req.Read(socket) == 0) | |||||
res.fResult = fServer->InternalClientLoad(req.fName, req.fDllName, req.fLoadInitName, req.fOptions, &res.fIntRefNum, &res.fStatus); | |||||
if (res.Write(socket) < 0) | |||||
jack_error("JackRequest::kInternalClientLoad write error name = %s", req.fName); | |||||
break; | |||||
} | |||||
case JackRequest::kInternalClientUnload: { | |||||
JackLog("JackRequest::kInternalClientUnload\n"); | |||||
JackInternalClientUnloadRequest req; | |||||
JackInternalClientUnloadResult res; | |||||
if (req.Read(socket) == 0) | |||||
res.fResult = fServer->GetEngine()->InternalClientUnload(req.fIntRefNum, &res.fStatus); | |||||
if (res.Write(socket) < 0) | |||||
jack_error("JackRequest::kInternalClientUnload write error ref = %d", req.fRefNum); | |||||
break; | |||||
} | |||||
JackLog("JackRequest::kSetTimebaseCallback\n"); | |||||
JackSetTimebaseCallbackRequest req; | |||||
JackResult res; | |||||
if (req.Read(socket) == 0) | |||||
res.fResult = fServer->SetTimebaseCallback(req.fRefNum, req.fConditionnal); | |||||
if (res.Write(socket) < 0) | |||||
jack_error("JackRequest::kSetTimebaseCallback write error ref = %d", req.fRefNum); | |||||
break; | |||||
} | |||||
case JackRequest::kGetInternalClientName: { | |||||
JackLog("JackRequest::kGetInternalClientName\n"); | |||||
JackGetInternalClientNameRequest req; | |||||
JackGetInternalClientNameResult res; | |||||
if (req.Read(socket) == 0) | |||||
res.fResult = fServer->GetEngine()->GetInternalClientName(req.fIntRefNum, res.fName); | |||||
if (res.Write(socket) < 0) | |||||
jack_error("JackRequest::kGetInternalClientName write error ref = %d", req.fRefNum); | |||||
break; | |||||
} | |||||
case JackRequest::kInternalClientHandle: { | |||||
JackLog("JackRequest::kInternalClientHandle\n"); | |||||
JackInternalClientHandleRequest req; | |||||
JackInternalClientHandleResult res; | |||||
if (req.Read(socket) == 0) | |||||
res.fResult = fServer->GetEngine()->InternalClientHandle(req.fName, &res.fStatus, &res.fIntRefNum); | |||||
if (res.Write(socket) < 0) | |||||
jack_error("JackRequest::kInternalClientHandle write error ref = %d", req.fRefNum); | |||||
break; | |||||
} | |||||
case JackRequest::kInternalClientLoad: { | |||||
JackLog("JackRequest::kInternalClientLoad\n"); | |||||
JackInternalClientLoadRequest req; | |||||
JackInternalClientLoadResult res; | |||||
if (req.Read(socket) == 0) | |||||
res.fResult = fServer->InternalClientLoad(req.fName, req.fDllName, req.fLoadInitName, req.fOptions, &res.fIntRefNum, &res.fStatus); | |||||
if (res.Write(socket) < 0) | |||||
jack_error("JackRequest::kInternalClientLoad write error name = %s", req.fName); | |||||
break; | |||||
} | |||||
case JackRequest::kInternalClientUnload: { | |||||
JackLog("JackRequest::kInternalClientUnload\n"); | |||||
JackInternalClientUnloadRequest req; | |||||
JackInternalClientUnloadResult res; | |||||
if (req.Read(socket) == 0) | |||||
res.fResult = fServer->GetEngine()->InternalClientUnload(req.fIntRefNum, &res.fStatus); | |||||
if (res.Write(socket) < 0) | |||||
jack_error("JackRequest::kInternalClientUnload write error ref = %d", req.fRefNum); | |||||
break; | |||||
} | |||||
case JackRequest::kNotification: { | case JackRequest::kNotification: { | ||||
JackLog("JackRequest::Notification\n"); | |||||
JackClientNotificationRequest req; | |||||
if (req.Read(socket) == 0) | |||||
fServer->Notify(req.fRefNum, req.fNotify, req.fValue); | |||||
break; | |||||
} | |||||
JackLog("JackRequest::Notification\n"); | |||||
JackClientNotificationRequest req; | |||||
if (req.Read(socket) == 0) | |||||
fServer->Notify(req.fRefNum, req.fNotify, req.fValue); | |||||
break; | |||||
} | |||||
default: | default: | ||||
JackLog("Unknown request %ld\n", header.fType); | JackLog("Unknown request %ld\n", header.fType); | ||||
@@ -1,18 +1,18 @@ | |||||
/* | /* | ||||
Copyright (C) 2004-2008 Grame | |||||
Copyright (C) 2004-2008 Grame | |||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
it under the terms of the GNU Lesser General Public License as published by | it under the terms of the GNU Lesser General Public License as published by | ||||
the Free Software Foundation; either version 2.1 of the License, or | the Free Software Foundation; either version 2.1 of the License, or | ||||
(at your option) any later version. | (at your option) any later version. | ||||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | ||||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
GNU Lesser General Public License for more details. | GNU Lesser General Public License for more details. | ||||
You should have received a copy of the GNU Lesser General Public License | You should have received a copy of the GNU Lesser General Public License | ||||
along with this program; if not, write to the Free Software | |||||
along with this program; if not, write to the Free Software | |||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||||
*/ | */ | ||||
@@ -46,13 +46,13 @@ class JackSocketServerChannel : public JackServerChannelInterface, public JackRu | |||||
std::map<int, std::pair<int, JackClientSocket*> > fSocketTable; | std::map<int, std::pair<int, JackClientSocket*> > fSocketTable; | ||||
int HandleRequest(int fd); | int HandleRequest(int fd); | ||||
void BuildPoolTable(); | |||||
void BuildPoolTable(); | |||||
void ClientCreate(); | void ClientCreate(); | ||||
void ClientAdd(int fd, char* name, int* shared_engine, int* shared_client, int* shared_graph, int* result); | void ClientAdd(int fd, char* name, int* shared_engine, int* shared_client, int* shared_graph, int* result); | ||||
void ClientRemove(int fd, int refnum); | void ClientRemove(int fd, int refnum); | ||||
void ClientKill(int fd); | void ClientKill(int fd); | ||||
public: | public: | ||||
JackSocketServerChannel(); | JackSocketServerChannel(); | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2004-2008 Grame | |||||
Copyright (C) 2004-2008 Grame | |||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
it under the terms of the GNU General Public License as published by | it under the terms of the GNU General Public License as published by | ||||
@@ -41,9 +41,9 @@ void JackSocketServerNotifyChannel::Close() | |||||
} | } | ||||
/* | /* | ||||
The requirement is that the Notification from RT thread can be delivered... not sure using a socket is adequate here... | |||||
Can the write operation block? | |||||
A non blocking write operation shoud be used : check if write can succeed, and ignore the notification otherwise | |||||
The requirement is that the Notification from RT thread can be delivered... not sure using a socket is adequate here... | |||||
Can the write operation block? | |||||
A non blocking write operation shoud be used : check if write can succeed, and ignore the notification otherwise | |||||
(since its mainly used for XRun, ignoring a notification is OK, successive XRun will come...) | (since its mainly used for XRun, ignoring a notification is OK, successive XRun will come...) | ||||
*/ | */ | ||||
void JackSocketServerNotifyChannel::ClientNotify(int refnum, int notify, int value) | void JackSocketServerNotifyChannel::ClientNotify(int refnum, int notify, int value) | ||||
@@ -1,18 +1,18 @@ | |||||
/* | /* | ||||
Copyright (C) 2004-2008 Grame | |||||
Copyright (C) 2004-2008 Grame | |||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
it under the terms of the GNU Lesser General Public License as published by | it under the terms of the GNU Lesser General Public License as published by | ||||
the Free Software Foundation; either version 2.1 of the License, or | the Free Software Foundation; either version 2.1 of the License, or | ||||
(at your option) any later version. | (at your option) any later version. | ||||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | ||||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
GNU Lesser General Public License for more details. | GNU Lesser General Public License for more details. | ||||
You should have received a copy of the GNU Lesser General Public License | You should have received a copy of the GNU Lesser General Public License | ||||
along with this program; if not, write to the Free Software | |||||
along with this program; if not, write to the Free Software | |||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||||
*/ | */ | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2004-2006 Grame | |||||
Copyright (C) 2004-2006 Grame | |||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
it under the terms of the GNU General Public License as published by | it under the terms of the GNU General Public License as published by | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2004-2008 Grame | |||||
Copyright (C) 2004-2008 Grame | |||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
it under the terms of the GNU General Public License as published by | it under the terms of the GNU General Public License as published by | ||||
@@ -22,11 +22,11 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||||
#define __JackThread__ | #define __JackThread__ | ||||
#ifdef WIN32 | #ifdef WIN32 | ||||
#include <windows.h> | |||||
#include <windows.h> | |||||
typedef HANDLE pthread_t; | typedef HANDLE pthread_t; | ||||
typedef ULONGLONG UInt64; | typedef ULONGLONG UInt64; | ||||
#else | #else | ||||
#include <pthread.h> | |||||
#include <pthread.h> | |||||
typedef unsigned long long UInt64; | typedef unsigned long long UInt64; | ||||
#endif | #endif | ||||
@@ -81,7 +81,7 @@ class JackThread | |||||
virtual int StartSync() = 0; | virtual int StartSync() = 0; | ||||
virtual int Kill() = 0; | virtual int Kill() = 0; | ||||
virtual int Stop() = 0; | virtual int Stop() = 0; | ||||
virtual void Terminate() = 0; | |||||
virtual void Terminate() = 0; | |||||
virtual int AcquireRealTime() = 0; | virtual int AcquireRealTime() = 0; | ||||
virtual int AcquireRealTime(int priority) = 0; | virtual int AcquireRealTime(int priority) = 0; | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2004-2008 Grame | Copyright (C) 2004-2008 Grame | ||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
@@ -18,7 +18,7 @@ | |||||
*/ | */ | ||||
#ifdef WIN32 | |||||
#ifdef WIN32 | |||||
#pragma warning (disable : 4786) | #pragma warning (disable : 4786) | ||||
#endif | #endif | ||||
@@ -59,7 +59,7 @@ int JackThreadedDriver::Start() | |||||
if (fDriver->IsRealTime()) { | if (fDriver->IsRealTime()) { | ||||
JackLog("JackThreadedDriver::Start IsRealTime\n"); | JackLog("JackThreadedDriver::Start IsRealTime\n"); | ||||
if (fThread->AcquireRealTime(GetEngineControl()->fPriority) < 0) | |||||
if (fThread->AcquireRealTime(GetEngineControl()->fPriority) < 0) | |||||
jack_error("AcquireRealTime error"); | jack_error("AcquireRealTime error"); | ||||
} | } | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2004-2008 Grame | Copyright (C) 2004-2008 Grame | ||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
@@ -82,8 +82,8 @@ class JackThreadedDriver : public JackDriverClientInterface, public JackRunnable | |||||
{ | { | ||||
return fDriver->Detach(); | return fDriver->Detach(); | ||||
} | } | ||||
virtual int Read() | |||||
virtual int Read() | |||||
{ | { | ||||
return fDriver->Read(); | return fDriver->Read(); | ||||
} | } | ||||
@@ -99,8 +99,8 @@ class JackThreadedDriver : public JackDriverClientInterface, public JackRunnable | |||||
{ | { | ||||
return fDriver->SetBufferSize(buffer_size); | return fDriver->SetBufferSize(buffer_size); | ||||
} | } | ||||
virtual int SetSampleRate(jack_nframes_t sample_rate) | |||||
virtual int SetSampleRate(jack_nframes_t sample_rate) | |||||
{ | { | ||||
return fDriver->SetSampleRate(sample_rate); | return fDriver->SetSampleRate(sample_rate); | ||||
} | } | ||||
@@ -13,7 +13,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
GNU Lesser General Public License for more details. | GNU Lesser General Public License for more details. | ||||
You should have received a copy of the GNU Lesser General Public License | You should have received a copy of the GNU Lesser General Public License | ||||
along with this program; if not, write to the Free Software | |||||
along with this program; if not, write to the Free Software | |||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||||
*/ | */ | ||||
@@ -37,16 +37,14 @@ extern "C" | |||||
extern double __jack_time_ratio; | extern double __jack_time_ratio; | ||||
static inline jack_time_t GetMicroSeconds(void) | |||||
{ | |||||
static inline jack_time_t GetMicroSeconds(void) { | |||||
return (jack_time_t) (mach_absolute_time () * __jack_time_ratio); | return (jack_time_t) (mach_absolute_time () * __jack_time_ratio); | ||||
} | } | ||||
/* This should only be called ONCE per process. */ | /* This should only be called ONCE per process. */ | ||||
extern void InitTime(); | extern void InitTime(); | ||||
static inline void JackSleep(int usec) | |||||
{ | |||||
static inline void JackSleep(int usec) { | |||||
usleep(usec); | usleep(usec); | ||||
} | } | ||||
@@ -60,8 +58,7 @@ extern "C" | |||||
extern void InitTime(); | extern void InitTime(); | ||||
static void JackSleep(int usec) | |||||
{ | |||||
static void JackSleep(int usec) { | |||||
Sleep(usec / 1000); | Sleep(usec / 1000); | ||||
} | } | ||||
@@ -71,25 +68,22 @@ extern "C" | |||||
#include <unistd.h> | #include <unistd.h> | ||||
static inline void JackSleep(long usec) | |||||
{ | |||||
static inline void JackSleep(long usec) { | |||||
usleep(usec); | usleep(usec); | ||||
} | } | ||||
#ifdef GETCYCLE_TIME | #ifdef GETCYCLE_TIME | ||||
#include "cycles.h" | |||||
#include "cycles.h" | |||||
extern jack_time_t __jack_cpu_mhz; | extern jack_time_t __jack_cpu_mhz; | ||||
extern jack_time_t GetMhz(); | extern jack_time_t GetMhz(); | ||||
extern void InitTime(); | extern void InitTime(); | ||||
static inline jack_time_t GetMicroSeconds(void) | |||||
{ | |||||
static inline jack_time_t GetMicroSeconds(void) { | |||||
return get_cycles() / __jack_cpu_mhz; | return get_cycles() / __jack_cpu_mhz; | ||||
} | } | ||||
#else | #else | ||||
#include <time.h> | |||||
#include <time.h> | |||||
extern void InitTime(); | extern void InitTime(); | ||||
static inline jack_time_t GetMicroSeconds(void) | |||||
{ | |||||
static inline jack_time_t GetMicroSeconds(void) { | |||||
struct timespec ts; | struct timespec ts; | ||||
clock_gettime(CLOCK_MONOTONIC, &ts); | clock_gettime(CLOCK_MONOTONIC, &ts); | ||||
return (jack_time_t)ts.tv_sec * 1000000 + ts.tv_nsec / 1000; | return (jack_time_t)ts.tv_sec * 1000000 + ts.tv_nsec / 1000; | ||||
@@ -1,18 +1,18 @@ | |||||
/* | /* | ||||
Copyright (C) 2001 Paul Davis | Copyright (C) 2001 Paul Davis | ||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
it under the terms of the GNU Lesser General Public License as published by | it under the terms of the GNU Lesser General Public License as published by | ||||
the Free Software Foundation; either version 2.1 of the License, or | the Free Software Foundation; either version 2.1 of the License, or | ||||
(at your option) any later version. | (at your option) any later version. | ||||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | ||||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
GNU Lesser General Public License for more details. | GNU Lesser General Public License for more details. | ||||
You should have received a copy of the GNU Lesser General Public License | You should have received a copy of the GNU Lesser General Public License | ||||
along with this program; if not, write to the Free Software | |||||
along with this program; if not, write to the Free Software | |||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||||
*/ | */ | ||||
@@ -31,22 +31,22 @@ namespace Jack | |||||
#define DEFAULT_TMP_DIR "/tmp" | #define DEFAULT_TMP_DIR "/tmp" | ||||
char* jack_tmpdir = (char*)DEFAULT_TMP_DIR; | char* jack_tmpdir = (char*)DEFAULT_TMP_DIR; | ||||
int JackTools::GetPID() | |||||
int JackTools::GetPID() | |||||
{ | { | ||||
#ifdef WIN32 | #ifdef WIN32 | ||||
return _getpid(); | |||||
return _getpid(); | |||||
#else | #else | ||||
return getpid(); | |||||
return getpid(); | |||||
#endif | #endif | ||||
} | } | ||||
int JackTools::GetUID() | |||||
int JackTools::GetUID() | |||||
{ | { | ||||
#ifdef WIN32 | #ifdef WIN32 | ||||
return _getpid(); | |||||
//#error "No getuid function available" | |||||
return _getpid(); | |||||
//#error "No getuid function available" | |||||
#else | #else | ||||
return getuid(); | |||||
return getuid(); | |||||
#endif | #endif | ||||
} | } | ||||
@@ -63,152 +63,151 @@ const char* JackTools::DefaultServerName() | |||||
char* JackTools::UserDir() | char* JackTools::UserDir() | ||||
{ | { | ||||
return ""; | |||||
return ""; | |||||
} | } | ||||
char* JackTools::ServerDir(const char* server_name, char* server_dir) | char* JackTools::ServerDir(const char* server_name, char* server_dir) | ||||
{ | { | ||||
return ""; | |||||
return ""; | |||||
} | } | ||||
void JackTools::CleanupFiles(const char* server_name) | void JackTools::CleanupFiles(const char* server_name) | ||||
{ | { | ||||
} | } | ||||
int JackTools::GetTmpdir() | int JackTools::GetTmpdir() | ||||
{ | { | ||||
return 0; | |||||
return 0; | |||||
} | } | ||||
#else | #else | ||||
char* JackTools::UserDir() | char* JackTools::UserDir() | ||||
{ | { | ||||
static char user_dir[PATH_MAX + 1] = ""; | |||||
/* format the path name on the first call */ | |||||
if (user_dir[0] == '\0') { | |||||
if (getenv ("JACK_PROMISCUOUS_SERVER")) { | |||||
snprintf(user_dir, sizeof(user_dir), "%s/jack", jack_tmpdir); | |||||
} else { | |||||
snprintf(user_dir, sizeof(user_dir), "%s/jack-%d", jack_tmpdir, GetUID()); | |||||
} | |||||
} | |||||
return user_dir; | |||||
static char user_dir[PATH_MAX + 1] = ""; | |||||
/* format the path name on the first call */ | |||||
if (user_dir[0] == '\0') { | |||||
if (getenv ("JACK_PROMISCUOUS_SERVER")) { | |||||
snprintf(user_dir, sizeof(user_dir), "%s/jack", jack_tmpdir); | |||||
} else { | |||||
snprintf(user_dir, sizeof(user_dir), "%s/jack-%d", jack_tmpdir, GetUID()); | |||||
} | |||||
} | |||||
return user_dir; | |||||
} | } | ||||
/* returns the name of the per-server subdirectory of jack_user_dir() */ | /* returns the name of the per-server subdirectory of jack_user_dir() */ | ||||
char* JackTools::ServerDir(const char* server_name, char* server_dir) | char* JackTools::ServerDir(const char* server_name, char* server_dir) | ||||
{ | { | ||||
/* format the path name into the suppled server_dir char array, | |||||
* assuming that server_dir is at least as large as PATH_MAX+1 */ | |||||
/* format the path name into the suppled server_dir char array, | |||||
* assuming that server_dir is at least as large as PATH_MAX+1 */ | |||||
snprintf(server_dir, PATH_MAX + 1, "%s/%s", UserDir(), server_name); | |||||
return server_dir; | |||||
snprintf(server_dir, PATH_MAX + 1, "%s/%s", UserDir(), server_name); | |||||
return server_dir; | |||||
} | } | ||||
void JackTools::CleanupFiles(const char* server_name) | void JackTools::CleanupFiles(const char* server_name) | ||||
{ | { | ||||
DIR* dir; | DIR* dir; | ||||
struct dirent *dirent; | |||||
char dir_name[PATH_MAX + 1] = ""; | |||||
ServerDir(server_name, dir_name); | |||||
/* On termination, we remove all files that jackd creates so | |||||
* subsequent attempts to start jackd will not believe that an | |||||
* instance is already running. If the server crashes or is | |||||
* terminated with SIGKILL, this is not possible. So, cleanup | |||||
* is also attempted when jackd starts. | |||||
* | |||||
* There are several tricky issues. First, the previous JACK | |||||
* server may have run for a different user ID, so its files | |||||
* may be inaccessible. This is handled by using a separate | |||||
* JACK_TMP_DIR subdirectory for each user. Second, there may | |||||
* be other servers running with different names. Each gets | |||||
* its own subdirectory within the per-user directory. The | |||||
* current process has already registered as `server_name', so | |||||
* we know there is no other server actively using that name. | |||||
*/ | |||||
/* nothing to do if the server directory does not exist */ | |||||
if ((dir = opendir(dir_name)) == NULL) { | |||||
return; | |||||
} | |||||
/* unlink all the files in this directory, they are mine */ | |||||
while ((dirent = readdir(dir)) != NULL) { | |||||
char fullpath[PATH_MAX + 1]; | |||||
if ((strcmp(dirent->d_name, ".") == 0) || (strcmp (dirent->d_name, "..") == 0)) { | |||||
continue; | |||||
} | |||||
snprintf(fullpath, sizeof(fullpath), "%s/%s", dir_name, dirent->d_name); | |||||
if (unlink(fullpath)) { | |||||
jack_error("cannot unlink `%s' (%s)", fullpath, strerror(errno)); | |||||
} | |||||
} | |||||
closedir(dir); | |||||
/* now, delete the per-server subdirectory, itself */ | |||||
if (rmdir(dir_name)) { | |||||
jack_error("cannot remove `%s' (%s)", dir_name, strerror(errno)); | |||||
} | |||||
/* finally, delete the per-user subdirectory, if empty */ | |||||
if (rmdir(UserDir())) { | |||||
if (errno != ENOTEMPTY) { | |||||
jack_error("cannot remove `%s' (%s)", UserDir(), strerror(errno)); | |||||
} | |||||
} | |||||
struct dirent *dirent; | |||||
char dir_name[PATH_MAX + 1] = ""; | |||||
ServerDir(server_name, dir_name); | |||||
/* On termination, we remove all files that jackd creates so | |||||
* subsequent attempts to start jackd will not believe that an | |||||
* instance is already running. If the server crashes or is | |||||
* terminated with SIGKILL, this is not possible. So, cleanup | |||||
* is also attempted when jackd starts. | |||||
* | |||||
* There are several tricky issues. First, the previous JACK | |||||
* server may have run for a different user ID, so its files | |||||
* may be inaccessible. This is handled by using a separate | |||||
* JACK_TMP_DIR subdirectory for each user. Second, there may | |||||
* be other servers running with different names. Each gets | |||||
* its own subdirectory within the per-user directory. The | |||||
* current process has already registered as `server_name', so | |||||
* we know there is no other server actively using that name. | |||||
*/ | |||||
/* nothing to do if the server directory does not exist */ | |||||
if ((dir = opendir(dir_name)) == NULL) { | |||||
return; | |||||
} | |||||
/* unlink all the files in this directory, they are mine */ | |||||
while ((dirent = readdir(dir)) != NULL) { | |||||
char fullpath[PATH_MAX + 1]; | |||||
if ((strcmp(dirent->d_name, ".") == 0) || (strcmp (dirent->d_name, "..") == 0)) { | |||||
continue; | |||||
} | |||||
snprintf(fullpath, sizeof(fullpath), "%s/%s", dir_name, dirent->d_name); | |||||
if (unlink(fullpath)) { | |||||
jack_error("cannot unlink `%s' (%s)", fullpath, strerror(errno)); | |||||
} | |||||
} | |||||
closedir(dir); | |||||
/* now, delete the per-server subdirectory, itself */ | |||||
if (rmdir(dir_name)) { | |||||
jack_error("cannot remove `%s' (%s)", dir_name, strerror(errno)); | |||||
} | |||||
/* finally, delete the per-user subdirectory, if empty */ | |||||
if (rmdir(UserDir())) { | |||||
if (errno != ENOTEMPTY) { | |||||
jack_error("cannot remove `%s' (%s)", UserDir(), strerror(errno)); | |||||
} | |||||
} | |||||
} | } | ||||
int JackTools::GetTmpdir() | int JackTools::GetTmpdir() | ||||
{ | { | ||||
FILE* in; | |||||
size_t len; | |||||
char buf[PATH_MAX + 2]; /* allow tmpdir to live anywhere, plus newline, plus null */ | |||||
if ((in = popen("jackd -l", "r")) == NULL) { | |||||
return -1; | |||||
} | |||||
if (fgets(buf, sizeof(buf), in) == NULL) { | |||||
fclose(in); | |||||
return -1; | |||||
} | |||||
len = strlen(buf); | |||||
if (buf[len - 1] != '\n') { | |||||
/* didn't get a whole line */ | |||||
fclose(in); | |||||
return -1; | |||||
} | |||||
jack_tmpdir = (char *)malloc(len); | |||||
memcpy(jack_tmpdir, buf, len - 1); | |||||
jack_tmpdir[len - 1] = '\0'; | |||||
fclose(in); | |||||
return 0; | |||||
FILE* in; | |||||
size_t len; | |||||
char buf[PATH_MAX + 2]; /* allow tmpdir to live anywhere, plus newline, plus null */ | |||||
if ((in = popen("jackd -l", "r")) == NULL) { | |||||
return -1; | |||||
} | |||||
if (fgets(buf, sizeof(buf), in) == NULL) { | |||||
fclose(in); | |||||
return -1; | |||||
} | |||||
len = strlen(buf); | |||||
if (buf[len - 1] != '\n') { | |||||
/* didn't get a whole line */ | |||||
fclose(in); | |||||
return -1; | |||||
} | |||||
jack_tmpdir = (char *)malloc(len); | |||||
memcpy(jack_tmpdir, buf, len - 1); | |||||
jack_tmpdir[len - 1] = '\0'; | |||||
fclose(in); | |||||
return 0; | |||||
} | } | ||||
#endif | #endif | ||||
void JackTools::RewriteName(const char* name, char* new_name) | void JackTools::RewriteName(const char* name, char* new_name) | ||||
{ | { | ||||
size_t i; | |||||
for (i = 0; i < strlen(name); i++) { | |||||
if ((name[i] == '/') || (name[i] == '\\')) | |||||
new_name[i] = '_'; | |||||
else | |||||
new_name[i] = name[i]; | |||||
} | |||||
new_name[i] = '\0'; | |||||
size_t i; | |||||
for (i = 0; i < strlen(name); i++) { | |||||
if ((name[i] == '/') || (name[i] == '\\')) | |||||
new_name[i] = '_'; | |||||
else | |||||
new_name[i] = name[i]; | |||||
} | |||||
new_name[i] = '\0'; | |||||
} | } | ||||
@@ -1,18 +1,18 @@ | |||||
/* | /* | ||||
Copyright (C) 2001 Paul Davis | Copyright (C) 2001 Paul Davis | ||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
it under the terms of the GNU Lesser General Public License as published by | it under the terms of the GNU Lesser General Public License as published by | ||||
the Free Software Foundation; either version 2.1 of the License, or | the Free Software Foundation; either version 2.1 of the License, or | ||||
(at your option) any later version. | (at your option) any later version. | ||||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | ||||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
GNU Lesser General Public License for more details. | GNU Lesser General Public License for more details. | ||||
You should have received a copy of the GNU Lesser General Public License | You should have received a copy of the GNU Lesser General Public License | ||||
along with this program; if not, write to the Free Software | |||||
along with this program; if not, write to the Free Software | |||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||||
*/ | */ | ||||
@@ -21,33 +21,34 @@ | |||||
#define __JackTools__ | #define __JackTools__ | ||||
#ifdef WIN32 | #ifdef WIN32 | ||||
#include <windows.h> | |||||
#include <windows.h> | |||||
#else | #else | ||||
#include <sys/types.h> | |||||
#include <unistd.h> | |||||
#include <dirent.h> | |||||
#include <sys/types.h> | |||||
#include <unistd.h> | |||||
#include <dirent.h> | |||||
#endif | #endif | ||||
#ifdef __APPLE__ | #ifdef __APPLE__ | ||||
#include <sys/syslimits.h> | |||||
#include <sys/syslimits.h> | |||||
#endif | #endif | ||||
namespace Jack | namespace Jack | ||||
{ | { | ||||
struct JackTools { | |||||
static int GetPID(); | |||||
static int GetUID(); | |||||
static char* UserDir(); | |||||
static char* ServerDir(const char* server_name, char* server_dir); | |||||
static const char* DefaultServerName(); | |||||
static void CleanupFiles(const char* server_name); | |||||
static int GetTmpdir(); | |||||
static void RewriteName(const char* name, char* new_name); | |||||
}; | |||||
struct JackTools | |||||
{ | |||||
static int GetPID(); | |||||
static int GetUID(); | |||||
static char* UserDir(); | |||||
static char* ServerDir(const char* server_name, char* server_dir); | |||||
static const char* DefaultServerName(); | |||||
static void CleanupFiles(const char* server_name); | |||||
static int GetTmpdir(); | |||||
static void RewriteName(const char* name, char* new_name); | |||||
}; | |||||
} | } | ||||
#endif | #endif |
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2004-2008 Grame | Copyright (C) 2004-2008 Grame | ||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
@@ -21,7 +21,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||||
#include "JackTransportEngine.h" | #include "JackTransportEngine.h" | ||||
#include "JackClientControl.h" | #include "JackClientControl.h" | ||||
#include "JackError.h" | #include "JackError.h" | ||||
#include "JackTime.h" | |||||
#include "JackTime.h" | |||||
#include <assert.h> | #include <assert.h> | ||||
#include <stdlib.h> | #include <stdlib.h> | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2004-2008 Grame | Copyright (C) 2004-2008 Grame | ||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
@@ -37,17 +37,17 @@ typedef enum { | |||||
/*! | /*! | ||||
\brief The client transport structure. | \brief The client transport structure. | ||||
We have: | We have: | ||||
- a "current" position | - a "current" position | ||||
- a "pending" position prepared by the server at each cycle | - a "pending" position prepared by the server at each cycle | ||||
- a "request" position wanted by a client | - a "request" position wanted by a client | ||||
At the beginning of a cycle the server needs to select a new current position. When a request and a pending position are available, | At the beginning of a cycle the server needs to select a new current position. When a request and a pending position are available, | ||||
the resquest takes precedence on the pending one. The server atomically switches to the new position. | |||||
the resquest takes precedence on the pending one. The server atomically switches to the new position. | |||||
The current position can be read by clients. | The current position can be read by clients. | ||||
We use a JackAtomicArrayState pattern that allows to manage several "next" states independantly. | We use a JackAtomicArrayState pattern that allows to manage several "next" states independantly. | ||||
*/ | */ | ||||
@@ -1,18 +1,18 @@ | |||||
/* | /* | ||||
Copyright (C) 2001 Paul Davis | Copyright (C) 2001 Paul Davis | ||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
it under the terms of the GNU Lesser General Public License as published by | it under the terms of the GNU Lesser General Public License as published by | ||||
the Free Software Foundation; either version 2.1 of the License, or | the Free Software Foundation; either version 2.1 of the License, or | ||||
(at your option) any later version. | (at your option) any later version. | ||||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | ||||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
GNU Lesser General Public License for more details. | GNU Lesser General Public License for more details. | ||||
You should have received a copy of the GNU Lesser General Public License | You should have received a copy of the GNU Lesser General Public License | ||||
along with this program; if not, write to the Free Software | |||||
along with this program; if not, write to the Free Software | |||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||||
$Id: JackTypes.h,v 1.2.2.1 2006/06/20 14:44:00 letz Exp $ | $Id: JackTypes.h,v 1.2.2.1 2006/06/20 14:44:00 letz Exp $ | ||||
@@ -32,9 +32,9 @@ typedef signed long SInt32; | |||||
#ifdef WIN32 | #ifdef WIN32 | ||||
#include <windows.h> | #include <windows.h> | ||||
typedef ULONGLONG UInt64; | |||||
typedef ULONGLONG UInt64; | |||||
typedef unsigned short uint16_t; | typedef unsigned short uint16_t; | ||||
#else | |||||
#else | |||||
#include <stdint.h> | #include <stdint.h> | ||||
typedef unsigned long long UInt64; | typedef unsigned long long UInt64; | ||||
#endif | #endif | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2001 Paul Davis | |||||
Copyright (C) 2004-2008 Grame | Copyright (C) 2004-2008 Grame | ||||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
@@ -62,34 +62,34 @@ static void silent_jack_error_callback(const char *desc) | |||||
static void copyright(FILE* file) | static void copyright(FILE* file) | ||||
{ | { | ||||
fprintf(file, "jackdmp " VERSION "\n" | fprintf(file, "jackdmp " VERSION "\n" | ||||
"Copyright 2001-2005 Paul Davis and others.\n" | |||||
"Copyright 2004-2008 Grame.\n" | |||||
"jackdmp comes with ABSOLUTELY NO WARRANTY\n" | |||||
"This is free software, and you are welcome to redistribute it\n" | |||||
"under certain conditions; see the file COPYING for details\n"); | |||||
"Copyright 2001-2005 Paul Davis and others.\n" | |||||
"Copyright 2004-2008 Grame.\n" | |||||
"jackdmp comes with ABSOLUTELY NO WARRANTY\n" | |||||
"This is free software, and you are welcome to redistribute it\n" | |||||
"under certain conditions; see the file COPYING for details\n"); | |||||
} | } | ||||
static void usage(FILE* file) | static void usage(FILE* file) | ||||
{ | { | ||||
copyright(file); | copyright(file); | ||||
fprintf(file, "\n" | fprintf(file, "\n" | ||||
"usage: jackdmp [ --realtime OR -R [ --realtime-priority OR -P priority ] ]\n" | |||||
" [ --name OR -n server-name ]\n" | |||||
// " [ --no-mlock OR -m ]\n" | |||||
// " [ --unlock OR -u ]\n" | |||||
" [ --timeout OR -t client-timeout-in-msecs ]\n" | |||||
" [ --loopback OR -L loopback-port-number ]\n" | |||||
// " [ --port-max OR -p maximum-number-of-ports]\n" | |||||
" [ --verbose OR -v ]\n" | |||||
" [ --replace-registry OR -r ]\n" | |||||
" [ --silent OR -s ]\n" | |||||
" [ --sync OR -S ]\n" | |||||
" [ --temporary OR -T ]\n" | |||||
" [ --version OR -V ]\n" | |||||
" -d driver [ ... driver args ... ]\n" | |||||
" where driver can be `alsa', `coreaudio', 'portaudio' or `dummy'\n" | |||||
" jackdmp -d driver --help\n" | |||||
" to display options for each driver\n\n"); | |||||
"usage: jackdmp [ --realtime OR -R [ --realtime-priority OR -P priority ] ]\n" | |||||
" [ --name OR -n server-name ]\n" | |||||
// " [ --no-mlock OR -m ]\n" | |||||
// " [ --unlock OR -u ]\n" | |||||
" [ --timeout OR -t client-timeout-in-msecs ]\n" | |||||
" [ --loopback OR -L loopback-port-number ]\n" | |||||
// " [ --port-max OR -p maximum-number-of-ports]\n" | |||||
" [ --verbose OR -v ]\n" | |||||
" [ --replace-registry OR -r ]\n" | |||||
" [ --silent OR -s ]\n" | |||||
" [ --sync OR -S ]\n" | |||||
" [ --temporary OR -T ]\n" | |||||
" [ --version OR -V ]\n" | |||||
" -d driver [ ... driver args ... ]\n" | |||||
" where driver can be `alsa', `coreaudio', 'portaudio' or `dummy'\n" | |||||
" jackdmp -d driver --help\n" | |||||
" to display options for each driver\n\n"); | |||||
} | } | ||||
@@ -148,7 +148,8 @@ int main(int argc, char* argv[]) | |||||
jack_driver_desc_t* driver_desc; | jack_driver_desc_t* driver_desc; | ||||
const char *options = "-ad:P:uvrshVRL:STFl:t:mn:p:"; | const char *options = "-ad:P:uvrshVRL:STFl:t:mn:p:"; | ||||
struct option long_options[] = { | struct option long_options[] = { | ||||
{ "driver", 1, 0, 'd' }, | |||||
{ "driver", 1, 0, 'd' | |||||
}, | |||||
{ "verbose", 0, 0, 'v' }, | { "verbose", 0, 0, 'v' }, | ||||
{ "help", 0, 0, 'h' }, | { "help", 0, 0, 'h' }, | ||||
{ "port-max", 1, 0, 'p' }, | { "port-max", 1, 0, 'p' }, | ||||
@@ -156,7 +157,7 @@ int main(int argc, char* argv[]) | |||||
{ "name", 0, 0, 'n' }, | { "name", 0, 0, 'n' }, | ||||
{ "unlock", 0, 0, 'u' }, | { "unlock", 0, 0, 'u' }, | ||||
{ "realtime", 0, 0, 'R' }, | { "realtime", 0, 0, 'R' }, | ||||
{ "replace-registry", 0, 0, 'r' }, | |||||
{ "replace-registry", 0, 0, 'r' }, | |||||
{ "loopback", 0, 0, 'L' }, | { "loopback", 0, 0, 'L' }, | ||||
{ "realtime-priority", 1, 0, 'P' }, | { "realtime-priority", 1, 0, 'P' }, | ||||
{ "timeout", 1, 0, 't' }, | { "timeout", 1, 0, 't' }, | ||||
@@ -174,7 +175,7 @@ int main(int argc, char* argv[]) | |||||
JSList* driver_params; | JSList* driver_params; | ||||
int driver_nargs = 1; | int driver_nargs = 1; | ||||
int show_version = 0; | int show_version = 0; | ||||
int replace_registry = 0; | |||||
int replace_registry = 0; | |||||
int sync = 0; | int sync = 0; | ||||
int rc, i; | int rc, i; | ||||
@@ -216,11 +217,11 @@ int main(int argc, char* argv[]) | |||||
case 'P': | case 'P': | ||||
realtime_priority = atoi(optarg); | realtime_priority = atoi(optarg); | ||||
break; | break; | ||||
case 'r': | |||||
replace_registry = 1; | |||||
break; | |||||
case 'r': | |||||
replace_registry = 1; | |||||
break; | |||||
case 'R': | case 'R': | ||||
realtime = 1; | realtime = 1; | ||||
break; | break; | ||||
@@ -290,7 +291,7 @@ int main(int argc, char* argv[]) | |||||
if (driver_nargs == 0) { | if (driver_nargs == 0) { | ||||
fprintf(stderr, "No driver specified ... hmm. JACK won't do" | fprintf(stderr, "No driver specified ... hmm. JACK won't do" | ||||
" anything when run like this.\n"); | |||||
" anything when run like this.\n"); | |||||
return -1; | return -1; | ||||
} | } | ||||
@@ -302,7 +303,7 @@ int main(int argc, char* argv[]) | |||||
} | } | ||||
if (jack_parse_driver_params(driver_desc, driver_nargs, | if (jack_parse_driver_params(driver_desc, driver_nargs, | ||||
driver_args, &driver_params)) { | |||||
driver_args, &driver_params)) { | |||||
exit(0); | exit(0); | ||||
} | } | ||||
@@ -360,16 +361,16 @@ int main(int argc, char* argv[]) | |||||
} | } | ||||
#ifdef __APPLE__ | #ifdef __APPLE__ | ||||
CFStringRef ref = CFStringCreateWithCString(NULL, server_name, kCFStringEncodingMacRoman); | |||||
CFStringRef ref = CFStringCreateWithCString(NULL, server_name, kCFStringEncodingMacRoman); | |||||
// Send notification to be used in the JackRouter plugin | // Send notification to be used in the JackRouter plugin | ||||
CFNotificationCenterPostNotificationWithOptions(CFNotificationCenterGetDistributedCenter(), | CFNotificationCenterPostNotificationWithOptions(CFNotificationCenterGetDistributedCenter(), | ||||
CFSTR("com.grame.jackserver.start"), | |||||
ref, | |||||
NULL, | |||||
kCFNotificationDeliverImmediately | kCFNotificationPostToAllSessions); | |||||
CFRelease(ref); | |||||
CFSTR("com.grame.jackserver.start"), | |||||
ref, | |||||
NULL, | |||||
kCFNotificationDeliverImmediately | kCFNotificationPostToAllSessions); | |||||
CFRelease(ref); | |||||
#endif | #endif | ||||
// install a do-nothing handler because otherwise pthreads | // install a do-nothing handler because otherwise pthreads | ||||
// behaviour is undefined when we enter sigwait. | // behaviour is undefined when we enter sigwait. | ||||
@@ -410,22 +411,22 @@ int main(int argc, char* argv[]) | |||||
// bugs that cause segfaults etc. during shutdown. | // bugs that cause segfaults etc. during shutdown. | ||||
sigprocmask(SIG_UNBLOCK, &signals, 0); | sigprocmask(SIG_UNBLOCK, &signals, 0); | ||||
} | } | ||||
JackStop(); | |||||
JackStop(); | |||||
jack_cleanup_shm(); | jack_cleanup_shm(); | ||||
JackTools::CleanupFiles(server_name); | JackTools::CleanupFiles(server_name); | ||||
jack_unregister_server(server_name); | jack_unregister_server(server_name); | ||||
#ifdef __APPLE__ | #ifdef __APPLE__ | ||||
CFStringRef ref1 = CFStringCreateWithCString(NULL, server_name, kCFStringEncodingMacRoman); | |||||
CFStringRef ref1 = CFStringCreateWithCString(NULL, server_name, kCFStringEncodingMacRoman); | |||||
// Send notification to be used in the JackRouter plugin | // Send notification to be used in the JackRouter plugin | ||||
CFNotificationCenterPostNotificationWithOptions(CFNotificationCenterGetDistributedCenter(), | CFNotificationCenterPostNotificationWithOptions(CFNotificationCenterGetDistributedCenter(), | ||||
CFSTR("com.grame.jackserver.stop"), | |||||
ref1, | |||||
NULL, | |||||
kCFNotificationDeliverImmediately | kCFNotificationPostToAllSessions); | |||||
CFRelease(ref1); | |||||
CFSTR("com.grame.jackserver.stop"), | |||||
ref1, | |||||
NULL, | |||||
kCFNotificationDeliverImmediately | kCFNotificationPostToAllSessions); | |||||
CFRelease(ref1); | |||||
#endif | #endif | ||||
return 1; | return 1; | ||||