Commit 248d1f16 authored by Stephane Letz's avatar Stephane Letz
Browse files

Session API for internal clients in progress.

parent 94eea6f4
......@@ -966,11 +966,11 @@ void JackEngine::SessionNotify(int refnum, const char *target, jack_session_even
}
char path_buf[JACK_PORT_NAME_SIZE];
snprintf( path_buf, sizeof(path_buf), "%s%s%c", path, client->GetClientControl()->fName, DIR_SEPARATOR );
snprintf(path_buf, sizeof(path_buf), "%s%s%c", path, client->GetClientControl()->fName, DIR_SEPARATOR);
int res = JackTools::MkDir(path_buf);
if (res)
jack_error( "JackEngine::SessionNotify: can not create session directory '%s'", path_buf );
jack_error("JackEngine::SessionNotify: can not create session directory '%s'", path_buf);
int result = client->ClientNotify(i, client->GetClientControl()->fName, kSessionCallback, true, path_buf, (int) type, 0);
......@@ -978,11 +978,11 @@ void JackEngine::SessionNotify(int refnum, const char *target, jack_session_even
fSessionPendingReplies += 1;
} else if (result == 1) {
char uuid_buf[JACK_UUID_SIZE];
snprintf( uuid_buf, sizeof(uuid_buf), "%d", client->GetClientControl()->fSessionID );
fSessionResult->fCommandList.push_back( JackSessionCommand( uuid_buf,
client->GetClientControl()->fName,
client->GetClientControl()->fSessionCommand,
client->GetClientControl()->fSessionFlags ));
snprintf(uuid_buf, sizeof(uuid_buf), "%d", client->GetClientControl()->fSessionID);
fSessionResult->fCommandList.push_back(JackSessionCommand(uuid_buf,
client->GetClientControl()->fName,
client->GetClientControl()->fSessionCommand,
client->GetClientControl()->fSessionFlags));
}
}
}
......@@ -1065,7 +1065,7 @@ void JackEngine::ReserveClientName(const char *name, const char *uuid, int *resu
*result = 0;
}
void JackEngine::ClientHasSessionCallbackRequest(const char *name, int *result)
void JackEngine::ClientHasSessionCallback(const char *name, int *result)
{
JackClientInterface* client = NULL;
for (int i = 0; i < CLIENT_NUM; i++) {
......
......@@ -151,7 +151,7 @@ class SERVER_EXPORT JackEngine : public JackLockAble
void GetUUIDForClientName(const char *client_name, char *uuid_res, int *result);
void GetClientNameForUUID(const char *uuid, char *name_res, int *result);
void ReserveClientName(const char *name, const char *uuid, int *result);
void ClientHasSessionCallbackRequest(const char *name, int *result);
void ClientHasSessionCallback(const char *name, int *result);
};
......
......@@ -146,7 +146,34 @@ class JackInternalClientChannel : public detail::JackClientChannelInterface
void SessionNotify(int refnum, const char *target, jack_session_event_type_t type, const char *path, jack_session_command_t** result)
{
*result = NULL;
//*result = fEngine->SessionNotify(refnum, target, type, path, result);
// TODO
}
void SessionReply(int refnum, int* result)
{
fEngine->SessionReply(refnum);
*result = 0;
}
void GetUUIDForClientName(int refnum, const char* client_name, char* uuid_res, int* result)
{
fEngine->GetUUIDForClientName(client_name, uuid_res, result);
}
void GetClientNameForUUID(int refnum, const char* uuid, char* name_res, int* result)
{
fEngine->GetClientNameForUUID(uuid, name_res, result);
}
void ReserveClientName(int refnum, const char* client_name, const char *uuid, int* result)
{
fEngine->ReserveClientName(client_name, uuid, result);
}
void ClientHasSessionCallback(const char* client_name, int* result)
{
fEngine->ClientHasSessionCallback(client_name, result);
}
......
......@@ -363,11 +363,11 @@ class SERVER_EXPORT JackLockedEngine
CATCH_EXCEPTION
}
void ClientHasSessionCallbackRequest(const char *name, int *result)
void ClientHasSessionCallback(const char *name, int *result)
{
TRY_CALL
JackLock lock(&fEngine);
fEngine.ClientHasSessionCallbackRequest(name, result);
fEngine.ClientHasSessionCallback(name, result);
CATCH_EXCEPTION
}
};
......
......@@ -1142,7 +1142,7 @@ struct JackSessionNotifyResult : public JackResult
int Read(JackChannelTransaction* trans)
{
CheckRes(JackResult::Read(trans));
while(1) {
while (true) {
JackSessionCommand buffer;
CheckRes(trans->Read(buffer.fUUID, sizeof(buffer.fUUID)));
......@@ -1164,7 +1164,7 @@ struct JackSessionNotifyResult : public JackResult
terminator[0] = '\0';
CheckRes(JackResult::Write(trans));
for (std::list<JackSessionCommand>::iterator i=fCommandList.begin(); i!=fCommandList.end(); i++) {
for (std::list<JackSessionCommand>::iterator i = fCommandList.begin(); i != fCommandList.end(); i++) {
CheckRes(trans->Write(i->fUUID, sizeof(i->fUUID)));
CheckRes(trans->Write(i->fClientName, sizeof(i->fClientName)));
CheckRes(trans->Write(i->fCommand, sizeof(i->fCommand)));
......
......@@ -262,10 +262,10 @@ void JackSocketClientChannel::SessionNotify(int refnum, const char* target, jack
jack_session_command_t* session_command = (jack_session_command_t *)malloc(sizeof(jack_session_command_t) * (res.fCommandList.size() + 1));
int i = 0;
for (std::list<JackSessionCommand>::iterator ci=res.fCommandList.begin(); ci!=res.fCommandList.end(); ci++) {
session_command[i].uuid = strdup( ci->fUUID );
session_command[i].client_name = strdup( ci->fClientName );
session_command[i].command = strdup( ci->fCommand );
for (std::list<JackSessionCommand>::iterator ci = res.fCommandList.begin(); ci != res.fCommandList.end(); ci++) {
session_command[i].uuid = strdup(ci->fUUID);
session_command[i].client_name = strdup(ci->fClientName);
session_command[i].command = strdup(ci->fCommand);
session_command[i].flags = ci->fFlags;
i += 1;
}
......
......@@ -487,7 +487,7 @@ bool JackSocketServerChannel::HandleRequest(int fd)
JackClientHasSessionCallbackRequest req;
JackResult res;
if (req.Read(socket) == 0) {
fServer->GetEngine()->ClientHasSessionCallbackRequest(req.fName, &res.fResult);
fServer->GetEngine()->ClientHasSessionCallback(req.fName, &res.fResult);
}
if (res.Write(socket) < 0)
jack_error("JackRequest::ClientHasSessionCallback write error");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment