Browse Source

Version 0.61. Move client allocation in JackEngine

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@1317 0c269be4-1314-0410-8aa9-9f06e86f4224
tags/0.61
sletz 19 years ago
parent
commit
6946740c19
7 changed files with 84 additions and 43 deletions
  1. +18
    -10
      common/JackConnectionManager.cpp
  2. +4
    -3
      common/JackConnectionManager.h
  3. +1
    -1
      common/JackConstants.h
  4. +43
    -24
      common/JackEngine.cpp
  5. +2
    -1
      common/JackEngine.h
  6. +11
    -0
      common/JackGraphManager.cpp
  7. +5
    -4
      common/JackGraphManager.h

+ 18
- 10
common/JackConnectionManager.cpp View File

@@ -39,7 +39,7 @@ JackConnectionManager::JackConnectionManager()

JackLog("JackConnectionManager::InitClients\n");
for (i = 0; i < CLIENT_NUM; i++) {
InitClient(i);
InitRefNum(i);
}
}

@@ -79,14 +79,6 @@ bool JackConnectionManager::IsLoopPathAux(int ref1, int ref2) const
}
}

void JackConnectionManager::InitClient(int refnum)
{
fInputPort[refnum].Init();
fOutputPort[refnum].Init();
fConnectionRef.Init(refnum);
fInputCounter[refnum].SetValue(0);
}

//--------------
// External API
//--------------
@@ -237,6 +229,7 @@ const jack_int_t* JackConnectionManager::GetOutputPorts(int refnum)
/*!
\brief Return the first available refnum.
*/
/*
int JackConnectionManager::AllocateRefNum()
{
for (int i = 0; i < CLIENT_NUM; i++) {
@@ -248,15 +241,30 @@ int JackConnectionManager::AllocateRefNum()

return -1;
}
*/
/*!
\brief Release the refnum.
*/
/*
void JackConnectionManager::ReleaseRefNum(int refnum)
{
JackLog("JackConnectionManager::ReleaseRefNum ref = %ld\n", refnum);
InitClient(refnum);
}
*/

/*!
\brief Release the refnum.
*/

void JackConnectionManager::InitRefNum(int refnum)
{
fInputPort[refnum].Init();
fOutputPort[refnum].Init();
fConnectionRef.Init(refnum);
fInputCounter[refnum].SetValue(0);
}


/*!
\brief Reset all clients activation.


+ 4
- 3
common/JackConnectionManager.h View File

@@ -407,7 +407,7 @@ class JackConnectionManager
JackLoopFeedback<CONNECTION_NUM> fLoopFeedback; /*! Loop feedback connections */

bool IsLoopPathAux(int ref1, int ref2) const;
void InitClient(int refnum);
//void InitClient(int refnum);

public:

@@ -442,8 +442,9 @@ class JackConnectionManager
const jack_int_t* GetOutputPorts(int refnum);

// Client management
int AllocateRefNum();
void ReleaseRefNum(int refnum);
//int AllocateRefNum();
//void ReleaseRefNum(int refnum);
void InitRefNum(int refnum);

int GetInputRefNum(jack_port_id_t port_index) const;
int GetOutputRefNum(jack_port_id_t port_index) const;


+ 1
- 1
common/JackConstants.h View File

@@ -19,7 +19,7 @@

#define PRINTDEBUG

#define VERSION "0.60"
#define VERSION "0.61"

#define FORK_SERVER 1



+ 43
- 24
common/JackEngine.cpp View File

@@ -44,18 +44,18 @@ JackEngine::JackEngine(JackGraphManager* manager, JackSynchro** table, JackEngin
fEngineControl->fPriority = priority;
fEngineControl->fVerbose = ve;
fChannel = JackGlobals::MakeServerNotifyChannel();
fTiming = new JackEngineTiming(fClientTable, fGraphManager, fEngineControl);
fEngineTiming = new JackEngineTiming(fClientTable, fGraphManager, fEngineControl);
fSignal = signal;
for (int i = 0; i < CLIENT_NUM; i++)
fClientTable[i] = 0;
fTiming->ClearTimeMeasures();
fTiming->ResetRollingUsecs();
fClientTable[i] = NULL;
fEngineTiming->ClearTimeMeasures();
fEngineTiming->ResetRollingUsecs();
}

JackEngine::~JackEngine()
{
delete fChannel;
delete fTiming;
delete fEngineTiming;
}

//-------------------
@@ -94,6 +94,18 @@ int JackEngine::Close()
return 0;
}

int JackEngine::Allocate()
{
for (int i = 0; i < CLIENT_NUM; i++) {
if (!fClientTable[i]) {
JackLog("JackEngine::AllocateRefNum ref = %ld\n", i);
return i;
}
}

return -1;
}

//------------------
// Graph management
//------------------
@@ -106,7 +118,7 @@ bool JackEngine::Process(jack_time_t callback_usecs)

// Timing
fEngineControl->fFrameTimer.IncFrameTime(fEngineControl->fBufferSize, callback_usecs, fEngineControl->fPeriodUsecs);
fTiming->UpdateTiming(callback_usecs);
fEngineTiming->UpdateTiming(callback_usecs);

// Graph
if (fGraphManager->IsFinishedGraph()) {
@@ -346,7 +358,8 @@ int JackEngine::ClientNew(const char* name, int* ref, int* shared_engine, int* s
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 = fGraphManager->AllocateRefNum();
//int refnum = fGraphManager->AllocateRefNum();
int refnum = Allocate();

if (refnum < 0) {
jack_error("No more refnum available");
@@ -354,38 +367,41 @@ int JackEngine::ClientExternalNew(const char* name, int* ref, int* shared_engine
}

if (!fSynchroTable[refnum]->Allocate(name, 0)) {
jack_error("Cannot allocate synchro");
goto error1;
jack_error("Cannot allocate synchro");
goto error;
}

if (client->Open(name, refnum, shared_client) < 0) {
jack_error("Cannot open client");
goto error1;
goto error;
}

if (!fSignal->TimedWait(5 * 1000000)) {
// Failure if RT thread is not running (problem with the driver...)
jack_error("Driver is not running");
goto error2;
goto error;
}

if (NotifyAddClient(client, name, refnum) < 0) {
jack_error("Cannot notify add client");
goto error2;
goto error;
}

fClientTable[refnum] = client;
fTiming->ResetRollingUsecs();
fGraphManager->InitRefNum(refnum);
fEngineTiming->ResetRollingUsecs();
*shared_engine = fEngineControl->GetShmIndex();
*shared_graph_manager = fGraphManager->GetShmIndex();
*ref = refnum;
return 0;
error1:
fGraphManager->ReleaseRefNum(refnum);
return 0;

/*
error1:
fGraphManager->ReleaseRefNum(refnum);
return -1;
*/

error2:
error:
ClientCloseAux(refnum, client, false);
client->Close();
return -1;
@@ -395,7 +411,8 @@ error2:
int JackEngine::ClientInternalNew(const char* name, int* ref, JackEngineControl** shared_engine, JackGraphManager** shared_manager, JackClientInterface* client)
{
JackLog("JackEngine::ClientInternalNew: name = %s\n", name);
int refnum = fGraphManager->AllocateRefNum();
//int refnum = fGraphManager->AllocateRefNum();
int refnum = Allocate();

if (refnum < 0) {
jack_error("No more refnum available");
@@ -413,14 +430,15 @@ int JackEngine::ClientInternalNew(const char* name, int* ref, JackEngineControl*
}

fClientTable[refnum] = client;
fTiming->ResetRollingUsecs();
fGraphManager->InitRefNum(refnum);
fEngineTiming->ResetRollingUsecs();
*shared_engine = fEngineControl;
*shared_manager = fGraphManager;
*ref = refnum;
return 0;

error:
fGraphManager->ReleaseRefNum(refnum);
// fGraphManager->ReleaseRefNum(refnum);
return -1;
}

@@ -475,8 +493,9 @@ int JackEngine::ClientCloseAux(int refnum, JackClientInterface* client, bool wai

// Cleanup...
fSynchroTable[refnum]->Destroy();
fGraphManager->ReleaseRefNum(refnum);
fTiming->ResetRollingUsecs();
//fGraphManager->ReleaseRefNum(refnum);
fEngineTiming->ResetRollingUsecs();
return 0;
}

@@ -641,7 +660,7 @@ void JackEngine::PrintState()
}

//fGraphManager->PrintState();
fTiming->PrintState();
fEngineTiming->PrintState();
}

} // end of namespace


+ 2
- 1
common/JackEngine.h View File

@@ -48,7 +48,7 @@ class JackEngine
JackClientInterface* fClientTable[CLIENT_NUM];
JackSynchro** fSynchroTable;
JackServerNotifyChannelInterface* fChannel; /*! To communicate between the RT thread and server */
JackEngineTiming* fTiming;
JackEngineTiming* fEngineTiming;
JackSyncInterface* fSignal;
jack_time_t fLastSwitchUsecs;

@@ -67,6 +67,7 @@ class JackEngine

int Open();
int Close();
int Allocate();

// Client management
bool ClientCheckName(const char* name);


+ 11
- 0
common/JackGraphManager.cpp View File

@@ -67,6 +67,7 @@ int JackGraphManager::GetConnectionsNum(jack_port_id_t port_index)
}

// Server
/*
int JackGraphManager::AllocateRefNum()
{
JackConnectionManager* manager = WriteNextStateStart();
@@ -74,14 +75,24 @@ int JackGraphManager::AllocateRefNum()
WriteNextStateStop();
return res;
}
*/

// Server
/*
void JackGraphManager::ReleaseRefNum(int refnum)
{
JackConnectionManager* manager = WriteNextStateStart();
manager->ReleaseRefNum(refnum);
WriteNextStateStop();
}
*/

void JackGraphManager::InitRefNum(int refnum)
{
JackConnectionManager* manager = WriteNextStateStart();
manager->InitRefNum(refnum);
WriteNextStateStop();
}

// RT
void JackGraphManager::RunCurrentGraph()


+ 5
- 4
common/JackGraphManager.h View File

@@ -82,9 +82,9 @@ class JackGraphManager : public JackShmMem, public JackAtomicState<JackConnectio
int DisconnectAll(jack_port_id_t port_index);

// Client management
int AllocateRefNum();
void ReleaseRefNum(int refnum);
//int AllocateRefNum();
//void ReleaseRefNum(int refnum);
bool IsDirectConnection(int ref1, int ref2);
void DirectConnect(int ref1, int ref2);
void DirectDisconnect(int ref1, int ref2);
@@ -104,10 +104,11 @@ class JackGraphManager : public JackShmMem, public JackAtomicState<JackConnectio
bool RunNextGraph();
bool IsFinishedGraph();

void InitRefNum(int refnum);
int ResumeRefNum(JackClientControl* control, JackSynchro** table);
int SuspendRefNum(JackClientControl* control, JackSynchro** table, long usecs);
JackClientTiming* GetClientTiming(int ref);
JackClientTiming* GetClientTiming(int refnum);
void Save(JackConnectionManager* dst);
void Restore(JackConnectionManager* src);


Loading…
Cancel
Save