Commit f16634bb authored by sletz's avatar sletz
Browse files

Implementation of server_name setting (-n) in progress

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@1638 0c269be4-1314-0410-8aa9-9f06e86f4224
parent 0daaace1
......@@ -13,6 +13,10 @@ Tom Szilagyi
Jackdmp changes log
---------------------------
2007-10-24 Stephane Letz <letz@grame.fr>
* Implementation of server_name setting (-n) in progress.
2007-10-23 Stephane Letz <letz@grame.fr>
* Correct jack_acquire_real_time_scheduling on OSX.
......
......@@ -53,10 +53,8 @@ extern "C"
EXPORT int jack_internal_client_new (const char *client_name,
const char *load_name,
const char *load_init);
EXPORT jack_client_t* my_jack_internal_client_new(const char* client_name);
EXPORT void jack_internal_client_close (const char *client_name);
EXPORT void my_jack_internal_client_close (jack_client_t* client);
EXPORT int jack_is_realtime (jack_client_t *client);
EXPORT int jack_is_realtime (jack_client_t *client);
EXPORT void jack_on_shutdown (jack_client_t *client,
void (*function)(void *arg), void *arg);
EXPORT int jack_set_process_callback (jack_client_t *client,
......
......@@ -36,9 +36,7 @@ extern "C"
EXPORT int jack_internal_client_new (const char *client_name,
const char *load_name,
const char *load_init);
EXPORT jack_client_t* my_jack_internal_client_new(const char* client_name, const char* dll_name, const char* object_data);
EXPORT void jack_internal_client_close (const char *client_name);
EXPORT void my_jack_internal_client_close (jack_client_t* client);
EXPORT int jack_is_realtime (jack_client_t *client);
EXPORT void jack_on_shutdown (jack_client_t *client,
void (*function)(void *arg), void *arg);
......
......@@ -48,7 +48,7 @@ class JackClientChannelInterface
{}
// Open the Server/Client connection
virtual int Open(const char* name, char* name_res, JackClient* obj, jack_options_t options, jack_status_t* status)
virtual int Open(const char* server_name, const char* name, char* name_res, JackClient* obj, jack_options_t options, jack_status_t* status)
{
return 0;
}
......@@ -170,7 +170,7 @@ class JackServerChannelInterface
{}
// Open the Server/Client connection
virtual int Open(JackServer* server)
virtual int Open(const char* server_name, JackServer* server)
{
return 0;
}
......@@ -194,7 +194,7 @@ class JackServerNotifyChannelInterface
{}
// Open the Server RT/Server connection
virtual int Open()
virtual int Open(const char* server_name)
{
return 0;
}
......
......@@ -76,6 +76,7 @@ class JackClient : public JackClientInterface, public JackRunnableInterface
void* fTimebaseArg;
void* fSyncArg;
int fConditionnal;
char fServerName[64];
JackThread* fThread; /*! Thread to execute the Process function */
JackClientChannelInterface* fChannel;
......@@ -99,7 +100,7 @@ class JackClient : public JackClientInterface, public JackRunnableInterface
JackClient(JackSynchro** table);
virtual ~JackClient();
virtual int Open(const char* name, jack_options_t options, jack_status_t* status) = 0;
virtual int Open(const char* server_name, const char* name, jack_options_t options, jack_status_t* status) = 0;
virtual int Close();
virtual JackGraphManager* GetGraphManager() const = 0;
......
......@@ -74,9 +74,9 @@ JackDebugClient::~JackDebugClient()
delete fClient;
}
int JackDebugClient::Open(const char* name, jack_options_t options, jack_status_t* status)
int JackDebugClient::Open(const char* server_name, const char* name, jack_options_t options, jack_status_t* status)
{
int res = fClient->Open(name, options, status);
int res = fClient->Open(server_name, name, options, status);
char provstr[256];
char buffer[256];
time_t curtime;
......
......@@ -67,7 +67,7 @@ class JackDebugClient : public JackClient
JackDebugClient(JackClient* fTheClient);
virtual ~JackDebugClient();
virtual int Open(const char* name, jack_options_t options, jack_status_t* status);
virtual int Open(const char* server_name, const char* name, jack_options_t options, jack_status_t* status);
int Close();
virtual JackGraphManager* GetGraphManager() const;
......
......@@ -67,7 +67,7 @@ int JackEngine::Open()
JackLog("JackEngine::Open\n");
// Open audio thread => request thread communication channel
if (fChannel->Open() < 0) {
if (fChannel->Open(fEngineControl->fServerName) < 0) {
jack_error("Cannot connect to server");
return -1;
} else {
......@@ -515,7 +515,7 @@ int JackEngine::ClientExternalOpen(const char* name, int* ref, int* shared_engin
JackExternalClient* client = new JackExternalClient();
if (!fSynchroTable[refnum]->Allocate(name, 0)) {
if (!fSynchroTable[refnum]->Allocate(name, fEngineControl->fServerName, 0)) {
jack_error("Cannot allocate synchro");
goto error;
}
......@@ -562,7 +562,7 @@ int JackEngine::ClientInternalOpen(const char* name, int* ref, JackEngineControl
return -1;
}
if (!fSynchroTable[refnum]->Allocate(name, 0)) {
if (!fSynchroTable[refnum]->Allocate(name, fEngineControl->fServerName, 0)) {
jack_error("Cannot allocate synchro");
return -1;
}
......
......@@ -47,18 +47,22 @@ struct JackEngineControl : public JackShmMem
UInt64 fPeriod;
UInt64 fComputation;
UInt64 fConstraint;
char fServerName[64];
JackFrameTimer fFrameTimer;
JackTransportEngine fTransport;
bool fVerbose;
JackEngineControl(bool sync, bool temporary, long timeout, bool rt, long priority, bool verbose)
JackEngineControl(bool sync, bool temporary, long timeout, bool rt, long priority, bool verbose, const char* server_name)
:fSyncMode(sync),
fTemporary(temporary),
fTimeOutUsecs(timeout * 1000),
fRealTime(rt),
fPriority(priority),
fVerbose(verbose)
{}
{
snprintf(fServerName, sizeof(fServerName), server_name);
}
void InitFrameTime()
{
......
......@@ -29,9 +29,9 @@ This program is free software; you can redistribute it and/or modify
namespace Jack
{
void JackFifo::BuildName(const char* name, char* res)
void JackFifo::BuildName(const char* name, const char* server_name, char* res)
{
sprintf(res, "%s/jack_fifo.%s", jack_client_dir, name);
sprintf(res, "%s/jack_fifo.%s_%s", jack_client_dir, server_name, name);
}
bool JackFifo::Signal()
......@@ -103,10 +103,10 @@ bool JackFifo::TimedWait(long usec)
#endif
// Server side
bool JackFifo::Allocate(const char* name, int value)
bool JackFifo::Allocate(const char* name, const char* server_name, int value)
{
struct stat statbuf;
BuildName(name, fName);
BuildName(name, server_name, fName);
JackLog("JackFifo::Allocate name = %s\n", fName);
......@@ -138,9 +138,9 @@ bool JackFifo::Allocate(const char* name, int value)
}
// Client side
bool JackFifo::ConnectAux(const char* name, int access)
bool JackFifo::ConnectAux(const char* name, const char* server_name, int access)
{
BuildName(name, fName);
BuildName(name, server_name, fName);
JackLog("JackFifo::ConnectAux name = %s\n", fName);
// Temporary...
......@@ -159,19 +159,19 @@ bool JackFifo::ConnectAux(const char* name, int access)
}
}
bool JackFifo::Connect(const char* name)
bool JackFifo::Connect(const char* name, const char* server_name)
{
return ConnectAux(name, O_RDWR);
return ConnectAux(name, server_name, O_RDWR);
}
bool JackFifo::ConnectOutput(const char* name)
bool JackFifo::ConnectOutput(const char* name, const char* server_name)
{
return ConnectAux(name, O_WRONLY | O_NONBLOCK);
return ConnectAux(name, server_name, O_WRONLY | O_NONBLOCK);
}
bool JackFifo::ConnectInput(const char* name)
bool JackFifo::ConnectInput(const char* name, const char* server_name)
{
return ConnectAux(name, O_RDONLY);
return ConnectAux(name, server_name, O_RDONLY);
}
bool JackFifo::Disconnect()
......
......@@ -40,11 +40,11 @@ class JackFifo : public JackSynchro
int fFifo;
pollfd fPoll;
bool ConnectAux(const char* name, int access);
bool ConnectAux(const char* name, const char* server_name, int access);
protected:
void BuildName(const char* name, char* res);
void BuildName(const char* name, const char* server_name, char* res);
public:
......@@ -58,10 +58,10 @@ class JackFifo : public JackSynchro
bool Wait();
bool TimedWait(long usec);
bool Allocate(const char* name, int value);
bool Connect(const char* name);
bool ConnectInput(const char* name);
bool ConnectOutput(const char* name);
bool Allocate(const char* name, const char* server_name, int value);
bool Connect(const char* name, const char* server_name);
bool ConnectInput(const char* name, const char* server_name);
bool ConnectOutput(const char* name, const char* server_name);
bool Disconnect();
void Destroy();
};
......
......@@ -65,11 +65,13 @@ JackInternalClient::~JackInternalClient()
delete fChannel;
}
int JackInternalClient::Open(const char* name, jack_options_t options, jack_status_t* status)
int JackInternalClient::Open(const char* server_name, const char* name, jack_options_t options, jack_status_t* status)
{
int result;
char name_res[JACK_CLIENT_NAME_SIZE];
JackLog("JackInternalClient::Open name = %s\n", name);
snprintf(fServerName, sizeof(fServerName), server_name);
fChannel->ClientCheck(name, name_res, JACK_PROTOCOL_VERSION, (int)options, (int*)status, &result);
if (result < 0) {
......@@ -154,9 +156,9 @@ JackLoadableInternalClient::~JackLoadableInternalClient()
UnloadJackModule(fHandle);
}
int JackLoadableInternalClient::Open(const char* name, jack_options_t options, jack_status_t* status)
int JackLoadableInternalClient::Open(const char* server_name, const char* name, jack_options_t options, jack_status_t* status)
{
int res = JackInternalClient::Open(name, options, status);
int res = JackInternalClient::Open(server_name, name, options, status);
if (res == 0)
fInitialize((jack_client_t*)this, fObjectData);
return res;
......
......@@ -45,7 +45,7 @@ class JackInternalClient : public JackClient
JackInternalClient(JackServer* server, JackSynchro** table);
virtual ~JackInternalClient();
int Open(const char* name, jack_options_t options, jack_status_t* status);
int Open(const char* server_name, const char* name, jack_options_t options, jack_status_t* status);
JackGraphManager* GetGraphManager() const;
JackEngineControl* GetEngineControl() const;
......@@ -95,7 +95,7 @@ class JackLoadableInternalClient : public JackInternalClient
JackLoadableInternalClient(JackServer* server, JackSynchro** table, const char* so_name, const char* object_data);
virtual ~JackLoadableInternalClient();
int Open(const char* name, jack_options_t options, jack_status_t* status);
int Open(const char* server_name, const char* name, jack_options_t options, jack_status_t* status);
};
......
......@@ -77,7 +77,7 @@ static jack_client_t* jack_client_open_aux(const char* client_name, jack_options
va_start(ap, status);
jack_varargs_parse(options, ap, &va);
va_end(ap);
JackLog("jack_client_open %s\n", client_name);
if (client_name == NULL) {
jack_error("jack_client_new called with a NULL client_name");
......@@ -100,7 +100,7 @@ static jack_client_t* jack_client_open_aux(const char* client_name, jack_options
JackClient* client = new JackLibClient(GetSynchroTable());
#endif
int res = client->Open(client_name, options, status);
int res = client->Open(va.server_name, client_name, options, status);
if (res < 0) {
delete client;
JackLibGlobals::Destroy(); // jack library destruction
......
......@@ -61,14 +61,16 @@ JackLibClient::~JackLibClient()
delete fChannel;
}
int JackLibClient::Open(const char* name, jack_options_t options, jack_status_t* status)
int JackLibClient::Open(const char* server_name, const char* name, jack_options_t options, jack_status_t* status)
{
int shared_engine, shared_client, shared_graph, result;
JackLog("JackLibClient::Open %s\n", name);
snprintf(fServerName, sizeof(fServerName), server_name);
// Open server/client channel
char name_res[JACK_CLIENT_NAME_SIZE];
if (fChannel->Open(name, name_res, this, options, status) < 0) {
if (fChannel->Open(server_name, name, name_res, this, options, status) < 0) {
jack_error("Cannot connect to the server");
goto error;
}
......@@ -88,9 +90,9 @@ int JackLibClient::Open(const char* name, jack_options_t options, jack_status_t*
try {
// Map shared memory segments
JackLibGlobals::fGlobals->fEngineControl = shared_engine;
JackLibGlobals::fGlobals->fGraphManager = shared_graph;
fClientControl = shared_client;
JackLibGlobals::fGlobals->fEngineControl.SetShmIndex(shared_engine, fServerName);
JackLibGlobals::fGlobals->fGraphManager.SetShmIndex(shared_graph, fServerName);
fClientControl.SetShmIndex(shared_client, fServerName);
jack_verbose = GetEngineControl()->fVerbose;
} catch (int n) {
jack_error("Map shared memory segments exception %d", n);
......@@ -109,7 +111,7 @@ int JackLibClient::Open(const char* name, jack_options_t options, jack_status_t*
#endif
*/
// Connect shared synchro : the synchro must be usable in I/O mode when several clients live in the same process
if (!fSynchroTable[fClientControl->fRefNum]->Connect(name_res)) {
if (!fSynchroTable[fClientControl->fRefNum]->Connect(name_res, fServerName)) {
jack_error("Cannot ConnectSemaphore %s client", name_res);
goto error;
}
......@@ -135,8 +137,8 @@ int JackLibClient::ClientNotifyImp(int refnum, const char* name, int notify, int
case kAddClient:
JackLog("JackClient::AddClient name = %s, ref = %ld \n", name, refnum);
// the synchro must be usable in I/O mode when several clients live in the same process
res = fSynchroTable[refnum]->Connect(name) ? 0 : -1;
// the synchro must be usable in I/O mode when several clients live in the same process
res = fSynchroTable[refnum]->Connect(name, fServerName) ? 0 : -1;
break;
case kRemoveClient:
......
......@@ -44,7 +44,7 @@ class JackLibClient : public JackClient
JackLibClient(JackSynchro** table);
virtual ~JackLibClient();
int Open(const char* name, jack_options_t options, jack_status_t* status);
int Open(const char* server_name, const char* name, jack_options_t options, jack_status_t* status);
int ClientNotifyImp(int refnum, const char* name, int notify, int sync, int value);
......
......@@ -26,9 +26,9 @@ This program is free software; you can redistribute it and/or modify
namespace Jack
{
void JackPosixSemaphore::BuildName(const char* name, char* res)
void JackPosixSemaphore::BuildName(const char* name, const char* server_name, char* res)
{
sprintf(res, "%s/jack_sem.%s", jack_client_dir, name);
sprintf(res, "%s/jack_sem.%s_%s", jack_client_dir, server_name, name);
}
bool JackPosixSemaphore::Signal()
......@@ -123,9 +123,9 @@ bool JackPosixSemaphore::TimedWait(long usec)
}
// Server side : publish the semaphore in the global namespace
bool JackPosixSemaphore::Allocate(const char* name, int value)
bool JackPosixSemaphore::Allocate(const char* name, const char* server_name, int value)
{
BuildName(name, fName);
BuildName(name, server_name, fName);
JackLog("JackPosixSemaphore::Allocate name = %s val = %ld\n", fName, value);
if ((fSemaphore = sem_open(fName, O_CREAT, 0777, value)) == (sem_t*)SEM_FAILED) {
......@@ -137,9 +137,9 @@ bool JackPosixSemaphore::Allocate(const char* name, int value)
}
// Client side : get the published semaphore from server
bool JackPosixSemaphore::ConnectInput(const char* name)
bool JackPosixSemaphore::ConnectInput(const char* name, const char* server_name)
{
BuildName(name, fName);
BuildName(name, server_name, fName);
JackLog("JackPosixSemaphore::Connect %s\n", fName);
// Temporary...
......@@ -159,14 +159,14 @@ bool JackPosixSemaphore::ConnectInput(const char* name)
}
}
bool JackPosixSemaphore::Connect(const char* name)
bool JackPosixSemaphore::Connect(const char* name, const char* server_name)
{
return ConnectInput(name);
return ConnectInput(name, server_name);
}
bool JackPosixSemaphore::ConnectOutput(const char* name)
bool JackPosixSemaphore::ConnectOutput(const char* name, const char* server_name)
{
return ConnectInput(name);
return ConnectInput(name, server_name);
}
bool JackPosixSemaphore::Disconnect()
......
......@@ -42,7 +42,7 @@ class JackPosixSemaphore : public JackSynchro
protected:
void BuildName(const char* name, char* res);
void BuildName(const char* name, const char* server_name, char* res);
public:
......@@ -56,10 +56,10 @@ class JackPosixSemaphore : public JackSynchro
bool Wait();
bool TimedWait(long usec);
bool Allocate(const char* name, int value);
bool Connect(const char* name);
bool ConnectInput(const char* name);
bool ConnectOutput(const char* name);
bool Allocate(const char* name, const char* server_name, int value);
bool Connect(const char* name, const char* server_name);
bool ConnectInput(const char* name, const char* server_name);
bool ConnectOutput(const char* name, const char* server_name);
bool Disconnect();
void Destroy();
};
......
......@@ -137,7 +137,7 @@ class JackInterProcessSync : public JackSyncInterface
bool Allocate(const char* name)
{
return fSynchro->Allocate(name, 0);
return fSynchro->Allocate(name, "", 0);
}
void Destroy()
......@@ -147,7 +147,7 @@ class JackInterProcessSync : public JackSyncInterface
bool Connect(const char* name)
{
return fSynchro->Connect(name);
return fSynchro->Connect(name, "");
}
bool TimedWait(long usec)
......
......@@ -46,13 +46,13 @@ namespace Jack
JackServer* JackServer::fInstance = NULL;
JackServer::JackServer(bool sync, bool temporary, 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, const char* server_name)
{
JackGlobals::InitServer();
for (int i = 0; i < CLIENT_NUM; i++)
fSynchroTable[i] = JackGlobals::MakeSynchro();
fGraphManager = new JackGraphManager();
fEngineControl = new JackEngineControl(sync, temporary, timeout, rt, priority, verbose);
fEngineControl = new JackEngineControl(sync, temporary, timeout, rt, priority, verbose, server_name);
fEngine = new JackEngine(fGraphManager, fSynchroTable, fEngineControl);
fFreewheelDriver = new JackThreadedDriver(new JackFreewheelDriver("freewheel", fEngine, fSynchroTable));
fLoopbackDriver = new JackLoopbackDriver("loopback", fEngine, fSynchroTable);
......@@ -89,7 +89,7 @@ JackServer::~JackServer()
int JackServer::Open(jack_driver_desc_t* driver_desc, JSList* driver_params)
{
if (fChannel->Open(this) < 0) {
if (fChannel->Open(fEngineControl->fServerName, this) < 0) {
jack_error("Server channel open error");
return -1;
}
......@@ -179,7 +179,7 @@ int JackServer::InternalClientLoad(const char* client_name, const char* so_name,
*status = 0;
JackLoadableInternalClient* client = new JackLoadableInternalClient(fInstance, GetSynchroTable(), so_name, objet_data);
assert(client);
int res = client->Open(client_name, (jack_options_t)options, (jack_status_t*)status);
int res = client->Open("unused", client_name, (jack_options_t)options, (jack_status_t*)status);
if (res < 0) {
delete client;
*int_ref = 0;
......
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