Commit bb25e2e7 authored by sletz's avatar sletz
Browse files

Cleanup, renaming

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@1380 0c269be4-1314-0410-8aa9-9f06e86f4224
parent 4f6b91c4
......@@ -67,9 +67,9 @@ class JackClientChannelInterface
virtual void Stop()
{}
virtual void ClientNew(const char* name, int* shared_engine, int* shared_client, int* shared_graph, int* result)
virtual void ClientOpen(const char* name, int* shared_engine, int* shared_client, int* shared_graph, int* result)
{}
virtual void ClientNew(const char* name, int* ref, JackEngineControl** shared_engine, JackGraphManager** shared_manager, JackClientInterface* client, int* result)
virtual void ClientOpen(const char* name, int* ref, JackEngineControl** shared_engine, JackGraphManager** shared_manager, JackClientInterface* client, int* result)
{}
virtual void ClientClose(int refnum, int* result)
{}
......
......@@ -70,12 +70,7 @@ int JackDriver::Open()
{
int refnum = -1;
if (fEngine->ClientCheckName(fClientControl->fName)) {
jack_error("client %s already registered", fClientControl->fName);
return -1;
}
if (fEngine->ClientInternalNew(fClientControl->fName, &refnum, &fEngineControl, &fGraphManager, this) != 0) {
if (fEngine->ClientInternalOpen(fClientControl->fName, &refnum, &fEngineControl, &fGraphManager, this) != 0) {
jack_error("Cannot allocate internal client for audio driver");
return -1;
}
......@@ -112,12 +107,7 @@ int JackDriver::Open(jack_nframes_t nframes,
JackLog("JackDriver::Open playback_driver_name = %s\n", playback_driver_name);
int refnum = -1;
if (fEngine->ClientCheckName(fClientControl->fName)) {
jack_error("client %s already registered", fClientControl->fName);
return -1;
}
if (fEngine->ClientInternalNew(fClientControl->fName, &refnum, &fEngineControl, &fGraphManager, this) != 0) {
if (fEngine->ClientInternalOpen(fClientControl->fName, &refnum, &fEngineControl, &fGraphManager, this) != 0) {
jack_error("Cannot allocate internal client for audio driver");
return -1;
}
......
......@@ -35,22 +35,12 @@ namespace Jack
JackEngine::JackEngine(JackGraphManager* manager,
JackSynchro** table,
JackEngineControl* control,
bool sync,
long time_out_ms,
bool rt,
long priority,
bool ve)
JackEngineControl* control)
{
fGraphManager = manager;
fSynchroTable = table;
fEngineControl = control;
fEngineControl->fSyncMode = sync;
fEngineControl->fTimeOutUsecs = time_out_ms * 1000;
fEngineControl->fRealTime = rt;
fEngineControl->fPriority = priority;
fEngineControl->fVerbose = ve;
fChannel = JackGlobals::MakeServerNotifyChannel();
fChannel = JackGlobals::MakeServerNotifyChannel();
fSignal = JackGlobals::MakeInterProcessSync();
fEngineTiming = new JackEngineTiming(fClientTable, fGraphManager, fEngineControl);
for (int i = 0; i < CLIENT_NUM; i++)
......@@ -366,32 +356,22 @@ bool JackEngine::ClientCheckName(const char* name)
}
// Used for external clients
int JackEngine::ClientNew(const char* name, int* ref, int* shared_engine, int* shared_client, int* shared_graph_manager)
int JackEngine::ClientExternalOpen(const char* name, int* ref, int* shared_engine, int* shared_client, int* shared_graph_manager)
{
if (ClientCheckName(name)) {
JackLog("JackEngine::ClientOpen: name = %s \n", name);
if (ClientCheckName(name)) {
jack_error("client %s already registered", name);
return -1;
}
JackExternalClient* client = new JackExternalClient();
if (ClientExternalNew(name, ref, shared_engine, shared_client, shared_graph_manager, client) < 0) {
delete client;
return -1;
}
return 0;
}
// Used for external clients
int JackEngine::ClientExternalNew(const char* name, int* ref, int* shared_engine, int* shared_client, int* shared_graph_manager, JackExternalClient* client)
{
JackLog("JackEngine::ClientNew: name = %s \n", name);
int refnum = Allocate();
if (refnum < 0) {
jack_error("No more refnum available");
return -1;
}
JackExternalClient* client = new JackExternalClient();
if (!fSynchroTable[refnum]->Allocate(name, 0)) {
jack_error("Cannot allocate synchro");
......@@ -425,16 +405,22 @@ int JackEngine::ClientExternalNew(const char* name, int* ref, int* shared_engine
error:
ClientCloseAux(refnum, client, false);
client->Close();
delete client;
return -1;
}
// Used for server driver clients
int JackEngine::ClientInternalNew(const char* name, int* ref, JackEngineControl** shared_engine, JackGraphManager** shared_manager, JackClientInterface* client)
int JackEngine::ClientInternalOpen(const char* name, int* ref, JackEngineControl** shared_engine, JackGraphManager** shared_manager, JackClientInterface* client)
{
JackLog("JackEngine::ClientInternalNew: name = %s\n", name);
if (ClientCheckName(name)) {
jack_error("client %s already registered", name);
return -1;
}
int refnum = Allocate();
if (refnum < 0) {
if (refnum < 0) {
jack_error("No more refnum available");
return -1;
}
......@@ -459,7 +445,7 @@ int JackEngine::ClientInternalNew(const char* name, int* ref, JackEngineControl*
}
// Used for externall clients
int JackEngine::ClientClose(int refnum)
int JackEngine::ClientExternalClose(int refnum)
{
JackClientInterface* client = fClientTable[refnum];
if (client) {
......
......@@ -61,23 +61,23 @@ class JackEngine
void GetZombifiedClients(bool clients[CLIENT_NUM], jack_time_t current_time);
void ProcessNext(jack_time_t callback_usecs);
void ProcessCurrent(jack_time_t callback_usecs);
bool ClientCheckName(const char* name);
int Allocate();
public:
JackEngine(JackGraphManager* manager, JackSynchro** table, JackEngineControl* control, bool sync, long time_out_ms, bool rt, long priority, bool verbose);
JackEngine(JackGraphManager* manager, JackSynchro** table, JackEngineControl* controler);
virtual ~JackEngine();
int Open();
int Close();
int Allocate();
// Client management
bool ClientCheckName(const char* name);
int ClientNew(const char* name, int* refnum, int* shared_engine, int* shared_client, int* shared_graph_manager);
int ClientExternalNew(const char* name, int* ref, int* shared_engine, int* shared_client, int* shared_graph_manager, JackExternalClient* client);
int ClientInternalNew(const char* name, int* ref, JackEngineControl** shared_engine, JackGraphManager** shared_manager, JackClientInterface* client);
int ClientExternalOpen(const char* name, 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);
int ClientClose(int refnum);
int ClientExternalClose(int refnum);
int ClientInternalClose(int refnum);
int ClientInternalCloseIm(int refnum);
......
......@@ -37,19 +37,27 @@ struct JackEngineControl : public JackShmMem
{
jack_nframes_t fBufferSize;
jack_nframes_t fSampleRate;
bool fRealTime;
int32_t fPriority;
float fCPULoad;
bool fSyncMode;
jack_time_t fPeriodUsecs;
jack_time_t fTimeOutUsecs;
bool fRealTime;
int32_t fPriority;
UInt64 fPeriod;
UInt64 fComputation;
UInt64 fConstraint;
JackFrameTimer fFrameTimer;
JackTransportEngine fTransport;
bool fSyncMode;
bool fVerbose;
JackEngineControl(bool sync, long timeout, bool rt, long priority, bool verbose)
:fSyncMode(sync),
fTimeOutUsecs(timeout * 1000),
fRealTime(rt),
fPriority(priority),
fVerbose(verbose)
{}
void InitFrameTime()
{
fFrameTimer.InitFrameTime();
......
......@@ -72,7 +72,7 @@ int JackInternalClient::Open(const char* name)
strcpy(fClientControl->fName, name);
// Require new client
fChannel->ClientNew(name, &fClientControl->fRefNum, &fEngineControl, &fGraphManager, this, &result);
fChannel->ClientOpen(name, &fClientControl->fRefNum, &fEngineControl, &fGraphManager, this, &result);
if (result < 0) {
jack_error("Cannot open client name = %s", name);
goto error;
......
......@@ -44,9 +44,9 @@ class JackInternalClientChannel : public JackClientChannelInterface
virtual ~JackInternalClientChannel()
{}
void ClientNew(const char* name, int* ref, JackEngineControl** shared_engine, JackGraphManager** shared_manager, JackClientInterface* client, int* result)
void ClientOpen(const char* name, int* ref, JackEngineControl** shared_engine, JackGraphManager** shared_manager, JackClientInterface* client, int* result)
{
*result = fEngine->ClientInternalNew(name, ref, shared_engine, shared_manager, client);
*result = fEngine->ClientInternalOpen(name, ref, shared_engine, shared_manager, client);
}
void ClientClose(int refnum, int* result)
{
......
......@@ -79,7 +79,7 @@ int JackLibClient::Open(const char* name)
}
// Require new client
fChannel->ClientNew(name, &shared_engine, &shared_client, &shared_graph, &result);
fChannel->ClientOpen(name, &shared_engine, &shared_client, &shared_graph, &result);
if (result < 0) {
jack_error("Cannot open %s client", name);
goto error;
......
......@@ -59,7 +59,7 @@ public:
kSetBufferSize = 20,
kSetFreeWheel = 21,
kClientNew = 22,
kClientOpen = 22,
kClientClose = 23,
kConnectNamePorts = 24,
kDisconnectNamePorts = 25,
......@@ -121,14 +121,14 @@ struct JackResult
\brief NewClient request.
*/
struct JackClientNewRequest : public JackRequest
struct JackClientOpenRequest : public JackRequest
{
char fName[JACK_CLIENT_NAME_SIZE + 1];
JackClientNewRequest()
JackClientOpenRequest()
{}
JackClientNewRequest(const char* name): JackRequest(JackRequest::kClientNew)
JackClientOpenRequest(const char* name): JackRequest(JackRequest::kClientOpen)
{
snprintf(fName, sizeof(fName), "%s", name);
}
......@@ -149,7 +149,7 @@ struct JackClientNewRequest : public JackRequest
\brief NewClient result.
*/
struct JackClientNewResult : public JackResult
struct JackClientOpenResult : public JackResult
{
int fSharedEngine;
......@@ -157,10 +157,10 @@ struct JackClientNewResult : public JackResult
int fSharedGraph;
uint32_t fProtocolVersion;
JackClientNewResult()
JackClientOpenResult()
:fSharedEngine(-1), fSharedClient(-1), fSharedGraph(-1), fProtocolVersion(0)
{}
JackClientNewResult(int32_t status, int index1, int index2, int index3)
JackClientOpenResult(int32_t status, int index1, int index2, int index3)
: JackResult(status), fSharedEngine(index1), fSharedClient(index2), fSharedGraph(index3), fProtocolVersion(0)
{}
......
......@@ -51,14 +51,13 @@ JackServer::JackServer(bool sync, long timeout, bool rt, long priority, long loo
for (int i = 0; i < CLIENT_NUM; i++)
fSynchroTable[i] = JackGlobals::MakeSynchro();
fGraphManager = new JackGraphManager();
fEngineControl = new JackEngineControl();
fEngine = new JackEngine(fGraphManager, fSynchroTable, fEngineControl, sync, timeout, rt, priority, verbose);
fEngineControl = new JackEngineControl(sync, timeout, rt, priority, verbose);
fEngine = new JackEngine(fGraphManager, fSynchroTable, fEngineControl);
fFreewheelDriver = new JackThreadedDriver(new JackFreewheelDriver("freewheel", fEngine, fSynchroTable));
fLoopbackDriver = new JackLoopbackDriver("loopback", fEngine, fSynchroTable);
fChannel = JackGlobals::MakeServerChannel();
fState = new JackConnectionManager();
fFreewheel = false;
fSyncMode = sync;
fFreewheel = false;
fLoopback = loopback;
fDriverInfo = NULL;
fAudioDriver = NULL;
......@@ -272,7 +271,7 @@ void JackServer::Notify(int refnum, int notify, int value)
JackLog("JackServer: kDeadClient ref = %ld\n", refnum);
if (fEngine->ClientDeactivate(refnum) < 0)
jack_error("JackServer: DeadClient ref = %ld cannot be removed from the graph !!", refnum);
fEngine->ClientClose(refnum);
fEngine->ClientExternalClose(refnum);
break;
}
}
......
......@@ -55,9 +55,7 @@ class EXPORT JackServer
JackGraphManager* fGraphManager;
JackServerChannelInterface* fChannel;
JackConnectionManager* fState;
JackSynchro* fSynchroTable[CLIENT_NUM];
bool fSyncMode;
JackSynchro* fSynchroTable[CLIENT_NUM];
bool fFreewheel;
long fLoopback;
......
......@@ -113,10 +113,10 @@ void JackSocketClientChannel::ServerAsyncCall(JackRequest* req, JackResult* res,
}
}
void JackSocketClientChannel::ClientNew(const char* name, int* shared_engine, int* shared_client, int* shared_graph, int* result)
void JackSocketClientChannel::ClientOpen(const char* name, int* shared_engine, int* shared_client, int* shared_graph, int* result)
{
JackClientNewRequest req(name);
JackClientNewResult res;
JackClientOpenRequest req(name);
JackClientOpenResult res;
ServerSyncCall(&req, &res, result);
*shared_engine = res.fSharedEngine;
*shared_client = res.fSharedClient;
......
......@@ -57,7 +57,7 @@ class JackSocketClientChannel : public JackClientChannelInterface, public JackRu
int Start();
void Stop();
void ClientNew(const char* name, int* shared_engine, int* shared_client, int* shared_graph, int* result);
void ClientOpen(const char* name, int* shared_engine, int* shared_client, int* shared_graph, int* result);
void ClientClose(int refnum, int* result);
void ClientActivate(int refnum, int* result);
......
......@@ -92,7 +92,7 @@ void JackSocketServerChannel::AddClient(int fd, char* name, int* shared_engine,
{
JackLog("JackSocketServerChannel::AddClient\n");
int refnum = -1;
*result = fServer->GetEngine()->ClientNew(name, &refnum, shared_engine, shared_client, shared_graph);
*result = fServer->GetEngine()->ClientExternalOpen(name, &refnum, shared_engine, shared_client, shared_graph);
if (*result == 0) {
fSocketTable[fd].first = refnum;
fRebuild = true;
......@@ -150,10 +150,10 @@ int JackSocketServerChannel::HandleRequest(int fd)
// Read data
switch (header.fType) {
case JackRequest::kClientNew: {
JackLog("JackRequest::ClientNew\n");
JackClientNewRequest req;
JackClientNewResult res;
case JackRequest::kClientOpen: {
JackLog("JackRequest::ClientOpen\n");
JackClientOpenRequest req;
JackClientOpenResult res;
if (req.Read(socket) == 0)
AddClient(fd, req.fName, &res.fSharedEngine, &res.fSharedClient, &res.fSharedGraph, &res.fResult);
res.Write(socket);
......@@ -165,7 +165,7 @@ int JackSocketServerChannel::HandleRequest(int fd)
JackClientCloseRequest req;
JackResult res;
if (req.Read(socket) == 0)
res.fResult = fServer->GetEngine()->ClientClose(req.fRefNum);
res.fResult = fServer->GetEngine()->ClientExternalClose(req.fRefNum);
res.Write(socket);
RemoveClient(fd, req.fRefNum);
break;
......@@ -176,7 +176,6 @@ int JackSocketServerChannel::HandleRequest(int fd)
JackResult res;
JackLog("JackRequest::ActivateClient\n");
if (req.Read(socket) == 0)
//res.fResult = fServer->Activate(req.fRefNum);
res.fResult = fServer->GetEngine()->ClientActivate(req.fRefNum);
res.Write(socket);
break;
......@@ -187,7 +186,6 @@ int JackSocketServerChannel::HandleRequest(int fd)
JackDeactivateRequest req;
JackResult res;
if (req.Read(socket) == 0)
//res.fResult = fServer->Deactivate(req.fRefNum);
res.fResult = fServer->GetEngine()->ClientDeactivate(req.fRefNum);
res.Write(socket);
break;
......
......@@ -31,7 +31,7 @@ using namespace Jack;
#define rpc_type kern_return_t // for astyle
rpc_type server_rpc_jack_client_new(mach_port_t server_port, client_name_t name, mach_port_t* private_port, int* shared_engine, int* shared_client, int* shared_graph, int* result)
rpc_type server_rpc_jack_client_open(mach_port_t server_port, client_name_t name, mach_port_t* private_port, int* shared_engine, int* shared_client, int* shared_graph, int* result)
{
JackLog("rpc_jack_client_new %s\n", name);
JackMachServerChannel* channel = JackMachServerChannel::fPortTable[server_port];
......
......@@ -95,12 +95,12 @@ void JackMachClientChannel::Stop()
fThread->Kill();
}
void JackMachClientChannel::ClientNew(const char* name, int* shared_engine, int* shared_client, int* shared_graph, int* result)
void JackMachClientChannel::ClientOpen(const char* name, int* shared_engine, int* shared_client, int* shared_graph, int* result)
{
kern_return_t res = rpc_jack_client_new(fServerPort.GetPort(), (char*)name, &fPrivatePort, shared_engine, shared_client, shared_graph, result);
kern_return_t res = rpc_jack_client_open(fServerPort.GetPort(), (char*)name, &fPrivatePort, shared_engine, shared_client, shared_graph, result);
if (res != KERN_SUCCESS) {
*result = -1;
jack_error("JackMachClientChannel::ClientNew err = %s", mach_error_string(res));
jack_error("JackMachClientChannel::ClientOpen err = %s", mach_error_string(res));
}
}
......
......@@ -54,7 +54,7 @@ class JackMachClientChannel : public JackClientChannelInterface, public JackRunn
int Start();
void Stop();
void ClientNew(const char* name, int* shared_engine, int* shared_client, int* shared_graph, int* result);
void ClientOpen(const char* name, int* shared_engine, int* shared_client, int* shared_graph, int* result);
void ClientClose(int refnum, int* result);
void ClientActivate(int refnum, int* result);
......
......@@ -80,7 +80,7 @@ JackServer* JackMachServerChannel::GetServer()
void JackMachServerChannel::AddClient(char* name, mach_port_t* private_port, int* shared_engine, int* shared_client, int* shared_graph, int* result)
{
int refnum = -1;
*result = GetEngine()->ClientNew(name, &refnum, shared_engine, shared_client, shared_graph);
*result = GetEngine()->ClientExternalOpen(name, &refnum, shared_engine, shared_client, shared_graph);
if (*result == 0) {
mach_port_t port = fServerPort.AddPort();
......@@ -99,7 +99,7 @@ void JackMachServerChannel::AddClient(char* name, mach_port_t* private_port, int
void JackMachServerChannel::RemoveClient(mach_port_t private_port, int refnum)
{
GetEngine()->ClientClose(refnum);
GetEngine()->ClientExternalClose(refnum);
fClientTable.erase(private_port);
// Hum, hum....
......
/*
* IDENTIFICATION:
* stub generated Sat Dec 23 15:21:20 2006
* stub generated Tue Jan 30 00:00:51 2007
* with a MiG generated Mon Sep 11 19:11:05 PDT 2006 by root@b09.apple.com
* OPTIONS:
*/
......
/*
* IDENTIFICATION:
* stub generated Sat Dec 23 15:21:20 2006
* stub generated Tue Jan 30 00:00:51 2007
* with a MiG generated Mon Sep 11 19:11:05 PDT 2006 by root@b09.apple.com
* OPTIONS:
*/
......
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