| @@ -375,7 +375,8 @@ typedef enum { | |||
| IntClientUnload = 22, | |||
| RecomputeTotalLatencies = 23, | |||
| RecomputeTotalLatency = 24, | |||
| SessionNotify = 25 | |||
| SessionNotify = 25, | |||
| GetClientByUUID = 26 | |||
| } RequestType; | |||
| struct _jack_request { | |||
| @@ -1026,6 +1026,8 @@ struct session_command { | |||
| struct session_command * jack_session_notify (jack_client_t* client, jack_session_event_t code, const char *path ); | |||
| char *jack_get_client_name_by_uuid( jack_client_t *client, const char *uuid ); | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| @@ -113,7 +113,6 @@ 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 */ | |||
| jack_port_id_t uid; /* index into engine port array */ | |||
| uint32_t flags; | |||
| char name[JACK_CLIENT_NAME_SIZE+JACK_PORT_NAME_SIZE]; | |||
| char alias1[JACK_CLIENT_NAME_SIZE+JACK_PORT_NAME_SIZE]; | |||
| @@ -134,6 +134,7 @@ 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 void jack_engine_signal_problems (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 inline int | |||
| jack_rolling_interval (jack_time_t period_usecs) | |||
| @@ -1340,11 +1341,16 @@ do_request (jack_engine_t *engine, jack_request_t *req, int *reply_fd) | |||
| req->status = 0; | |||
| break; | |||
| case GetClientByUUID: | |||
| jack_lock_graph (engine); | |||
| jack_do_get_client_by_uuid (engine, req); | |||
| jack_unlock_graph (engine); | |||
| break; | |||
| case SessionNotify: | |||
| jack_lock_graph (engine); | |||
| if ((req->status = | |||
| jack_do_session_notify (engine, req, *reply_fd)) | |||
| == 0) { | |||
| >= 0) { | |||
| /* we have already replied, don't do it again */ | |||
| *reply_fd = -1; | |||
| } | |||
| @@ -2447,16 +2453,17 @@ static jack_client_id_t jack_engine_get_max_uuid( jack_engine_t *engine ) | |||
| return retval; | |||
| } | |||
| static void jack_client_fixup_uuid (jack_client_internal_t *client ) | |||
| static void jack_do_get_client_by_uuid ( jack_engine_t *engine, jack_request_t *req) | |||
| { | |||
| JSList *node; | |||
| jack_port_t *port; | |||
| for (node = client->ports; node; node = jack_slist_next (node)) { | |||
| port = (jack_port_t *) node->data; | |||
| port->shared->uid = client->control->uid; | |||
| 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 ) { | |||
| snprintf( req->x.port_info.name, sizeof(req->x.port_info.name), "%s", client->control->name ); | |||
| req->status = 0; | |||
| return; | |||
| } | |||
| } | |||
| } | |||
| @@ -2483,7 +2490,6 @@ jack_do_session_notify (jack_engine_t *engine, jack_request_t *req, int reply_fd | |||
| if( client->control->uid == 0 ) { | |||
| client->control->uid=jack_engine_get_max_uuid( engine ) + 1; | |||
| jack_client_fixup_uuid( client ); | |||
| } | |||
| reply = jack_deliver_event (engine, client, &event); | |||
| @@ -2536,6 +2536,19 @@ jack_on_info_shutdown (jack_client_t *client, void (*function)(jack_status_t, co | |||
| client->on_info_shutdown_arg = arg; | |||
| } | |||
| char *jack_get_client_name_by_uuid( jack_client_t *client, const char *uuid ) | |||
| { | |||
| jack_request_t request; | |||
| jack_client_id_t uuid_int = atoi( uuid ); | |||
| request.type = GetClientByUUID; | |||
| request.x.client_id = uuid_int; | |||
| if( jack_client_deliver_request( client, &request ) ) | |||
| return NULL; | |||
| return strdup( request.x.port_info.name ); | |||
| } | |||
| const char ** | |||
| jack_get_ports (jack_client_t *client, | |||
| const char *port_name_pattern, | |||
| @@ -2550,18 +2563,9 @@ jack_get_ports (jack_client_t *client, | |||
| regex_t port_regex; | |||
| regex_t type_regex; | |||
| int matching; | |||
| jack_client_id_t port_uuid_match = 0U; | |||
| engine = client->engine; | |||
| if( port_name_pattern ) { | |||
| if((strncmp( "!uuid:", port_name_pattern, sizeof("!uuid:") ) )) { | |||
| port_uuid_match = atoi( port_name_pattern+6); | |||
| port_name_pattern = NULL; | |||
| } | |||
| } | |||
| if (port_name_pattern && port_name_pattern[0]) { | |||
| regcomp (&port_regex, port_name_pattern, | |||
| REG_EXTENDED|REG_NOSUB); | |||
| @@ -2591,10 +2595,6 @@ jack_get_ports (jack_client_t *client, | |||
| } | |||
| } | |||
| if (matching && port_uuid_match) { | |||
| if( psp[i].uid != port_uuid_match ) | |||
| matching = 0; | |||
| } | |||
| if (matching && port_name_pattern && port_name_pattern[0]) { | |||
| if (regexec (&port_regex, psp[i].name, 0, NULL, 0)) { | |||
| matching = 0; | |||
| @@ -201,7 +201,6 @@ jack_port_new (const jack_client_t *client, jack_port_id_t port_id, | |||
| port_functions = &jack_builtin_NULL_functions; | |||
| port->fptr = *port_functions; | |||
| port->shared->has_mixdown = (port->fptr.mixdown ? TRUE : FALSE); | |||
| port->shared->uid = client->control->uid; | |||
| } | |||
| /* set up a base address so that port->offset can be used to | |||
| @@ -102,20 +102,28 @@ int main(int argc, char *argv[]) | |||
| for(i=0; retval[i].uid != 0; i++ ) { | |||
| char uidstring[16]; | |||
| snprintf( uidstring, sizeof(uidstring), "!uuid:%d", retval[i].uid ); | |||
| const char **ports = jack_get_ports( client, uidstring, NULL, 0 ); | |||
| snprintf( uidstring, sizeof(uidstring), "%d", retval[i].uid ); | |||
| char* port_regexp = alloca( jack_client_name_size()+3 ); | |||
| char* client_name = jack_get_client_name_by_uuid( client, uidstring ); | |||
| printf( "client by uuid(%d) %s\n", retval[i].uid, client_name ); | |||
| snprintf( port_regexp, jack_client_name_size()+3, "%s", client_name ); | |||
| printf( "port_regexp: %s\n", port_regexp ); | |||
| jack_free(client_name); | |||
| const char **ports = jack_get_ports( client, port_regexp, NULL, 0 ); | |||
| if( !ports ) | |||
| continue; | |||
| for (i = 0; ports[i]; ++i) { | |||
| printf( "port: %s\n", ports[i] ); | |||
| const char **connections; | |||
| if ((connections = jack_port_get_all_connections (client, jack_port_by_name(client, ports[i]))) != 0) { | |||
| for (j = 0; connections[j]; j++) { | |||
| printf( "jack_connect %s %s\n", ports[i], connections[j] ); | |||
| } | |||
| free (connections); | |||
| jack_free (connections); | |||
| } | |||
| } | |||
| free(ports); | |||
| jack_free(ports); | |||
| } | |||
| free(retval); | |||