summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2013-09-24 22:15:23 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2013-09-24 22:15:23 -0400
commita4580ec67d173190edc7f669fc927eb920be7a36 (patch)
tree1ace78d1ba7f9424551a842b71d81ba83c70adcb
parentc3d0978e0a2d4f6148c7b332b6318c218c3aea67 (diff)
downloadjack1-a4580ec67d173190edc7f669fc927eb920be7a36.tar.gz
first pass at working UUID-based clients and ports. many JACK clients work correctly without recompilation
-rw-r--r--include/engine.h7
-rw-r--r--include/internal.h17
-rw-r--r--include/port.h6
m---------jack0
-rw-r--r--jackd/Makefile.am2
-rw-r--r--jackd/clientengine.c138
-rw-r--r--jackd/clientengine.h4
-rw-r--r--jackd/engine.c96
-rw-r--r--jackd/transengine.c14
-rw-r--r--jackd/transengine.h8
-rw-r--r--libjack/Makefile.am3
-rw-r--r--libjack/client.c104
-rw-r--r--libjack/intclient.c54
-rw-r--r--libjack/port.c13
-rw-r--r--libjack/transclient.c6
m---------tools0
16 files changed, 251 insertions, 221 deletions
diff --git a/include/engine.h b/include/engine.h
index dd761c7..eac8511 100644
--- a/include/engine.h
+++ b/include/engine.h
@@ -52,7 +52,7 @@ typedef struct _jack_port_buffer_list {
} jack_port_buffer_list_t;
typedef struct _jack_reserved_name {
- jack_client_id_t uuid;
+ jack_uuid_t uuid;
char name[JACK_CLIENT_NAME_SIZE];
} jack_reserved_name_t;
@@ -108,7 +108,6 @@ struct _jack_engine {
int fds[2];
int cleanup_fifo[2];
- jack_client_id_t next_client_id;
size_t pfd_size;
size_t pfd_max;
struct pollfd *pfd;
@@ -124,7 +123,7 @@ struct _jack_engine {
int rtpriority;
volatile char freewheeling;
volatile char stop_freewheeling;
- jack_client_id_t fwclient;
+ jack_uuid_t fwclient;
pthread_t freewheel_thread;
char verbose;
char do_munlock;
@@ -205,7 +204,7 @@ int jack_get_fifo_fd (jack_engine_t *engine,
extern jack_timer_type_t clock_source;
extern jack_client_internal_t *
-jack_client_internal_by_id (jack_engine_t *engine, jack_client_id_t id);
+jack_client_internal_by_id (jack_engine_t *engine, jack_uuid_t id);
#define jack_rdlock_graph(e) { DEBUG ("acquiring graph read lock"); if (pthread_rwlock_rdlock (&e->client_lock)) abort(); }
#define jack_lock_graph(e) { DEBUG ("acquiring graph write lock"); if (pthread_rwlock_wrlock (&e->client_lock)) abort(); }
diff --git a/include/internal.h b/include/internal.h
index 1595a36..bd9b3c8 100644
--- a/include/internal.h
+++ b/include/internal.h
@@ -257,8 +257,7 @@ typedef enum {
/* JACK client shared memory data structure. */
typedef volatile struct {
- volatile jack_client_id_t id; /* w: engine r: engine and client */
- volatile jack_client_id_t uid; /* w: engine r: engine and client */
+ jack_uuid_t uuid; /* w: engine r: engine and client */
volatile jack_client_state_t state; /* w: engine and client r: engine */
volatile char name[JACK_CLIENT_NAME_SIZE];
volatile char session_command[JACK_PORT_NAME_SIZE];
@@ -311,7 +310,7 @@ typedef struct {
int32_t load;
ClientType type;
jack_options_t options;
- jack_client_id_t uuid;
+ jack_uuid_t uuid;
char name[JACK_CLIENT_NAME_SIZE];
char object_path[PATH_MAX+1];
@@ -350,7 +349,7 @@ typedef struct {
} POST_PACKED_STRUCTURE jack_client_connect_result_t;
typedef struct {
- jack_client_id_t client_id;
+ jack_uuid_t client_id;
} POST_PACKED_STRUCTURE jack_client_connect_ack_request_t;
typedef struct {
@@ -401,7 +400,7 @@ struct _jack_request {
uint32_t flags;
jack_shmsize_t buffer_size;
jack_port_id_t port_id;
- jack_client_id_t client_id;
+ jack_uuid_t client_id;
} POST_PACKED_STRUCTURE port_info;
struct {
char source_port[JACK_PORT_NAME_SIZE];
@@ -426,22 +425,22 @@ struct _jack_request {
*/
} POST_PACKED_STRUCTURE port_connections;
struct {
- jack_client_id_t client_id;
+ jack_uuid_t client_id;
int32_t conditional;
} POST_PACKED_STRUCTURE timebase;
struct {
char name[JACK_CLIENT_NAME_SIZE];
- jack_client_id_t uuid;
+ jack_uuid_t uuid;
} POST_PACKED_STRUCTURE reservename;
struct {
//jack_options_t options;
uint32_t options;
- jack_client_id_t id;
+ jack_uuid_t uuid;
char name[JACK_CLIENT_NAME_SIZE];
char path[PATH_MAX+1];
char init[JACK_LOAD_INIT_LIMIT];
} POST_PACKED_STRUCTURE intclient;
- jack_client_id_t client_id;
+ jack_uuid_t client_id;
jack_nframes_t nframes;
jack_time_t timeout;
pid_t cap_pid;
diff --git a/include/port.h b/include/port.h
index 8553ec3..840d9ed 100644
--- a/include/port.h
+++ b/include/port.h
@@ -45,7 +45,6 @@
/* these should probably go somewhere else, but not in <jack/types.h> */
#define JACK_CLIENT_NAME_SIZE 33
-typedef uint32_t jack_client_id_t;
/* JACK shared memory segments are limited to MAX_INT32, they can be
* shared between 32-bit and 64-bit clients.
@@ -113,11 +112,12 @@ typedef struct _jack_port_shared {
jack_port_type_id_t ptype_id; /* index into port type array */
jack_shmsize_t offset; /* buffer offset in shm segment */
jack_port_id_t id; /* index into engine port array */
- uint32_t flags;
+ jack_uuid_t uuid;
+ uint32_t flags;
char name[JACK_CLIENT_NAME_SIZE+JACK_PORT_NAME_SIZE];
char alias1[JACK_CLIENT_NAME_SIZE+JACK_PORT_NAME_SIZE];
char alias2[JACK_CLIENT_NAME_SIZE+JACK_PORT_NAME_SIZE];
- jack_client_id_t client_id; /* who owns me */
+ jack_uuid_t client_id; /* who owns me */
volatile jack_nframes_t latency;
volatile jack_nframes_t total_latency;
diff --git a/jack b/jack
-Subproject a43a3276b40a08a338ef08a6491df7e116e8c9c
+Subproject 2d8115ffacbfbcfb303f4c8e437eeb84346cb80
diff --git a/jackd/Makefile.am b/jackd/Makefile.am
index e951462..94f521e 100644
--- a/jackd/Makefile.am
+++ b/jackd/Makefile.am
@@ -50,7 +50,7 @@ libjackserver_la_SOURCES = engine.c clientengine.c transengine.c controlapi.c \
../libjack/messagebuffer.c ../libjack/pool.c ../libjack/port.c \
../libjack/midiport.c ../libjack/ringbuffer.c ../libjack/shm.c \
../libjack/thread.c ../libjack/time.c ../libjack/transclient.c \
- ../libjack/unlock.c
+ ../libjack/unlock.c ../libjack/uuid.c
libjackserver_la_LIBADD = simd.lo @OS_LDFLAGS@
libjackserver_la_LDFLAGS = -export-dynamic -version-info @JACK_SO_VERSION@
diff --git a/jackd/clientengine.c b/jackd/clientengine.c
index 03147b6..45c9f4d 100644
--- a/jackd/clientengine.c
+++ b/jackd/clientengine.c
@@ -28,6 +28,7 @@
#include <unistd.h>
#include <string.h>
#include <signal.h>
+#include <uuid/uuid.h>
#include "internal.h"
#include "engine.h"
@@ -40,6 +41,8 @@
#include "clientengine.h"
#include "transengine.h"
+#include <jack/uuid.h>
+
#include "libjack/local.h"
static void
@@ -162,7 +165,8 @@ void
jack_remove_client (jack_engine_t *engine, jack_client_internal_t *client)
{
JSList *node;
- jack_client_id_t finalizer=0;
+ jack_uuid_t finalizer;
+ jack_uuid_clear (finalizer);
/* caller must write-hold the client lock */
@@ -203,10 +207,8 @@ jack_remove_client (jack_engine_t *engine, jack_client_internal_t *client)
}
for (node = engine->clients; node; node = jack_slist_next (node)) {
- if (((jack_client_internal_t *) node->data)->control->id
- == client->control->id) {
- engine->clients =
- jack_slist_remove_link (engine->clients, node);
+ if (jack_uuid_compare (((jack_client_internal_t *) node->data)->control->uuid, client->control->uuid) == 0) {
+ engine->clients = jack_slist_remove_link (engine->clients, node);
jack_slist_free_1 (node);
break;
}
@@ -331,7 +333,7 @@ jack_remove_clients (jack_engine_t* engine, int* exit_freewheeling_when_done)
if (client->error) {
- if (engine->freewheeling && client->control->id == engine->fwclient) {
+ if (engine->freewheeling && jack_uuid_compare (client->control->uuid, engine->fwclient) == 0) {
VERBOSE (engine, "freewheeling client has errors");
*exit_freewheeling_when_done = 1;
}
@@ -404,11 +406,13 @@ jack_client_by_name (jack_engine_t *engine, const char *name)
return client;
}
-static jack_client_id_t
-jack_client_id_by_name (jack_engine_t *engine, const char *name)
+static int
+jack_client_id_by_name (jack_engine_t *engine, const char *name, jack_uuid_t id)
{
- jack_client_id_t id = 0; /* NULL client ID */
JSList *node;
+ int ret = -1;
+
+ jack_uuid_clear (id);
jack_rdlock_graph (engine);
@@ -418,17 +422,18 @@ jack_client_id_by_name (jack_engine_t *engine, const char *name)
name) == 0) {
jack_client_internal_t *client =
(jack_client_internal_t *) node->data;
- id = client->control->id;
+ jack_uuid_copy (id, client->control->uuid);
+ ret = 0;
break;
}
}
jack_unlock_graph (engine);
- return id;
+ return ret;
}
jack_client_internal_t *
-jack_client_internal_by_id (jack_engine_t *engine, jack_client_id_t id)
+jack_client_internal_by_id (jack_engine_t *engine, jack_uuid_t id)
{
jack_client_internal_t *client = NULL;
JSList *node;
@@ -437,8 +442,7 @@ jack_client_internal_by_id (jack_engine_t *engine, jack_client_id_t id)
for (node = engine->clients; node; node = jack_slist_next (node)) {
- if (((jack_client_internal_t *) node->data)->control->id
- == id) {
+ if (jack_uuid_compare (((jack_client_internal_t *) node->data)->control->uuid, id) == 0) {
client = (jack_client_internal_t *) node->data;
break;
}
@@ -453,8 +457,9 @@ jack_client_name_reserved( jack_engine_t *engine, const char *name )
JSList *node;
for (node = engine->reserved_client_names; node; node = jack_slist_next (node)) {
jack_reserved_name_t *reservation = (jack_reserved_name_t *) node->data;
- if( !strcmp( reservation->name, name ) )
+ if (!strcmp (reservation->name, name)) {
return 1;
+ }
}
return 0;
}
@@ -532,8 +537,7 @@ jack_client_name_invalid (jack_engine_t *engine, char *name,
/* Set up the engine's client internal and control structures for both
* internal and external clients. */
static jack_client_internal_t *
-jack_setup_client_control (jack_engine_t *engine, int fd,
- ClientType type, const char *name, jack_client_id_t uuid)
+jack_setup_client_control (jack_engine_t *engine, int fd, ClientType type, const char *name, jack_uuid_t uuid)
{
jack_client_internal_t *client;
@@ -582,8 +586,13 @@ jack_setup_client_control (jack_engine_t *engine, int fd,
client->control->active = 0;
client->control->dead = FALSE;
client->control->timed_out = 0;
- client->control->id = engine->next_client_id++;
- client->control->uid = uuid;
+
+ if (jack_uuid_empty (uuid)) {
+ uuid_generate (client->control->uuid);
+ } else {
+ jack_uuid_copy (client->control->uuid, uuid);
+ }
+
strcpy ((char *) client->control->name, name);
client->subgraph_start_fd = -1;
client->subgraph_wait_fd = -1;
@@ -636,38 +645,45 @@ jack_setup_client_control (jack_engine_t *engine, int fd,
}
static void
-jack_ensure_uuid_unique (jack_engine_t *engine, jack_client_id_t uuid)
+jack_ensure_uuid_unique (jack_engine_t *engine, jack_uuid_t uuid)
{
JSList *node;
+ jack_uuid_t jj;
+
+ if (jack_uuid_empty (uuid)) {
+ return;
+ }
jack_lock_graph (engine);
for (node=engine->clients; node; node=jack_slist_next (node)) {
jack_client_internal_t *client = (jack_client_internal_t *) node->data;
- if (client->control->uid == uuid)
- client->control->uid = 0;
+ if (jack_uuid_compare (client->control->uuid, uuid) == 0) {
+ jack_uuid_clear (uuid);
+ }
}
jack_unlock_graph (engine);
}
/* set up all types of clients */
static jack_client_internal_t *
-setup_client (jack_engine_t *engine, ClientType type, char *name, jack_client_id_t uuid,
+setup_client (jack_engine_t *engine, ClientType type, char *name,
+ jack_uuid_t uuid,
jack_options_t options, jack_status_t *status, int client_fd,
const char *object_path, const char *object_data)
{
/* called with the request_lock */
jack_client_internal_t *client;
+ char bufx[64];
/* validate client name, generate a unique one if appropriate */
if (jack_client_name_invalid (engine, name, options, status))
return NULL;
- if (uuid != 0)
- jack_ensure_uuid_unique (engine, uuid);
+ jack_ensure_uuid_unique (engine, uuid);
/* create a client struct for this name */
if ((client = jack_setup_client_control (engine, client_fd,
- type, name, uuid )) == NULL) {
+ type, name, uuid)) == NULL) {
*status |= (JackFailure|JackInitFailure);
jack_error ("cannot create new client object");
return NULL;
@@ -684,9 +700,11 @@ setup_client (jack_engine_t *engine, ClientType type, char *name, jack_client_id
}
}
+ jack_uuid_unparse (client->control->uuid, bufx);
+
VERBOSE (engine, "new client: %s, id = %" PRIu32
" type %d @ %p fd = %d",
- client->control->name, client->control->id,
+ client->control->name, bufx,
type, client->control, client_fd);
if (jack_client_is_internal(client)) {
@@ -757,11 +775,16 @@ jack_create_driver_client (jack_engine_t *engine, char *name)
jack_client_connect_request_t req;
jack_status_t status;
jack_client_internal_t *client;
+ jack_uuid_t empty_uuid;
+
+ VALGRIND_MEMSET(&empty_uuid, 0, sizeof(empty_uuid));
snprintf (req.name, sizeof (req.name), "%s", name);
+ jack_uuid_clear (empty_uuid);
+
pthread_mutex_lock (&engine->request_lock);
- client = setup_client (engine, ClientDriver, name, 0, JackUseExactName,
+ client = setup_client (engine, ClientDriver, name, empty_uuid, JackUseExactName,
&status, -1, NULL, NULL);
pthread_mutex_unlock (&engine->request_lock);
@@ -769,7 +792,7 @@ jack_create_driver_client (jack_engine_t *engine, char *name)
}
static jack_status_t
-handle_unload_client (jack_engine_t *engine, jack_client_id_t id)
+handle_unload_client (jack_engine_t *engine, jack_uuid_t id)
{
/* called *without* the request_lock */
jack_client_internal_t *client;
@@ -790,16 +813,16 @@ handle_unload_client (jack_engine_t *engine, jack_client_id_t id)
}
static char *
-jack_get_reserved_name( jack_engine_t *engine, jack_client_id_t uuid )
+jack_get_reserved_name (jack_engine_t *engine, jack_uuid_t uuid)
{
JSList *node;
for (node = engine->reserved_client_names; node; node = jack_slist_next (node)) {
jack_reserved_name_t *reservation = (jack_reserved_name_t *) node->data;
- if( reservation->uuid== uuid ) {
- char *retval = strdup( reservation->name );
- free( reservation );
+ if (jack_uuid_compare (reservation->uuid, uuid) != 0) {
+ char *retval = strdup (reservation->name);
+ free (reservation);
engine->reserved_client_names =
- jack_slist_remove( engine->reserved_client_names, reservation );
+ jack_slist_remove (engine->reserved_client_names, reservation);
return retval;
}
}
@@ -816,6 +839,8 @@ jack_client_create (jack_engine_t *engine, int client_fd)
res.status = 0;
+ VALGRIND_MEMSET(&res, 0, sizeof (res));
+
nbytes = read (client_fd, &req, sizeof (req));
if (nbytes == 0) { /* EOF? */
@@ -841,9 +866,9 @@ jack_client_create (jack_engine_t *engine, int client_fd)
if (!req.load) { /* internal client close? */
int rc = -1;
- jack_client_id_t id;
+ jack_uuid_t id;
- if ((id = jack_client_id_by_name(engine, req.name))) {
+ if (jack_client_id_by_name(engine, req.name, id) == 0) {
rc = handle_unload_client (engine, id);
}
@@ -852,13 +877,14 @@ jack_client_create (jack_engine_t *engine, int client_fd)
}
pthread_mutex_lock (&engine->request_lock);
- if( req.uuid ) {
- char *res_name = jack_get_reserved_name( engine, req.uuid );
- if( res_name ) {
- snprintf( req.name, sizeof(req.name), "%s", res_name );
- free(res_name);
+ if (!jack_uuid_empty (req.uuid)) {
+ char *res_name = jack_get_reserved_name (engine, req.uuid);
+ if (res_name) {
+ snprintf (req.name, sizeof(req.name), "%s", res_name);
+ free (res_name);
}
}
+
client = setup_client (engine, req.type, req.name, req.uuid,
req.options, &res.status, client_fd,
req.object_path, req.object_data);
@@ -912,7 +938,7 @@ jack_client_create (jack_engine_t *engine, int client_fd)
}
int
-jack_client_activate (jack_engine_t *engine, jack_client_id_t id)
+jack_client_activate (jack_engine_t *engine, jack_uuid_t id)
{
jack_client_internal_t *client;
JSList *node;
@@ -920,6 +946,8 @@ jack_client_activate (jack_engine_t *engine, jack_client_id_t id)
int i;
jack_event_t event;
+ VALGRIND_MEMSET(&event, 0, sizeof(event));
+
jack_lock_graph (engine);
if ((client = jack_client_internal_by_id (engine, id)))
@@ -963,7 +991,7 @@ jack_client_activate (jack_engine_t *engine, jack_client_id_t id)
}
int
-jack_client_deactivate (jack_engine_t *engine, jack_client_id_t id)
+jack_client_deactivate (jack_engine_t *engine, jack_uuid_t id)
{
JSList *node;
int ret = -1;
@@ -974,8 +1002,8 @@ jack_client_deactivate (jack_engine_t *engine, jack_client_id_t id)
jack_client_internal_t *client =
(jack_client_internal_t *) node->data;
-
- if (client->control->id == id) {
+
+ if (jack_uuid_compare (client->control->uuid, id) == 0) {
JSList *portnode;
jack_port_internal_t *port;
@@ -1061,7 +1089,7 @@ jack_intclient_handle_request (jack_engine_t *engine, jack_request_t *req)
req->status = 0;
if ((client = jack_client_by_name (engine, req->x.intclient.name))) {
- req->x.intclient.id = client->control->id;
+ jack_uuid_copy (req->x.intclient.uuid, client->control->uuid);
} else {
req->status |= (JackNoSuchClient|JackFailure);
}
@@ -1073,22 +1101,26 @@ jack_intclient_load_request (jack_engine_t *engine, jack_request_t *req)
/* called with the request_lock */
jack_client_internal_t *client;
jack_status_t status = 0;
+ jack_uuid_t empty_uuid;
VERBOSE (engine, "load internal client %s from %s, init `%s', "
"options: 0x%x", req->x.intclient.name,
req->x.intclient.path, req->x.intclient.init,
req->x.intclient.options);
- client = setup_client (engine, ClientInternal, req->x.intclient.name, 0,
+ VALGRIND_MEMSET (&empty_uuid, 0, sizeof (empty_uuid));
+ jack_uuid_clear (empty_uuid);
+
+ client = setup_client (engine, ClientInternal, req->x.intclient.name, empty_uuid,
req->x.intclient.options, &status, -1,
req->x.intclient.path, req->x.intclient.init);
if (client == NULL) {
status |= JackFailure; /* just making sure */
- req->x.intclient.id = 0;
+ jack_uuid_clear (req->x.intclient.uuid);
VERBOSE (engine, "load failed, status = 0x%x", status);
} else {
- req->x.intclient.id = client->control->id;
+ jack_uuid_copy (req->x.intclient.uuid, client->control->uuid);
}
req->status = status;
@@ -1101,7 +1133,7 @@ jack_intclient_name_request (jack_engine_t *engine, jack_request_t *req)
jack_rdlock_graph (engine);
if ((client = jack_client_internal_by_id (engine,
- req->x.intclient.id))) {
+ req->x.intclient.uuid))) {
strncpy ((char *) req->x.intclient.name,
(char *) client->control->name,
sizeof (req->x.intclient.name));
@@ -1118,10 +1150,10 @@ jack_intclient_unload_request (jack_engine_t *engine, jack_request_t *req)
/* Called with the request_lock, but we need to call
* handle_unload_client() *without* it. */
- if (req->x.intclient.id) {
+ if (!jack_uuid_empty (req->x.intclient.uuid)) {
+ /* non-empty UUID */
pthread_mutex_unlock (&engine->request_lock);
- req->status =
- handle_unload_client (engine, req->x.intclient.id);
+ req->status = handle_unload_client (engine, req->x.intclient.uuid);
pthread_mutex_lock (&engine->request_lock);
} else {
VERBOSE (engine, "invalid unload request");
diff --git a/jackd/clientengine.h b/jackd/clientengine.h
index bcda149..a3d6371 100644
--- a/jackd/clientengine.h
+++ b/jackd/clientengine.h
@@ -42,8 +42,8 @@ jack_client_state_name (jack_client_internal_t *client)
#define JACK_ERROR_WITH_SOCKETS 10000000
-int jack_client_activate (jack_engine_t *engine, jack_client_id_t id);
-int jack_client_deactivate (jack_engine_t *engine, jack_client_id_t id);
+int jack_client_activate (jack_engine_t *engine, jack_uuid_t id);
+int jack_client_deactivate (jack_engine_t *engine, jack_uuid_t id);
int jack_client_create (jack_engine_t *engine, int client_fd);
void jack_client_delete (jack_engine_t *engine,
jack_client_internal_t *client);
diff --git a/jackd/engine.c b/jackd/engine.c
index 2023567..8c4029b 100644
--- a/jackd/engine.c
+++ b/jackd/engine.c
@@ -40,6 +40,7 @@
#include <limits.h>
#include <jack/thread.h>
+#include <jack/uuid.h>
#include "internal.h"
#include "engine.h"
@@ -105,14 +106,14 @@ static int jack_port_disconnect_internal (jack_engine_t *engine,
jack_port_internal_t *src,
jack_port_internal_t *dst);
static int jack_send_connection_notification (jack_engine_t *,
- jack_client_id_t,
+ jack_uuid_t,
jack_port_id_t,
jack_port_id_t, int);
static void jack_deliver_event_to_all (jack_engine_t *engine,
jack_event_t *event);
static void jack_notify_all_port_interested_clients (jack_engine_t *engine,
- jack_client_id_t exclude_src_id,
- jack_client_id_t exclude_dst_id,
+ jack_uuid_t exclude_src_id,
+ jack_uuid_t exclude_dst_id,
jack_port_id_t a,
jack_port_id_t b,
int connect);
@@ -124,7 +125,7 @@ static int jack_run_one_cycle (jack_engine_t *engine, jack_nframes_t nframes,
static void jack_engine_delay (jack_engine_t *engine,
float delayed_usecs);
static void jack_engine_driver_exit (jack_engine_t* engine);
-static int jack_start_freewheeling (jack_engine_t* engine, jack_client_id_t);
+static int jack_start_freewheeling (jack_engine_t* engine, jack_uuid_t);
static int jack_client_feeds_transitive (jack_client_internal_t *source,
jack_client_internal_t *dest);
static int jack_client_sort (jack_client_internal_t *a,
@@ -134,9 +135,9 @@ static void jack_compute_all_port_total_latencies (jack_engine_t *engine);
static void jack_compute_port_total_latency (jack_engine_t *engine, jack_port_shared_t*);
static int jack_check_client_status (jack_engine_t* engine);
static int jack_do_session_notify (jack_engine_t *engine, jack_request_t *req, int reply_fd );
-static void jack_do_get_client_by_uuid ( jack_engine_t *engine, jack_request_t *req);
-static void jack_do_get_uuid_by_client_name ( jack_engine_t *engine, jack_request_t *req);
-static void jack_do_reserve_name ( jack_engine_t *engine, jack_request_t *req);
+static void jack_do_get_client_by_uuid (jack_engine_t *engine, jack_request_t *req);
+static void jack_do_get_uuid_by_client_name (jack_engine_t *engine, jack_request_t *req);
+static void jack_do_reserve_name (jack_engine_t *engine, jack_request_t *req);
static void jack_do_session_reply (jack_engine_t *engine, jack_request_t *req );
static void jack_compute_new_latency (jack_engine_t *engine);
static int jack_do_has_session_cb (jack_engine_t *engine, jack_request_t *req);
@@ -647,7 +648,7 @@ jack_process_external(jack_engine_t *engine, JSList *node)
client = (jack_client_internal_t *) node->data;
ctl = client->control;
-
+
engine->current_client = client;
// a race exists if we do this after the write(2)
@@ -1763,7 +1764,6 @@ jack_engine_new (int realtime, int rtpriority, int do_mlock, int do_unlock,
engine->timeout_count = 0;
engine->problems = 0;
- engine->next_client_id = 1; /* 0 is a NULL client ID */
engine->port_max = port_max;
engine->server_thread = 0;
engine->rtpriority = rtpriority;
@@ -1773,7 +1773,7 @@ jack_engine_new (int realtime, int rtpriority, int do_mlock, int do_unlock,
engine->temporary = temporary;
engine->freewheeling = 0;
engine->stop_freewheeling = 0;
- engine->fwclient = 0;
+ jack_uuid_clear (engine->fwclient);
engine->feedbackcount = 0;
engine->wait_pid = wait_pid;
engine->nozombies = nozombies;
@@ -2166,7 +2166,7 @@ jack_drivers_write (jack_engine_t *engine, jack_nframes_t nframes)
return engine->driver->write(engine->driver, nframes);
}
static int
-jack_start_freewheeling (jack_engine_t* engine, jack_client_id_t client_id)
+jack_start_freewheeling (jack_engine_t* engine, jack_uuid_t client_id)
{
jack_event_t event;
jack_client_internal_t *client;
@@ -2192,7 +2192,7 @@ jack_start_freewheeling (jack_engine_t* engine, jack_client_id_t client_id)
client = jack_client_internal_by_id (engine, client_id);
if (client->control->process_cbset || client->control->thread_cb_cbset) {
- engine->fwclient = client_id;
+ jack_uuid_copy (engine->fwclient, client_id);
}
engine->freewheeling = 1;
@@ -2240,7 +2240,7 @@ jack_stop_freewheeling (jack_engine_t* engine, int engine_exiting)
pthread_join (engine->freewheel_thread, &ftstatus);
VERBOSE (engine, "freewheel thread has returned");
- engine->fwclient = 0;
+ jack_uuid_clear (engine->fwclient);
engine->freewheeling = 0;
engine->first_wakeup = 1;
@@ -2616,25 +2616,13 @@ jack_deliver_event_to_all (jack_engine_t *engine, jack_event_t *event)
jack_unlock_graph (engine);
}
-static jack_client_id_t jack_engine_get_max_uuid( jack_engine_t *engine )
-{
- JSList *node;
- jack_client_id_t retval = 0;
- for (node = engine->clients; node; node = jack_slist_next (node)) {
- jack_client_internal_t* client = (jack_client_internal_t*) node->data;
- if( client->control->uid > retval )
- retval = client->control->uid;
- }
- return retval;
-}
-
static void jack_do_get_client_by_uuid ( jack_engine_t *engine, jack_request_t *req)
{
JSList *node;
req->status = -1;
for (node = engine->clients; node; node = jack_slist_next (node)) {
jack_client_internal_t* client = (jack_client_internal_t*) node->data;
- if( client->control->uid == req->x.client_id ) {
+ if (jack_uuid_compare (client->control->uuid, req->x.client_id) == 0) {
snprintf( req->x.port_info.name, sizeof(req->x.port_info.name), "%s", client->control->name );
req->status = 0;
return;
@@ -2642,21 +2630,21 @@ static void jack_do_get_client_by_uuid ( jack_engine_t *engine, jack_request_t *
}
}
-static void jack_do_get_uuid_by_client_name ( jack_engine_t *engine, jack_request_t *req)
+static void jack_do_get_uuid_by_client_name (jack_engine_t *engine, jack_request_t *req)
{
JSList *node;
req->status = -1;
for (node = engine->clients; node; node = jack_slist_next (node)) {
jack_client_internal_t* client = (jack_client_internal_t*) node->data;
- if( strcmp( client->control->name, req->x.name ) == 0 ) {
- snprintf( req->x.port_info.name, sizeof(req->x.port_info.name), "%d", client->control->uid );
+ if (strcmp (client->control->name, req->x.name) == 0) {
+ jack_uuid_copy (req->x.client_id, client->control->uuid);
req->status = 0;
return;
}
}
}
-static void jack_do_reserve_name ( jack_engine_t *engine, jack_request_t *req)
+static void jack_do_reserve_name (jack_engine_t *engine, jack_request_t *req)
{
jack_reserved_name_t *reservation;
JSList *node;
@@ -2669,23 +2657,23 @@ static void jack_do_reserve_name ( jack_engine_t *engine, jack_request_t *req)
}
}
- reservation = malloc( sizeof( jack_reserved_name_t ) );
- if( reservation == NULL ) {
+ reservation = malloc (sizeof (jack_reserved_name_t));
+ if (reservation == NULL) {
req->status = -1;
return;
}
- snprintf( reservation->name, sizeof( reservation->name ), "%s", req->x.reservename.name );
- reservation->uuid = req->x.reservename.uuid;
- engine->reserved_client_names = jack_slist_append( engine->reserved_client_names, reservation );
+ snprintf (reservation->name, sizeof (reservation->name), "%s", req->x.reservename.name);
+ jack_uuid_copy (reservation->uuid, req->x.reservename.uuid);
+ engine->reserved_client_names = jack_slist_append (engine->reserved_client_names, reservation);
req->status = 0;
}
static int jack_send_session_reply ( jack_engine_t *engine, jack_client_internal_t *client )
{
- if (write (engine->session_reply_fd, (const void *) &client->control->uid, sizeof (client->control->uid))
- < (ssize_t) sizeof (client->control->uid)) {
+ if (write (engine->session_reply_fd, (const void *) &client->control->uuid, sizeof (client->control->uuid))
+ < (ssize_t) sizeof (client->control->uuid)) {
jack_error ("cannot write SessionNotify result "
"to client via fd = %d (%s)",
engine->session_reply_fd, strerror (errno));
@@ -2725,9 +2713,11 @@ jack_do_session_notify (jack_engine_t *engine, jack_request_t *req, int reply_fd
jack_event_t event;
int reply;
- jack_client_id_t finalizer=0;
+ jack_uuid_t finalizer;
struct stat sbuf;
+ jack_uuid_clear (finalizer);
+
if (engine->session_reply_fd != -1) {
// we should have a notion of busy or somthing.
// just sending empty reply now.
@@ -2743,14 +2733,6 @@ jack_do_session_notify (jack_engine_t *engine, jack_request_t *req, int reply_fd
/* GRAPH MUST BE LOCKED : see callers of jack_send_connection_notification()
*/
- // make sure all uuids are set.
- for (node = engine->clients; node; node = jack_slist_next (node)) {
- jack_client_internal_t* client = (jack_client_internal_t*) node->data;
- if( client->control->uid == 0 ) {
- client->control->uid=jack_engine_get_max_uuid( engine ) + 1;
- }
- }
-
if (stat (req->x.session.path, &sbuf) != 0 || !S_ISDIR (sbuf.st_mode)) {
jack_error ("session parent directory (%s) does not exist", req->x.session.path);
goto send_final;
@@ -2827,9 +2809,13 @@ out:
static void jack_do_session_reply (jack_engine_t *engine, jack_request_t *req )
{
- jack_client_id_t client_id = req->x.client_id;
- jack_client_internal_t *client = jack_client_internal_by_id (engine, client_id);
- jack_client_id_t finalizer=0;
+ jack_uuid_t client_id;
+ jack_client_internal_t *client;
+ jack_uuid_t finalizer;
+
+ jack_uuid_copy (client_id, req->x.client_id);
+ client = jack_client_internal_by_id (engine, client_id);
+ jack_uuid_clear (finalizer);
req->status = 0;
@@ -2862,7 +2848,7 @@ static void jack_do_session_reply (jack_engine_t *engine, jack_request_t *req )
}
static void
-jack_notify_all_port_interested_clients (jack_engine_t *engine, jack_client_id_t src, jack_client_id_t dst, jack_port_id_t a, jack_port_id_t b, int connected)
+jack_notify_all_port_interested_clients (jack_engine_t *engine, jack_uuid_t src, jack_uuid_t dst, jack_port_id_t a, jack_port_id_t b, int connected)
{
JSList *node;
jack_event_t event;
@@ -3112,6 +3098,8 @@ jack_rechain_graph (jack_engine_t *engine)
jack_event_t event;
int upstream_is_jackd;
+ VALGRIND_MEMSET(&event, 0, sizeof (event));
+
jack_clear_fifos (engine);
subgraph_client = 0;
@@ -3422,6 +3410,8 @@ jack_compute_new_latency (jack_engine_t *engine)
event.type = LatencyCallback;
event.x.n = 0;
+ VALGRIND_MEMSET (&event, 0, sizeof (event));
+
/* iterate over all clients in graph order, and emit
* capture latency callback.
* also builds up list in reverse graph order.
@@ -4358,7 +4348,7 @@ fallback:
next:
shared->ptype_id = engine->control->port_types[i].ptype_id;
- shared->client_id = req->x.port_info.client_id;
+ jack_uuid_copy (shared->client_id, req->x.port_info.client_id);
shared->flags = req->x.port_info.flags;
shared->latency = 0;
shared->capture_latency.min = shared->capture_latency.max = 0;
@@ -4653,7 +4643,7 @@ jack_get_port_by_name (jack_engine_t *engine, const char *name)
static int
jack_send_connection_notification (jack_engine_t *engine,
- jack_client_id_t client_id,
+ jack_uuid_t client_id,
jack_port_id_t self_id,
jack_port_id_t other_id, int connected)
@@ -4661,6 +4651,8 @@ jack_send_connection_notification (jack_engine_t *engine,
jack_client_internal_t *client;
jack_event_t event;
+ VALGRIND_MEMSET(&event, 0, sizeof(event));
+
if ((client = jack_client_internal_by_id (engine, client_id)) == NULL) {
jack_error ("no such client %" PRIu32
" during connection notification", client_id);
diff --git a/jackd/transengine.c b/jackd/transengine.c
index 331f1fc..8c84639 100644
--- a/jackd/transengine.c
+++ b/jackd/transengine.c
@@ -52,8 +52,7 @@ jack_sync_poll_new (jack_engine_t *engine, jack_client_internal_t *client)
VERBOSE (engine, "force transport state to Starting");
}
- VERBOSE (engine, "polling sync client %" PRIu32,
- client->control->id);
+ VERBOSE (engine, "polling sync client %s", client->control->name);
}
/* stop polling a specific slow-sync client
@@ -67,8 +66,7 @@ jack_sync_poll_deactivate (jack_engine_t *engine,
client->control->sync_poll = 0;
client->control->sync_new = 0;
engine->control->sync_remain--;
- VERBOSE (engine, "sync poll interrupted for client %"
- PRIu32, client->control->id);
+ VERBOSE (engine, "sync poll interrupted for client %s", client->control->name);
}
client->control->active_slowsync = 0;
engine->control->sync_clients--;
@@ -169,7 +167,7 @@ jack_set_sample_rate (jack_engine_t *engine, jack_nframes_t nframes)
/* on ResetTimeBaseClient request */
int
-jack_timebase_reset (jack_engine_t *engine, jack_client_id_t client_id)
+jack_timebase_reset (jack_engine_t *engine, jack_uuid_t client_id)
{
int ret;
struct _jack_client_internal *client;
@@ -197,7 +195,7 @@ jack_timebase_reset (jack_engine_t *engine, jack_client_id_t client_id)
/* on SetTimeBaseClient request */
int
jack_timebase_set (jack_engine_t *engine,
- jack_client_id_t client_id, int conditional)
+ jack_uuid_t client_id, int conditional)
{
int ret = 0;
struct _jack_client_internal *client;
@@ -339,7 +337,7 @@ jack_transport_client_new (jack_client_internal_t *client)
/* on ResetSyncClient request */
int
jack_transport_client_reset_sync (jack_engine_t *engine,
- jack_client_id_t client_id)
+ jack_uuid_t client_id)
{
int ret;
jack_client_internal_t *client;
@@ -364,7 +362,7 @@ jack_transport_client_reset_sync (jack_engine_t *engine,
/* on SetSyncClient request */
int
jack_transport_client_set_sync (jack_engine_t *engine,
- jack_client_id_t client_id)
+ jack_uuid_t client_id)
{
int ret;
jack_client_internal_t *client;
diff --git a/jackd/transengine.h b/jackd/transengine.h
index 9bd238d..b433c47 100644
--- a/jackd/transengine.h
+++ b/jackd/transengine.h
@@ -20,9 +20,9 @@
int jack_set_sample_rate (jack_engine_t *engine, jack_nframes_t nframes);
int jack_timebase_reset (jack_engine_t *engine,
- jack_client_id_t client_id);
+ jack_uuid_t client_id);
int jack_timebase_set (jack_engine_t *engine,
- jack_client_id_t client_id, int conditional);
+ jack_uuid_t client_id, int conditional);
void jack_transport_activate (jack_engine_t *engine,
jack_client_internal_t *client);
void jack_transport_init (jack_engine_t *engine);
@@ -30,9 +30,9 @@ void jack_transport_client_exit (jack_engine_t *engine,
jack_client_internal_t *client);
void jack_transport_client_new (jack_client_internal_t *client);
int jack_transport_client_reset_sync (jack_engine_t *engine,
- jack_client_id_t client_id);
+ jack_uuid_t client_id);
int jack_transport_client_set_sync (jack_engine_t *engine,
- jack_client_id_t client_id);
+ jack_uuid_t client_id);
void jack_transport_cycle_end (jack_engine_t *engine);
void jack_transport_cycle_start(jack_engine_t *engine, jack_time_t time);
int jack_transport_set_sync_timeout (jack_engine_t *engine,
diff --git a/libjack/Makefile.am b/libjack/Makefile.am
index 7e61e1a..b976fe7 100644
--- a/libjack/Makefile.am
+++ b/libjack/Makefile.am
@@ -21,7 +21,8 @@ SOURCE_FILES = \
thread.c \
time.c \
transclient.c \
- unlock.c
+ unlock.c \
+ uuid.c
simd.lo: $(srcdir)/simd.c
$(LIBTOOL) --mode=compile $(CC) -I$(top_builddir) $(JACK_CORE_CFLAGS) $(SIMD_CFLAGS) -c -o simd.lo $(srcdir)/simd.c
diff --git a/libjack/client.c b/libjack/client.c
index 2be9e63..c585f1b 100644
--- a/libjack/client.c
+++ b/libjack/client.c
@@ -40,6 +40,7 @@
#include <jack/jack.h>
#include <jack/jslist.h>
#include <jack/thread.h>
+#include <jack/uuid.h>
#include "internal.h"
#include "engine.h"
@@ -436,9 +437,9 @@ jack_client_handle_port_connection (jack_client_t *client, jack_event_t *event)
jack_port_t *other = 0;
JSList *node;
int need_free = FALSE;
-
- if (client->engine->ports[event->x.self_id].client_id == client->control->id ||
- client->engine->ports[event->y.other_id].client_id == client->control->id) {
+
+ if (jack_uuid_compare (client->engine->ports[event->x.self_id].client_id, client->control->uuid) == 0 ||
+ jack_uuid_compare (client->engine->ports[event->y.other_id].client_id, client->control->uuid) == 0) {
/* its one of ours */
@@ -516,24 +517,24 @@ jack_client_handle_port_connection (jack_client_t *client, jack_event_t *event)
int
jack_client_handle_session_callback (jack_client_t *client, jack_event_t *event)
{
- char prefix[32];
+ char uuidstr[37];
jack_session_event_t *s_event;
if (! client->control->session_cbset) {
return -1;
}
- snprintf( prefix, sizeof(prefix), "%d", client->control->uid );
+ uuid_unparse (client->control->uuid, uuidstr);
s_event = malloc( sizeof(jack_session_event_t) );
s_event->type = event->y.n;
- s_event->session_dir = strdup( event->x.name );
- s_event->client_uuid = strdup( prefix );
+ s_event->session_dir = strdup (event->x.name);
+ s_event->client_uuid = strdup (uuidstr);
s_event->command_line = NULL;
s_event->future = 0;
client->session_cb_immediate_reply = 0;
- client->session_cb ( s_event, client->session_cb_arg);
+ client->session_cb (s_event, client->session_cb_arg);
if (client->session_cb_immediate_reply) {
return 2;
@@ -805,7 +806,7 @@ server_event_connect (jack_client_t *client, const char *server_name)
return -1;
}
- req.client_id = client->control->id;
+ jack_uuid_copy (req.client_id, client->control->uuid);
if (write (fd, &req, sizeof (req)) != sizeof (req)) {
jack_error ("cannot write event connect request to server (%s)",
@@ -1032,10 +1033,13 @@ jack_request_client (ClientType type,
/* format connection request */
- if( va->sess_uuid )
- req.uuid = atoi( va->sess_uuid );
- else
- req.uuid = 0;
+ if (va->sess_uuid) {
+ if (jack_uuid_parse (va->sess_uuid, req.uuid) != 0) {
+ goto fail;
+ }
+ } else {
+ jack_uuid_clear (req.uuid);
+ }
req.protocol_v = jack_protocol_version;
req.load = TRUE;
req.type = type;
@@ -1280,11 +1284,6 @@ jack_client_open_aux (const char *client_name,
client->deliver_request = oop_client_deliver_request;
client->deliver_arg = client;
- if( va.sess_uuid )
- client->control->uid = atoi( va.sess_uuid );
- else
- client->control->uid = 0U;
-
if ((ev_fd = server_event_connect (client, va.server_name)) < 0) {
goto fail;
}
@@ -1470,7 +1469,7 @@ jack_set_freewheel (jack_client_t* client, int onoff)
VALGRIND_MEMSET (&request, 0, sizeof (request));
request.type = onoff ? FreeWheel : StopFreeWheel;
- request.x.client_id = client->control->id;
+ jack_uuid_copy (request.x.client_id, client->control->uuid);
return jack_client_deliver_request (client, &request);
}
@@ -1496,7 +1495,7 @@ jack_session_reply (jack_client_t *client, jack_session_event_t *event )
VALGRIND_MEMSET (&request, 0, sizeof (request));
request.type = SessionReply;
- request.x.client_id = client->control->id;
+ jack_uuid_copy (request.x.client_id, client->control->uuid);
retval = jack_client_deliver_request(client, &request);
}
@@ -1565,7 +1564,8 @@ jack_session_notify (jack_client_t* client, const char *target, jack_session_eve
}
while( 1 ) {
- jack_client_id_t uid;
+ jack_uuid_t uid;
+
if (read (client->request_fd, &uid, sizeof (uid)) != sizeof (uid)) {
jack_error ("cannot read result for request type %d from"
" server (%s)", request.type, strerror (errno));
@@ -1576,16 +1576,16 @@ jack_session_notify (jack_client_t* client, const char *target, jack_session_eve
retval = realloc( retval, (num_replies)*sizeof(jack_session_command_t) );
retval[num_replies-1].client_name = malloc (JACK_CLIENT_NAME_SIZE);
retval[num_replies-1].command = malloc (JACK_PORT_NAME_SIZE);
- retval[num_replies-1].uuid = malloc (16);
+ retval[num_replies-1].uuid = malloc (JACK_UUID_STRING_SIZE);
if ( (retval[num_replies-1].client_name == NULL)
||(retval[num_replies-1].command == NULL)
||(retval[num_replies-1].uuid == NULL) )
goto out;
- if( uid == 0 )
+ if (jack_uuid_empty (uid)) {
break;
-
+ }
if (read (client->request_fd, (char *)retval[num_replies-1].client_name, JACK_CLIENT_NAME_SIZE)
!= JACK_CLIENT_NAME_SIZE) {
@@ -1605,7 +1605,7 @@ jack_session_notify (jack_client_t* client, const char *target, jack_session_eve
" server (%s)", request.type, strerror (errno));
goto out;
}
- snprintf( (char *)retval[num_replies-1].uuid, 16, "%d", uid );
+ uuid_unparse (uid, (char *)retval[num_replies-1].uuid);
}
free((char *)retval[num_replies-1].uuid);
retval[num_replies-1].uuid = NULL;
@@ -2342,7 +2342,7 @@ jack_activate (jack_client_t *client)
startit:
req.type = ActivateClient;
- req.x.client_id = client->control->id;
+ jack_uuid_copy (req.x.client_id, client->control->uuid);
return jack_client_deliver_request (client, &req);
}
@@ -2358,7 +2358,7 @@ jack_deactivate_aux (jack_client_t *client)
if (client->control->active) { /* still active? */
VALGRIND_MEMSET (&req, 0, sizeof (req));
req.type = DeactivateClient;
- req.x.client_id = client->control->id;
+ jack_uuid_copy (req.x.client_id, client->control->uuid);
rc = jack_client_deliver_request (client, &req);
}
}
@@ -2774,25 +2774,25 @@ jack_on_info_shutdown (jack_client_t *client, void (*function)(jack_status_t, co
}
char *
-jack_get_client_name_by_uuid( jack_client_t *client, const char *uuid )
+jack_get_client_name_by_uuid (jack_client_t *client, const char *uuid_str)
{
jack_request_t request;
- char *end_ptr;
- jack_client_id_t uuid_int = strtol( uuid, &end_ptr, 10 );
- if ( *end_ptr != '\0' ) return NULL;
-
+
VALGRIND_MEMSET (&request, 0, sizeof (request));
+ if (uuid_parse (uuid_str, request.x.client_id) != 0) {
+ return NULL;
+ }
+
request.type = GetClientByUUID;
- request.x.client_id = uuid_int;
- if( jack_client_deliver_request( client, &request ) )
+ if( jack_client_deliver_request (client, &request))
return NULL;
- return strdup( request.x.port_info.name );
+ return strdup (request.x.port_info.name);
}
char*
-jack_get_uuid_for_client_name ( jack_client_t *client, const char *client_name )
+jack_get_uuid_for_client_name (jack_client_t *client, const char *client_name)
{
jack_request_t request;
size_t len = strlen(client_name) + 1;
@@ -2804,40 +2804,38 @@ jack_get_uuid_for_client_name ( jack_client_t *client, const char *client_name )
request.type = GetUUIDByClientName;
memcpy(request.x.name, client_name, len);
- if( jack_client_deliver_request( client, &request ) )
+ if (jack_client_deliver_request( client, &request)) {
return NULL;
+ }
- return strdup( request.x.port_info.name );
+ char buf[37];
+ uuid_unparse (request.x.client_id, buf);
+ return strdup (buf);
}
char *
-jack_client_get_uuid( jack_client_t *client )
+jack_client_get_uuid (jack_client_t *client)
{
- char retval[16];
-
- snprintf( retval, sizeof(retval), "%d", client->control->uid );
-
- return strdup(retval);
+ char retval[37];
+ uuid_unparse (client->control->uuid, retval);
+ return strdup (retval);
}
int
-jack_reserve_client_name( jack_client_t *client, const char *name, const char *uuid )
+jack_reserve_client_name (jack_client_t *client, const char *name, const char *uuid_str)
{
jack_request_t request;
- char *end_ptr;
- jack_client_id_t uuid_int = strtol( uuid, &end_ptr, 10 );
-
- if( *end_ptr != '\0' ) {
- return -1;
- }
VALGRIND_MEMSET (&request, 0, sizeof (request));
request.type = ReserveName;
snprintf( request.x.reservename.name, sizeof( request.x.reservename.name ),
"%s", name );
- request.x.reservename.uuid = uuid_int;
- return jack_client_deliver_request( client, &request );
+ if (uuid_parse (uuid_str, request.x.reservename.uuid) != 0) {
+ return NULL;
+ }
+
+ return jack_client_deliver_request (client, &request);
}
const char **
diff --git a/libjack/intclient.c b/libjack/intclient.c
index 453eb00..4503d61 100644
--- a/libjack/intclient.c
+++ b/libjack/intclient.c
@@ -26,16 +26,17 @@
#include <string.h>
#include <jack/intclient.h>
+#include <jack/uuid.h>
#include "internal.h"
#include "varargs.h"
#include "local.h"
-static jack_intclient_t
+static int
jack_intclient_request(RequestType type, jack_client_t *client,
- const char* client_name, jack_options_t options,
- jack_status_t *status, jack_varargs_t *va)
+ const char* client_name, jack_options_t options,
+ jack_status_t *status, jack_intclient_t uuid, jack_varargs_t *va)
{
jack_request_t req;
@@ -45,7 +46,7 @@ jack_intclient_request(RequestType type, jack_client_t *client,
jack_error ("\"%s\" is too long for a JACK client name.\n"
"Please use %lu characters or less.",
client_name, sizeof (req.x.intclient.name));
- return 0;
+ return -1;
}
if (va->load_name
@@ -54,7 +55,7 @@ jack_intclient_request(RequestType type, jack_client_t *client,
"Please use %lu characters or less.",
va->load_name, sizeof (req.x.intclient.path) - 1);
*status |= (JackFailure|JackInvalidOption);
- return 0;
+ return -1;
}
if (va->load_init
@@ -63,7 +64,7 @@ jack_intclient_request(RequestType type, jack_client_t *client,
"string.\nPlease use %lu characters or less.",
va->load_init, sizeof (req.x.intclient.init) - 1);
*status |= (JackFailure|JackInvalidOption);
- return 0;
+ return -1;
}
req.type = type;
@@ -82,9 +83,10 @@ jack_intclient_request(RequestType type, jack_client_t *client,
*status |= req.status;
if (*status & JackFailure)
- return 0;
+ return -1;
- return req.x.intclient.id;
+ jack_uuid_copy (uuid, req.x.intclient.uuid);
+ return 0;
}
char *
@@ -97,7 +99,7 @@ jack_get_internal_client_name (jack_client_t *client,
memset (&req, 0, sizeof (req));
req.type = IntClientName;
req.x.intclient.options = JackNullOption;
- req.x.intclient.id = intclient;
+ jack_uuid_copy (req.x.intclient.uuid, intclient);
jack_client_deliver_request (client, &req);
@@ -113,10 +115,11 @@ jack_get_internal_client_name (jack_client_t *client,
return name;
}
-jack_intclient_t
+int
jack_internal_client_handle (jack_client_t *client,
const char *client_name,
- jack_status_t *status)
+ jack_status_t *status,
+ jack_intclient_t handle)
{
jack_request_t req;
jack_status_t my_status;
@@ -133,14 +136,20 @@ jack_internal_client_handle (jack_client_t *client,
*status = jack_client_deliver_request (client, &req);
- return req.x.intclient.id;
+ if (!jack_uuid_empty (req.x.intclient.uuid)) {
+ jack_uuid_copy (handle, req.x.intclient.uuid);
+ return 0;
+ }
+
+ return -1;
}
-jack_intclient_t
+int
jack_internal_client_load_aux (jack_client_t *client,
- const char *client_name,
- jack_options_t options,
- jack_status_t *status, va_list ap)
+ const char *client_name,
+ jack_options_t options,
+ jack_status_t *status,
+ jack_intclient_t handle, va_list ap)
{
jack_varargs_t va;
jack_status_t my_status;
@@ -152,25 +161,26 @@ jack_internal_client_load_aux (jack_client_t *client,
/* validate parameters */
if ((options & ~JackLoadOptions)) {
*status |= (JackFailure|JackInvalidOption);
- return 0;
+ return -1;
}
/* parse variable arguments */
jack_varargs_parse (options, ap, &va);
return jack_intclient_request (IntClientLoad, client, client_name,
- options, status, &va);
+ options, status, handle, &va);
}
-jack_intclient_t
+int
jack_internal_client_load (jack_client_t *client,
const char *client_name,
jack_options_t options,
- jack_status_t *status, ...)
+ jack_status_t *status,
+ jack_intclient_t handle, ...)
{
va_list ap;
va_start(ap, status);
- jack_intclient_t res = jack_internal_client_load_aux(client, client_name, options, status, ap);
+ int res = jack_internal_client_load_aux(client, client_name, options, status, handle, ap);
va_end(ap);
return res;
}
@@ -187,7 +197,7 @@ jack_internal_client_unload (jack_client_t *client,
memset (&req, 0, sizeof (req));
req.type = IntClientUnload;
req.x.intclient.options = JackNullOption;
- req.x.intclient.id = intclient;
+ jack_uuid_copy (req.x.intclient.uuid, intclient);
jack_client_deliver_request (client, &req);
status = req.status;
diff --git a/libjack/port.c b/libjack/port.c
index 8aeb032..1ba951a 100644
--- a/libjack/port.c
+++ b/libjack/port.c
@@ -29,6 +29,7 @@
#include <jack/jack.h>
#include <jack/types.h>
#include <jack/midiport.h>
+#include <jack/uuid.h>
#include <jack/jslist.h>
@@ -195,7 +196,7 @@ jack_port_new (const jack_client_t *client, jack_port_id_t port_id,
port->tied = NULL;
uuid_generate (port->shared->uuid);
- if (client->control->id == port->shared->client_id) {
+ if (jack_uuid_compare (client->control->uuid, port->shared->client_id) == 0) {
/* It's our port, so initialize the pointers to port
* functions within this address space. These builtin
@@ -272,7 +273,7 @@ jack_port_register (jack_client_t *client,
"%s", port_type);
req.x.port_info.flags = flags;
req.x.port_info.buffer_size = buffer_size;
- req.x.port_info.client_id = client->control->id;
+ jack_uuid_copy (req.x.port_info.client_id, client->control->uuid);
if (jack_client_deliver_request (client, &req)) {
jack_error ("cannot deliver port registration request");
@@ -300,7 +301,7 @@ jack_port_unregister (jack_client_t *client, jack_port_t *port)
req.type = UnRegisterPort;
req.x.port_info.port_id = port->shared->id;
- req.x.port_info.client_id = client->control->id;
+ jack_uuid_copy (req.x.port_info.client_id, client->control->uuid);
return jack_client_deliver_request (client, &req);
}
@@ -403,7 +404,7 @@ jack_port_get_all_connections (const jack_client_t *client,
req.x.port_info.type[0] = '\0';
req.x.port_info.flags = 0;
req.x.port_info.buffer_size = 0;
- req.x.port_info.client_id = 0;
+ jack_uuid_clear (req.x.port_info.client_id);
req.x.port_info.port_id = port->shared->id;
jack_client_deliver_request (client, &req);
@@ -750,7 +751,7 @@ jack_port_name (const jack_port_t *port)
void
jack_port_uuid (const jack_port_t *port, jack_uuid_t uuid)
{
- return uuid_copy (uuid, port->shared->uuid);
+ return jack_uuid_copy (uuid, port->shared->uuid);
}
int
@@ -784,7 +785,7 @@ jack_port_short_name (const jack_port_t *port)
int
jack_port_is_mine (const jack_client_t *client, const jack_port_t *port)
{
- return port->shared->client_id == client->control->id;
+ return jack_uuid_compare (port->shared->client_id, client->control->uuid) == 0;
}
int
diff --git a/libjack/transclient.c b/libjack/transclient.c
index a5bacbe..06c886c 100644
--- a/libjack/transclient.c
+++ b/libjack/transclient.c
@@ -359,7 +359,7 @@ jack_release_timebase (jack_client_t *client)
VALGRIND_MEMSET (&req, 0, sizeof (req));
req.type = ResetTimeBaseClient;
- req.x.client_id = ctl->id;
+ jack_uuid_copy (req.x.client_id, ctl->uuid);
rc = jack_client_deliver_request (client, &req);
if (rc == 0) {
@@ -385,7 +385,7 @@ jack_set_sync_callback (jack_client_t *client,
req.type = SetSyncClient;
else
req.type = ResetSyncClient;
- req.x.client_id = ctl->id;
+ jack_uuid_copy (req.x.client_id, ctl->uuid);
rc = jack_client_deliver_request (client, &req);
if (rc == 0) {
@@ -420,7 +420,7 @@ jack_set_timebase_callback (jack_client_t *client, int conditional,
VALGRIND_MEMSET (&req, 0, sizeof (req));
req.type = SetTimeBaseClient;
- req.x.timebase.client_id = ctl->id;
+ jack_uuid_copy (req.x.timebase.client_id, ctl->uuid);
req.x.timebase.conditional = conditional;
rc = jack_client_deliver_request (client, &req);
diff --git a/tools b/tools
-Subproject a7fb88c0dee5c572d557be066e01ac410e029f8
+Subproject 177e91545dda9a1ebc81a511e787a6ef1ccbb52