git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@1585 0c269be4-1314-0410-8aa9-9f06e86f4224tags/0.67
@@ -13,6 +13,10 @@ Tom Szilagyi | |||
Jackdmp changes log | |||
--------------------------- | |||
2007-10-12 Stephane Letz <letz@grame.fr> | |||
* Internal loadable client implementation, socket version added. | |||
2007-10-11 Stephane Letz <letz@grame.fr> | |||
* Internal loadable client implementation (in progress). | |||
@@ -1431,8 +1431,11 @@ EXPORT char* jack_get_internal_client_name(jack_client_t* ext_client, jack_intcl | |||
JackClient* client = (JackClient*)ext_client; | |||
if (client == NULL) { | |||
jack_error("jack_get_internal_client_name called with a NULL client"); | |||
return ""; | |||
} else { | |||
return NULL; | |||
} else if (intclient < 0 || intclient >= CLIENT_NUM) { | |||
jack_error("jack_get_internal_client_name: incorrect client"); | |||
return NULL; | |||
} else { | |||
return client->GetInternalClientName(intclient); | |||
} | |||
} | |||
@@ -1498,7 +1501,10 @@ EXPORT jack_status_t jack_internal_client_unload(jack_client_t* ext_client, jack | |||
if (client == NULL) { | |||
jack_error("jack_internal_client_unload called with a NULL client"); | |||
return (jack_status_t)(JackNoSuchClient | JackFailure); | |||
} else { | |||
} else if (intclient < 0 || intclient >= CLIENT_NUM) { | |||
jack_error("jack_internal_client_unload: incorrect client"); | |||
return (jack_status_t)(JackNoSuchClient | JackFailure); | |||
} else { | |||
jack_status_t my_status; | |||
client->InternalClientUnload(intclient, &my_status); | |||
return my_status; | |||
@@ -826,8 +826,17 @@ int JackClient::SetPortRegistrationCallback(JackPortRegistrationCallback callbac | |||
char* JackClient::GetInternalClientName(int ref) | |||
{ | |||
// TODO | |||
return ""; | |||
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) | |||
@@ -377,9 +377,10 @@ void JackEngine::NotifyActivate(int refnum) | |||
// Loadable client management | |||
//---------------------------- | |||
int JackEngine::GetInternalClientName(int int_ref, char* name_res) | |||
int JackEngine::GetInternalClientName(int refnum, char* name_res) | |||
{ | |||
JackClientInterface* client = fClientTable[int_ref]; | |||
assert(refnum >= 0 && refnum < CLIENT_NUM); | |||
JackClientInterface* client = fClientTable[refnum]; | |||
if (client) { | |||
strncpy(name_res, client->GetClientControl()->fName, JACK_CLIENT_NAME_SIZE); | |||
return 0; | |||
@@ -408,6 +409,7 @@ int JackEngine::InternalClientHandle(const char* client_name, int* status, int* | |||
int JackEngine::InternalClientUnload(int refnum, int* status) | |||
{ | |||
assert(refnum >= 0 && refnum < CLIENT_NUM); | |||
JackClientInterface* client = fClientTable[refnum]; | |||
if (client) { | |||
int res = client->Close(); | |||
@@ -62,8 +62,12 @@ struct JackRequest | |||
kClientClose = 24, | |||
kConnectNamePorts = 25, | |||
kDisconnectNamePorts = 26, | |||
kGetInternalClientName = 27, | |||
kInternalClientHandle = 28, | |||
kInternalClientLoad = 29, | |||
kInternalClientUnload = 30, | |||
kNotification = 27 | |||
kNotification = 31 | |||
}; | |||
RequestType fType; | |||
@@ -129,7 +133,7 @@ struct JackClientCheckRequest : public JackRequest | |||
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); | |||
} | |||
@@ -685,6 +689,272 @@ struct JackSetTimebaseCallbackRequest : public JackRequest | |||
} | |||
}; | |||
/*! | |||
\brief GetInternalClientName request. | |||
*/ | |||
struct JackGetInternalClientNameRequest : public JackRequest | |||
{ | |||
int fRefNum; | |||
int fIntRefNum; | |||
JackGetInternalClientNameRequest() | |||
{} | |||
JackGetInternalClientNameRequest(int refnum, int int_ref) | |||
: JackRequest(JackRequest::kGetInternalClientName),fRefNum(refnum),fIntRefNum(int_ref) | |||
{} | |||
int Read(JackChannelTransaction* trans) | |||
{ | |||
CheckRes(trans->Read(&fRefNum, sizeof(int))); | |||
return trans->Read(&fIntRefNum, sizeof(int)); | |||
} | |||
int Write(JackChannelTransaction* trans) | |||
{ | |||
CheckRes(JackRequest::Write(trans)); | |||
CheckRes(trans->Write(&fRefNum, sizeof(int))); | |||
return trans->Write(&fIntRefNum, sizeof(int)); | |||
} | |||
}; | |||
/*! | |||
\brief GetInternalClient result. | |||
*/ | |||
struct JackGetInternalClientResult : public JackResult | |||
{ | |||
char fName[JACK_CLIENT_NAME_SIZE + 1]; | |||
JackGetInternalClientResult():JackResult() | |||
{} | |||
JackGetInternalClientResult(int32_t result, const char* name) | |||
: JackResult(result) | |||
{ | |||
snprintf(fName, sizeof(fName), "%s", name); | |||
} | |||
int Read(JackChannelTransaction* trans) | |||
{ | |||
CheckRes(JackResult::Read(trans)); | |||
CheckRes(trans->Read(&fName, JACK_CLIENT_NAME_SIZE + 1)); | |||
return 0; | |||
} | |||
int Write(JackChannelTransaction* trans) | |||
{ | |||
CheckRes(JackResult::Write(trans)); | |||
CheckRes(trans->Write(&fName, JACK_CLIENT_NAME_SIZE + 1)); | |||
return 0; | |||
} | |||
}; | |||
/*! | |||
\brief InternalClientHandle request. | |||
*/ | |||
struct JackInternalClientHandleRequest : public JackRequest | |||
{ | |||
int fRefNum; | |||
char fName[JACK_CLIENT_NAME_SIZE + 1]; | |||
JackInternalClientHandleRequest() | |||
{} | |||
JackInternalClientHandleRequest(int refnum, const char* client_name) | |||
: JackRequest(JackRequest::kInternalClientHandle),fRefNum(refnum) | |||
{ | |||
snprintf(fName, sizeof(fName), "%s", client_name); | |||
} | |||
int Read(JackChannelTransaction* trans) | |||
{ | |||
CheckRes(trans->Read(&fRefNum, sizeof(int))); | |||
return trans->Read(&fName, JACK_CLIENT_NAME_SIZE + 1); | |||
} | |||
int Write(JackChannelTransaction* trans) | |||
{ | |||
CheckRes(JackRequest::Write(trans)); | |||
CheckRes(trans->Write(&fRefNum, sizeof(int))); | |||
return trans->Write(&fName, JACK_CLIENT_NAME_SIZE + 1); | |||
} | |||
}; | |||
/*! | |||
\brief InternalClientHandle result. | |||
*/ | |||
struct JackInternalClientHandleResult : public JackResult | |||
{ | |||
int fStatus; | |||
int fIntRefNum; | |||
JackInternalClientHandleResult():JackResult() | |||
{} | |||
JackInternalClientHandleResult(int32_t result, int status, int int_ref) | |||
: JackResult(result),fStatus(status),fIntRefNum(int_ref) | |||
{} | |||
int Read(JackChannelTransaction* trans) | |||
{ | |||
CheckRes(JackResult::Read(trans)); | |||
CheckRes(trans->Read(&fStatus, sizeof(int))); | |||
CheckRes(trans->Read(&fIntRefNum, sizeof(int))); | |||
return 0; | |||
} | |||
int Write(JackChannelTransaction* trans) | |||
{ | |||
CheckRes(JackResult::Write(trans)); | |||
CheckRes(trans->Write(&fStatus, sizeof(int))); | |||
CheckRes(trans->Write(&fIntRefNum, sizeof(int))); | |||
return 0; | |||
} | |||
}; | |||
/*! | |||
\brief InternalClientLoad request. | |||
*/ | |||
struct JackInternalClientLoadRequest : public JackRequest | |||
{ | |||
#define MAX_PATH 256 | |||
int fRefNum; | |||
char fName[JACK_CLIENT_NAME_SIZE + 1]; | |||
char fDllName[MAX_PATH + 1]; | |||
char fLoadInitName[JACK_LOAD_INIT_LIMIT + 1]; | |||
int fOptions; | |||
JackInternalClientLoadRequest() | |||
{} | |||
JackInternalClientLoadRequest(int refnum, const char* client_name, const char* so_name, const char* objet_data, int 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); | |||
} | |||
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)); | |||
} | |||
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)); | |||
} | |||
}; | |||
/*! | |||
\brief InternalClientLoad result. | |||
*/ | |||
struct JackInternalClientLoadResult : public JackResult | |||
{ | |||
int fStatus; | |||
int fIntRefNum; | |||
JackInternalClientLoadResult():JackResult() | |||
{} | |||
JackInternalClientLoadResult(int32_t result, int status, int int_ref) | |||
: JackResult(result),fStatus(status),fIntRefNum(int_ref) | |||
{} | |||
int Read(JackChannelTransaction* trans) | |||
{ | |||
CheckRes(JackResult::Read(trans)); | |||
CheckRes(trans->Read(&fStatus, sizeof(int))); | |||
CheckRes(trans->Read(&fIntRefNum, sizeof(int))); | |||
return 0; | |||
} | |||
int Write(JackChannelTransaction* trans) | |||
{ | |||
CheckRes(JackResult::Write(trans)); | |||
CheckRes(trans->Write(&fStatus, sizeof(int))); | |||
CheckRes(trans->Write(&fIntRefNum, sizeof(int))); | |||
return 0; | |||
} | |||
}; | |||
/*! | |||
\brief InternalClientUnload request. | |||
*/ | |||
struct JackInternalClientUnloadRequest : public JackRequest | |||
{ | |||
int fRefNum; | |||
int fIntRefNum; | |||
JackInternalClientUnloadRequest() | |||
{} | |||
JackInternalClientUnloadRequest(int refnum, int int_ref) | |||
: JackRequest(JackRequest::kInternalClientUnload),fRefNum(refnum),fIntRefNum(int_ref) | |||
{} | |||
int Read(JackChannelTransaction* trans) | |||
{ | |||
CheckRes(trans->Read(&fRefNum, sizeof(int))); | |||
return trans->Read(&fIntRefNum, sizeof(int)); | |||
} | |||
int Write(JackChannelTransaction* trans) | |||
{ | |||
CheckRes(JackRequest::Write(trans)); | |||
CheckRes(trans->Write(&fRefNum, sizeof(int))); | |||
return trans->Write(&fIntRefNum, sizeof(int)); | |||
} | |||
}; | |||
/*! | |||
\brief InternalClientLoad result. | |||
*/ | |||
struct JackInternalClientUnloadResult : public JackResult | |||
{ | |||
int fStatus; | |||
JackInternalClientUnloadResult():JackResult() | |||
{} | |||
JackInternalClientUnloadResult(int32_t result, int status) | |||
: JackResult(result),fStatus(status) | |||
{} | |||
int Read(JackChannelTransaction* trans) | |||
{ | |||
CheckRes(JackResult::Read(trans)); | |||
CheckRes(trans->Read(&fStatus, sizeof(int))); | |||
return 0; | |||
} | |||
int Write(JackChannelTransaction* trans) | |||
{ | |||
CheckRes(JackResult::Write(trans)); | |||
CheckRes(trans->Write(&fStatus, sizeof(int))); | |||
return 0; | |||
} | |||
}; | |||
/*! | |||
\brief ClientNotification request. | |||
*/ | |||
@@ -250,6 +250,40 @@ void JackSocketClientChannel::SetTimebaseCallback(int refnum, int conditional, i | |||
ServerSyncCall(&req, &res, result); | |||
} | |||
void JackSocketClientChannel::GetInternalClientName(int refnum, int int_ref, char* name_res, int* result) | |||
{ | |||
JackGetInternalClientNameRequest req(refnum, int_ref); | |||
JackGetInternalClientResult res; | |||
ServerSyncCall(&req, &res, result); | |||
strcpy(name_res, res.fName); | |||
} | |||
void JackSocketClientChannel::InternalClientHandle(int refnum, const char* client_name, int* status, int* int_ref, int* result) | |||
{ | |||
JackInternalClientHandleRequest req(refnum, client_name); | |||
JackInternalClientHandleResult res; | |||
ServerSyncCall(&req, &res, result); | |||
*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) | |||
{ | |||
JackInternalClientLoadRequest req(refnum, client_name, so_name, objet_data, options); | |||
JackInternalClientLoadResult res; | |||
ServerSyncCall(&req, &res, result); | |||
*int_ref = res.fIntRefNum; | |||
*status = res.fStatus; | |||
} | |||
void JackSocketClientChannel::InternalClientUnload(int refnum, int int_ref, int* status, int* result) | |||
{ | |||
JackInternalClientUnloadRequest req(refnum, int_ref); | |||
JackInternalClientUnloadResult res; | |||
ServerSyncCall(&req, &res, result); | |||
*status = res.fStatus; | |||
} | |||
bool JackSocketClientChannel::Init() | |||
{ | |||
JackLog("JackSocketClientChannel::Init \n"); | |||
@@ -80,7 +80,12 @@ class JackSocketClientChannel : public JackClientChannelInterface, public JackRu | |||
void ReleaseTimebase(int refnum, int* result); | |||
void SetTimebaseCallback(int refnum, int conditional, 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 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); | |||
// JackRunnableInterface interface | |||
bool Init(); | |||
bool Execute(); | |||
@@ -151,6 +151,12 @@ main (int argc, char *argv[]) | |||
} | |||
fprintf (stdout, "%s is running.\n", load_name); | |||
char* name = jack_get_internal_client_name(client, intclient); | |||
if (name) { | |||
printf("client name = %s\n", name); | |||
free(name); | |||
} | |||
if (wait_opt) { | |||
/* define a signal handler to unload the client, then | |||
@@ -188,7 +188,7 @@ rpc_type server_rpc_jack_get_internal_clientname(mach_port_t private_port, int r | |||
JackLog("server_rpc_jack_get_internal_clientname\n"); | |||
JackMachServerChannel* channel = JackMachServerChannel::fPortTable[private_port]; | |||
assert(channel); | |||
//*result = channel->GetServer()->GetEngine()->GetInternalClientName(int_ref, (char*)name_res); | |||
*result = channel->GetServer()->GetEngine()->GetInternalClientName(int_ref, (char*)name_res); | |||
return KERN_SUCCESS; | |||
} | |||
@@ -340,14 +340,14 @@ | |||
isa = PBXContainerItemProxy; | |||
containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */; | |||
proxyType = 1; | |||
remoteGlobalIDString = 4BA692A60CBE4BC700EAD520 /* jack_load Universal */; | |||
remoteGlobalIDString = 4BA692A60CBE4BC700EAD520; | |||
remoteInfo = "jack_load Universal"; | |||
}; | |||
4BA693EA0CBE5BBA00EAD520 /* PBXContainerItemProxy */ = { | |||
isa = PBXContainerItemProxy; | |||
containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */; | |||
proxyType = 1; | |||
remoteGlobalIDString = 4BA692CA0CBE4C9000EAD520 /* jack_unload Universal */; | |||
remoteGlobalIDString = 4BA692CA0CBE4C9000EAD520; | |||
remoteInfo = "jack_unload Universal"; | |||
}; | |||
4BD624D20CBCF55700DE782F /* PBXContainerItemProxy */ = { | |||