| @@ -50,7 +50,7 @@ class JackClientChannelInterface | |||
| {} | |||
| // Open the Server/Client connection | |||
| virtual int Open(const char* server_name, const char* name, char* name_res, JackClient* obj, jack_options_t options, jack_status_t* status) | |||
| virtual int Open(const char* server_name, const char* name, int uuid, char* name_res, JackClient* obj, jack_options_t options, jack_status_t* status) | |||
| { | |||
| return 0; | |||
| } | |||
| @@ -74,7 +74,7 @@ class JackClientChannelInterface | |||
| return -1; | |||
| } | |||
| virtual void ClientCheck(const char* name, char* name_res, int protocol, int options, int* status, int* result) | |||
| virtual void ClientCheck(const char* name, int uuid, char* name_res, int protocol, int options, int* status, int* result) | |||
| {} | |||
| virtual void ClientOpen(const char* name, int pid, int uuid, int* shared_engine, int* shared_client, int* shared_graph, int* result) | |||
| {} | |||
| @@ -389,7 +389,7 @@ int JackEngine::InternalClientUnload(int refnum, int* status) | |||
| // Client management | |||
| //------------------- | |||
| int JackEngine::ClientCheck(const char* name, char* name_res, int protocol, int options, int* status) | |||
| int JackEngine::ClientCheck(const char* name, int uuid, char* name_res, int protocol, int options, int* status) | |||
| { | |||
| // Clear status | |||
| *status = 0; | |||
| @@ -403,7 +403,11 @@ int JackEngine::ClientCheck(const char* name, char* name_res, int protocol, int | |||
| return -1; | |||
| } | |||
| if (ClientCheckName(name)) { | |||
| std::map<int,std::string>::iterator res = fReservationMap.find(uuid); | |||
| if (res != fReservationMap.end()) { | |||
| strncpy( name_res, res->second.c_str(), JACK_CLIENT_NAME_SIZE ); | |||
| } else if (ClientCheckName(name)) { | |||
| *status |= JackNameNotUnique; | |||
| @@ -531,7 +535,7 @@ int JackEngine::ClientExternalOpen(const char* name, int pid, int uuid, int* ref | |||
| EnsureUUID(uuid); | |||
| } | |||
| jack_log("JackEngine::ClientExternalOpen: name = %s ", real_name); | |||
| jack_log("JackEngine::ClientExternalOpen: uuid=%d, name = %s ", uuid, real_name); | |||
| int refnum = AllocateRefnum(); | |||
| if (refnum < 0) { | |||
| @@ -1023,13 +1027,17 @@ void JackEngine::GetClientNameForUUID(const char *uuid, char *name_res, int *res | |||
| void JackEngine::ReserveClientName(const char *name, const char *uuid, int *result) | |||
| { | |||
| jack_log( "JackEngine::ReserveClientName ( name = %s, uuid = %s )", name, uuid ); | |||
| if (ClientCheckName(name)) { | |||
| *result = -1; | |||
| jack_log( "name already taken" ); | |||
| return; | |||
| } | |||
| EnsureUUID(atoi(uuid)); | |||
| fReservationMap[atoi(uuid)] = name; | |||
| *result = 0; | |||
| } | |||
| } // end of namespace | |||
| @@ -98,7 +98,7 @@ class SERVER_EXPORT JackEngine : public JackLockAble | |||
| int Close(); | |||
| // Client management | |||
| int ClientCheck(const char* name, char* name_res, int protocol, int options, int* status); | |||
| int ClientCheck(const char* name, int uuid, char* name_res, int protocol, int options, int* status); | |||
| int ClientExternalOpen(const char* name, int pid, int uuid, 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); | |||
| @@ -71,7 +71,7 @@ int JackInternalClient::Open(const char* server_name, const char* name, int uuid | |||
| strncpy(fServerName, server_name, sizeof(fServerName)); | |||
| fChannel->ClientCheck(name, name_res, JACK_PROTOCOL_VERSION, (int)options, (int*)status, &result); | |||
| fChannel->ClientCheck(name, uuid, name_res, JACK_PROTOCOL_VERSION, (int)options, (int*)status, &result); | |||
| if (result < 0) { | |||
| int status1 = *status; | |||
| if (status1 & JackVersionError) | |||
| @@ -52,7 +52,7 @@ class JackInternalClientChannel : public detail::JackClientChannelInterface | |||
| 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, -1, name_res, protocol, options, status); | |||
| } | |||
| void ClientOpen(const char* name, int* ref, JackEngineControl** shared_engine, JackGraphManager** shared_manager, JackClientInterface* client, int* result) | |||
| { | |||
| @@ -76,7 +76,7 @@ int JackLibClient::Open(const char* server_name, const char* name, int uuid, jac | |||
| // Open server/client channel | |||
| char name_res[JACK_CLIENT_NAME_SIZE + 1]; | |||
| if (fChannel->Open(server_name, name, name_res, this, options, status) < 0) { | |||
| if (fChannel->Open(server_name, name, uuid, name_res, this, options, status) < 0) { | |||
| jack_error("Cannot connect to the server"); | |||
| goto error; | |||
| } | |||
| @@ -96,11 +96,11 @@ class SERVER_EXPORT JackLockedEngine | |||
| } | |||
| // Client management | |||
| int ClientCheck(const char* name, char* name_res, int protocol, int options, int* status) | |||
| int ClientCheck(const char* name, int uuid, char* name_res, int protocol, int options, int* status) | |||
| { | |||
| TRY_CALL | |||
| JackLock lock(&fEngine); | |||
| return fEngine.ClientCheck(name, name_res, protocol, options, status); | |||
| return fEngine.ClientCheck(name, uuid, name_res, protocol, options, status); | |||
| CATCH_EXCEPTION_RETURN | |||
| } | |||
| int ClientExternalOpen(const char* name, int pid, int uuid, int* ref, int* shared_engine, int* shared_client, int* shared_graph_manager) | |||
| @@ -135,11 +135,12 @@ struct JackClientCheckRequest : public JackRequest | |||
| char fName[JACK_CLIENT_NAME_SIZE + 1]; | |||
| int fProtocol; | |||
| int fOptions; | |||
| int fUUID; | |||
| JackClientCheckRequest() | |||
| {} | |||
| JackClientCheckRequest(const char* name, int protocol, int options) | |||
| : JackRequest(JackRequest::kClientCheck), fProtocol(protocol), fOptions(options) | |||
| JackClientCheckRequest(const char* name, int protocol, int options, int uuid) | |||
| : JackRequest(JackRequest::kClientCheck), fProtocol(protocol), fOptions(options), fUUID(uuid) | |||
| { | |||
| snprintf(fName, sizeof(fName), "%s", name); | |||
| } | |||
| @@ -148,7 +149,8 @@ struct JackClientCheckRequest : public JackRequest | |||
| { | |||
| CheckRes(trans->Read(&fName, sizeof(fName))); | |||
| CheckRes(trans->Read(&fProtocol, sizeof(int))); | |||
| return trans->Read(&fOptions, sizeof(int)); | |||
| CheckRes(trans->Read(&fOptions, sizeof(int))); | |||
| return trans->Read(&fUUID, sizeof(int)); | |||
| } | |||
| int Write(JackChannelTransaction* trans) | |||
| @@ -156,7 +158,8 @@ struct JackClientCheckRequest : public JackRequest | |||
| CheckRes(JackRequest::Write(trans)); | |||
| CheckRes(trans->Write(&fName, sizeof(fName))); | |||
| CheckRes(trans->Write(&fProtocol, sizeof(int))); | |||
| return trans->Write(&fOptions, sizeof(int)); | |||
| CheckRes(trans->Write(&fOptions, sizeof(int))); | |||
| return trans->Write(&fUUID, sizeof(int)); | |||
| } | |||
| }; | |||
| @@ -51,7 +51,7 @@ int JackSocketClientChannel::ServerCheck(const char* server_name) | |||
| } | |||
| } | |||
| 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, int uuid, char* name_res, JackClient* obj, jack_options_t options, jack_status_t* status) | |||
| { | |||
| int result = 0; | |||
| jack_log("JackSocketClientChannel::Open name = %s", name); | |||
| @@ -62,7 +62,7 @@ int JackSocketClientChannel::Open(const char* server_name, const char* name, cha | |||
| } | |||
| // Check name in server | |||
| ClientCheck(name, name_res, JACK_PROTOCOL_VERSION, (int)options, (int*)status, &result); | |||
| ClientCheck(name, uuid, name_res, JACK_PROTOCOL_VERSION, (int)options, (int*)status, &result); | |||
| if (result < 0) { | |||
| int status1 = *status; | |||
| if (status1 & JackVersionError) | |||
| @@ -142,9 +142,9 @@ 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, int uuid, char* name_res, int protocol, int options, int* status, int* result) | |||
| { | |||
| JackClientCheckRequest req(name, protocol, options); | |||
| JackClientCheckRequest req(name, protocol, options, uuid); | |||
| JackClientCheckResult res; | |||
| ServerSyncCall(&req, &res, result); | |||
| *status = res.fStatus; | |||
| @@ -52,7 +52,7 @@ class JackSocketClientChannel : public detail::JackClientChannelInterface, publi | |||
| JackSocketClientChannel(); | |||
| virtual ~JackSocketClientChannel(); | |||
| int Open(const char* server_name, const char* name, char* name_res, JackClient* obj, jack_options_t options, jack_status_t* status); | |||
| int Open(const char* server_name, const char* name, int uuid, char* name_res, JackClient* obj, jack_options_t options, jack_status_t* status); | |||
| void Close(); | |||
| int Start(); | |||
| @@ -60,7 +60,7 @@ class JackSocketClientChannel : public detail::JackClientChannelInterface, publi | |||
| int ServerCheck(const char* server_name); | |||
| void ClientCheck(const char* name, char* name_res, int protocol, int options, int* status, int* result); | |||
| void ClientCheck(const char* name, int uuid, char* name_res, int protocol, int options, int* status, int* result); | |||
| void ClientOpen(const char* name, int pid, int uuid, int* shared_engine, int* shared_client, int* shared_graph, int* result); | |||
| void ClientOpen(const char* name, int* ref, int uuid, JackEngineControl** shared_engine, JackGraphManager** shared_manager, JackClientInterface* client, int* result) | |||
| {} | |||
| @@ -176,7 +176,7 @@ bool JackSocketServerChannel::HandleRequest(int fd) | |||
| JackClientCheckRequest req; | |||
| JackClientCheckResult res; | |||
| if (req.Read(socket) == 0) | |||
| res.fResult = fServer->GetEngine()->ClientCheck(req.fName, res.fName, req.fProtocol, req.fOptions, &res.fStatus); | |||
| res.fResult = fServer->GetEngine()->ClientCheck(req.fName, req.fUUID, res.fName, req.fProtocol, req.fOptions, &res.fStatus); | |||
| if (res.Write(socket) < 0) | |||
| jack_error("JackRequest::ClientCheck write error name = %s", req.fName); | |||
| break; | |||