Browse Source

add jack_client_get_uuid() and fix stuff for multiclient

tags/0.120.1
Torben Hohn 15 years ago
parent
commit
f9545581f7
3 changed files with 32 additions and 13 deletions
  1. +14
    -9
      jack/session.h
  2. +8
    -4
      jackd/engine.c
  3. +10
    -0
      libjack/client.c

+ 14
- 9
jack/session.h View File

@@ -63,14 +63,6 @@ enum JackSessionFlags {
* an error occured while saving. * an error occured while saving.
*/ */
JackSessionSaveError = 0x01, JackSessionSaveError = 0x01,

/**
* this reply indicates that a client is part of a multiclient application.
* the command reply is left empty. but the session manager should still
* consider this client part of a session. it will come up due to invocation of another
* client.
*/
JackSessionChildClient = 0x02
}; };


typedef enum JackSessionFlags jack_session_flags_t; typedef enum JackSessionFlags jack_session_flags_t;
@@ -130,6 +122,10 @@ typedef void (*JackSessionCallback)(jack_session_event_t *event, void *arg);
* Tell the JACK server to call @a save_callback the session handler wants * Tell the JACK server to call @a save_callback the session handler wants
* to save. * to save.
* *
* setting more than one session_callback per process is probably a design
* error. if you have a multiclient application its more sensible to create
* a jack_client with only a session callback set.
*
* @return 0 on success, otherwise a non-zero error code * @return 0 on success, otherwise a non-zero error code
*/ */
int jack_set_session_callback(jack_client_t *client, int jack_set_session_callback(jack_client_t *client,
@@ -155,7 +151,16 @@ int jack_session_reply( jack_client_t *client, jack_session_event_t *event ) JAC
* if its non NULL. * if its non NULL.
*/ */


void jack_session_event_free (jack_session_event_t *event);
void jack_session_event_free (jack_session_event_t *event) JACK_WEAK_EXPORT;


/**
* get the assigned uuid for client.
* safe to call from callback and all other threads.
* memory needs to be freed.
*/

char *jack_client_get_uuid (jack_client_t *client) JACK_WEAK_EXPORT;


/*@}*/ /*@}*/




+ 8
- 4
jackd/engine.c View File

@@ -2638,14 +2638,18 @@ 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() /* 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;
}
}

for (node = engine->clients; node; node = jack_slist_next (node)) { for (node = engine->clients; node; node = jack_slist_next (node)) {
jack_client_internal_t* client = (jack_client_internal_t*) node->data; jack_client_internal_t* client = (jack_client_internal_t*) node->data;
if (client->control->session_cbset) { if (client->control->session_cbset) {
if( client->control->uid == 0 ) {
client->control->uid=jack_engine_get_max_uuid( engine ) + 1;
}

// in case we only want to send to a special client. // in case we only want to send to a special client.
// uuid assign is still complete. not sure if thats necessary. // uuid assign is still complete. not sure if thats necessary.
if( (req->x.session.target[0] != 0) && strcmp(req->x.session.target, (char *)client->control->name) ) if( (req->x.session.target[0] != 0) && strcmp(req->x.session.target, (char *)client->control->name) )


+ 10
- 0
libjack/client.c View File

@@ -2676,6 +2676,16 @@ jack_get_client_name_by_uuid( jack_client_t *client, const char *uuid )
return strdup( request.x.port_info.name ); return strdup( request.x.port_info.name );
} }


char *
jack_client_get_uuid( jack_client_t *client )
{
char retval[16];

snprintf( retval, sizeof(retval), "%d", client->control->uid );

return strdup(retval);
}

int 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 )
{ {


Loading…
Cancel
Save