git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@1529 0c269be4-1314-0410-8aa9-9f06e86f4224tags/0.65
@@ -1,6 +1,10 @@ | |||||
--------------------------- | --------------------------- | ||||
Jackdmp changes log | Jackdmp changes log | ||||
--------------------------- | --------------------------- | ||||
2007-08-24 Stephane Letz <letz@grame.fr> | |||||
* Implement server temporary (-T) mode. | |||||
2007-08-23 Stephane Letz <letz@grame.fr> | 2007-08-23 Stephane Letz <letz@grame.fr> | ||||
@@ -93,7 +93,7 @@ int JackEngine::Close() | |||||
return 0; | return 0; | ||||
} | } | ||||
int JackEngine::Allocate() | |||||
int JackEngine::AllocateRefnum() | |||||
{ | { | ||||
for (int i = 0; i < CLIENT_NUM; i++) { | for (int i = 0; i < CLIENT_NUM; i++) { | ||||
if (!fClientTable[i]) { | if (!fClientTable[i]) { | ||||
@@ -101,10 +101,30 @@ int JackEngine::Allocate() | |||||
return i; | return i; | ||||
} | } | ||||
} | } | ||||
return -1; | return -1; | ||||
} | } | ||||
void JackEngine::ReleaseRefnum(int ref) | |||||
{ | |||||
fClientTable[ref] = NULL; | |||||
int i; | |||||
if (fEngineControl->fTemporary) { | |||||
for (i = REAL_REFNUM; i < CLIENT_NUM; i++) { | |||||
if (fClientTable[i]) | |||||
break; | |||||
} | |||||
if (i == CLIENT_NUM) { | |||||
// last client and temporay case: quit the server | |||||
JackLog("JackEngine::ReleaseRefnum server quit\n"); | |||||
fEngineControl->fTemporary = false; | |||||
#ifndef WIN32 | |||||
kill(getpid(), SIGINT); | |||||
#endif | |||||
} | |||||
} | |||||
} | |||||
//------------------ | //------------------ | ||||
// Graph management | // Graph management | ||||
//------------------ | //------------------ | ||||
@@ -424,7 +444,7 @@ int JackEngine::ClientExternalOpen(const char* name, int* ref, int* shared_engin | |||||
{ | { | ||||
JackLog("JackEngine::ClientOpen: name = %s \n", name); | JackLog("JackEngine::ClientOpen: name = %s \n", name); | ||||
int refnum = Allocate(); | |||||
int refnum = AllocateRefnum(); | |||||
if (refnum < 0) { | if (refnum < 0) { | ||||
jack_error("No more refnum available"); | jack_error("No more refnum available"); | ||||
return -1; | return -1; | ||||
@@ -473,7 +493,7 @@ int JackEngine::ClientInternalOpen(const char* name, int* ref, JackEngineControl | |||||
{ | { | ||||
JackLog("JackEngine::ClientInternalNew: name = %s\n", name); | JackLog("JackEngine::ClientInternalNew: name = %s\n", name); | ||||
int refnum = Allocate(); | |||||
int refnum = AllocateRefnum(); | |||||
if (refnum < 0) { | if (refnum < 0) { | ||||
jack_error("No more refnum available"); | jack_error("No more refnum available"); | ||||
return -1; | return -1; | ||||
@@ -534,7 +554,7 @@ int JackEngine::ClientCloseAux(int refnum, JackClientInterface* client, bool wai | |||||
(client->GetClientControl()) ? client->GetClientControl()->fName : "No name"); | (client->GetClientControl()) ? client->GetClientControl()->fName : "No name"); | ||||
// Remove the client from the table | // Remove the client from the table | ||||
fClientTable[refnum] = NULL; | |||||
ReleaseRefnum(refnum); | |||||
// Remove ports | // Remove ports | ||||
fGraphManager->RemoveAllPorts(refnum); | fGraphManager->RemoveAllPorts(refnum); | ||||
@@ -63,7 +63,8 @@ class JackEngine | |||||
void ProcessCurrent(jack_time_t callback_usecs); | void ProcessCurrent(jack_time_t callback_usecs); | ||||
bool ClientCheckName(const char* name); | bool ClientCheckName(const char* name); | ||||
bool GenerateUniqueName(char* name); | bool GenerateUniqueName(char* name); | ||||
int Allocate(); | |||||
int AllocateRefnum(); | |||||
void ReleaseRefnum(int ref); | |||||
public: | public: | ||||
@@ -39,6 +39,7 @@ struct JackEngineControl : public JackShmMem | |||||
jack_nframes_t fSampleRate; | jack_nframes_t fSampleRate; | ||||
float fCPULoad; | float fCPULoad; | ||||
bool fSyncMode; | bool fSyncMode; | ||||
bool fTemporary; | |||||
jack_time_t fPeriodUsecs; | jack_time_t fPeriodUsecs; | ||||
jack_time_t fTimeOutUsecs; | jack_time_t fTimeOutUsecs; | ||||
bool fRealTime; | bool fRealTime; | ||||
@@ -50,8 +51,9 @@ struct JackEngineControl : public JackShmMem | |||||
JackTransportEngine fTransport; | JackTransportEngine fTransport; | ||||
bool fVerbose; | bool fVerbose; | ||||
JackEngineControl(bool sync, long timeout, bool rt, long priority, bool verbose) | |||||
JackEngineControl(bool sync, bool temporary, long timeout, bool rt, long priority, bool verbose) | |||||
:fSyncMode(sync), | :fSyncMode(sync), | ||||
fTemporary(temporary), | |||||
fTimeOutUsecs(timeout * 1000), | fTimeOutUsecs(timeout * 1000), | ||||
fRealTime(rt), | fRealTime(rt), | ||||
fPriority(priority), | fPriority(priority), | ||||
@@ -45,13 +45,13 @@ namespace Jack | |||||
JackServer* JackServer::fInstance = NULL; | JackServer* JackServer::fInstance = NULL; | ||||
JackServer::JackServer(bool sync, long timeout, bool rt, long priority, long loopback, bool verbose) | |||||
JackServer::JackServer(bool sync, bool temporary, long timeout, bool rt, long priority, long loopback, bool verbose) | |||||
{ | { | ||||
JackGlobals::InitServer(); | JackGlobals::InitServer(); | ||||
for (int i = 0; i < CLIENT_NUM; i++) | for (int i = 0; i < CLIENT_NUM; i++) | ||||
fSynchroTable[i] = JackGlobals::MakeSynchro(); | fSynchroTable[i] = JackGlobals::MakeSynchro(); | ||||
fGraphManager = new JackGraphManager(); | fGraphManager = new JackGraphManager(); | ||||
fEngineControl = new JackEngineControl(sync, timeout, rt, priority, verbose); | |||||
fEngineControl = new JackEngineControl(sync, temporary, timeout, rt, priority, verbose); | |||||
fEngine = new JackEngine(fGraphManager, fSynchroTable, fEngineControl); | fEngine = new JackEngine(fGraphManager, fSynchroTable, fEngineControl); | ||||
fFreewheelDriver = new JackThreadedDriver(new JackFreewheelDriver("freewheel", fEngine, fSynchroTable)); | fFreewheelDriver = new JackThreadedDriver(new JackFreewheelDriver("freewheel", fEngine, fSynchroTable)); | ||||
fLoopbackDriver = new JackLoopbackDriver("loopback", fEngine, fSynchroTable); | fLoopbackDriver = new JackLoopbackDriver("loopback", fEngine, fSynchroTable); | ||||
@@ -61,7 +61,7 @@ class EXPORT JackServer | |||||
public: | public: | ||||
JackServer(bool sync, long timeout, bool rt, long priority, long loopback, bool verbose); | |||||
JackServer(bool sync, bool temporary, long timeout, bool rt, long priority, long loopback, bool verbose); | |||||
virtual ~JackServer(); | virtual ~JackServer(); | ||||
int Open(jack_driver_desc_t* driver_desc, JSList* driver_params); | int Open(jack_driver_desc_t* driver_desc, JSList* driver_params); | ||||
@@ -155,10 +155,10 @@ jack_cleanup_files (const char *server_name) | |||||
#endif | #endif | ||||
int JackServerGlobals::JackStart(jack_driver_desc_t* driver_desc, JSList* driver_params, int sync, int time_out_ms, int rt, int priority, int loopback, int verbose) | |||||
int JackServerGlobals::JackStart(jack_driver_desc_t* driver_desc, JSList* driver_params, int sync, int temporary, int time_out_ms, int rt, int priority, int loopback, int verbose) | |||||
{ | { | ||||
JackLog("Jackdmp: sync = %ld timeout = %ld rt = %ld priority = %ld verbose = %ld \n", sync, time_out_ms, rt, priority, verbose); | JackLog("Jackdmp: sync = %ld timeout = %ld rt = %ld priority = %ld verbose = %ld \n", sync, time_out_ms, rt, priority, verbose); | ||||
fServer = new JackServer(sync, time_out_ms, rt, priority, loopback, verbose); | |||||
fServer = new JackServer(sync, temporary, time_out_ms, rt, priority, loopback, verbose); | |||||
int res = fServer->Open(driver_desc, driver_params); | int res = fServer->Open(driver_desc, driver_params); | ||||
return (res < 0) ? res : fServer->Start(); | return (res < 0) ? res : fServer->Start(); | ||||
} | } | ||||
@@ -351,7 +351,7 @@ JackServerGlobals::JackServerGlobals() | |||||
if (!realtime && client_timeout == 0) | if (!realtime && client_timeout == 0) | ||||
client_timeout = 500; /* 0.5 sec; usable when non realtime. */ | client_timeout = 500; /* 0.5 sec; usable when non realtime. */ | ||||
int res = JackStart(driver_desc, driver_params, sync, client_timeout, realtime, realtime_priority, loopback, verbose_aux); | |||||
int res = JackStart(driver_desc, driver_params, sync, temporary, client_timeout, realtime, realtime_priority, loopback, verbose_aux); | |||||
if (res < 0) { | if (res < 0) { | ||||
jack_error("Cannot start server... exit"); | jack_error("Cannot start server... exit"); | ||||
JackDelete(); | JackDelete(); | ||||
@@ -47,7 +47,7 @@ struct JackServerGlobals | |||||
static void Init(); | static void Init(); | ||||
static void Destroy(); | static void Destroy(); | ||||
static int JackStart(jack_driver_desc_t* driver_desc, JSList* driver_params, int sync, int time_out_ms, int rt, int priority, int loopback, int verbose); | |||||
static int JackStart(jack_driver_desc_t* driver_desc, JSList* driver_params, int sync, int temporary, int time_out_ms, int rt, int priority, int loopback, int verbose); | |||||
static int JackStop(); | static int JackStop(); | ||||
static int JackDelete(); | static int JackDelete(); | ||||
}; | }; | ||||
@@ -101,10 +101,10 @@ static void DoNothingHandler(int sig) | |||||
write(1, buf, strlen(buf)); | write(1, buf, strlen(buf)); | ||||
} | } | ||||
static int JackStart(jack_driver_desc_t* driver_desc, JSList* driver_params, int sync, int time_out_ms, int rt, int priority, int loopback, int verbose) | |||||
static int JackStart(jack_driver_desc_t* driver_desc, JSList* driver_params, int sync, int temporary, int time_out_ms, int rt, int priority, int loopback, int verbose) | |||||
{ | { | ||||
JackLog("Jackdmp: sync = %ld timeout = %ld rt = %ld priority = %ld verbose = %ld \n", sync, time_out_ms, rt, priority, verbose); | JackLog("Jackdmp: sync = %ld timeout = %ld rt = %ld priority = %ld verbose = %ld \n", sync, time_out_ms, rt, priority, verbose); | ||||
fServer = new JackServer(sync, time_out_ms, rt, priority, loopback, verbose); | |||||
fServer = new JackServer(sync, temporary, time_out_ms, rt, priority, loopback, verbose); | |||||
int res = fServer->Open(driver_desc, driver_params); | int res = fServer->Open(driver_desc, driver_params); | ||||
return (res < 0) ? res : fServer->Start(); | return (res < 0) ? res : fServer->Start(); | ||||
} | } | ||||
@@ -448,7 +448,7 @@ int main(int argc, char* argv[]) | |||||
if (!realtime && client_timeout == 0) | if (!realtime && client_timeout == 0) | ||||
client_timeout = 500; /* 0.5 sec; usable when non realtime. */ | client_timeout = 500; /* 0.5 sec; usable when non realtime. */ | ||||
int res = JackStart(driver_desc, driver_params, sync, client_timeout, realtime, realtime_priority, loopback, jack_verbose); | |||||
int res = JackStart(driver_desc, driver_params, sync, temporary, client_timeout, realtime, realtime_priority, loopback, jack_verbose); | |||||
if (res < 0) { | if (res < 0) { | ||||
jack_error("Cannot start server... exit"); | jack_error("Cannot start server... exit"); | ||||
JackDelete(); | JackDelete(); | ||||