Commit 92d88530 authored by sletz's avatar sletz
Browse files

Implement renaming in JackDriver::Open to avoid name collision (thanks Devin Anderson).

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4221 0c269be4-1314-0410-8aa9-9f06e86f4224
parent 41bbcc3d
......@@ -34,6 +34,10 @@ Valerio Pilo
Jackdmp changes log
---------------------------
2011-03-24 Stephane Letz <letz@grame.fr>
* Implement renaming in JackDriver::Open to avoid name collision (thanks Devin Anderson).
2011-03-23 Stephane Letz <letz@grame.fr>
* Devin Anderson server-ctl-proposal branch merged on trunk: improved control API, slave backend reworked.
......
......@@ -82,7 +82,7 @@ int JackDriver::Open()
return 0;
}
int JackDriver::Open (bool capturing,
int JackDriver::Open(bool capturing,
bool playing,
int inchannels,
int outchannels,
......@@ -95,6 +95,15 @@ int JackDriver::Open (bool capturing,
jack_log("JackDriver::Open capture_driver_name = %s", capture_driver_name);
jack_log("JackDriver::Open playback_driver_name = %s", playback_driver_name);
int refnum = -1;
char name_res[JACK_CLIENT_NAME_SIZE + 1];
int status;
// Check name and possibly rename
if (fEngine->ClientCheck(fClientControl.fName, -1, name_res, JACK_PROTOCOL_VERSION, (int)JackNullOption, (int*)&status) < 0) {
jack_error("Client name = %s conflits with another running client", fClientControl.fName);
return -1;
}
strcpy(fClientControl.fName, name_res);
if (fEngine->ClientInternalOpen(fClientControl.fName, &refnum, &fEngineControl, &fGraphManager, this, false) != 0) {
jack_error("Cannot allocate internal client for driver");
......@@ -137,6 +146,15 @@ int JackDriver::Open(jack_nframes_t buffer_size,
jack_log("JackDriver::Open capture_driver_name = %s", capture_driver_name);
jack_log("JackDriver::Open playback_driver_name = %s", playback_driver_name);
int refnum = -1;
char name_res[JACK_CLIENT_NAME_SIZE + 1];
int status;
// Check name and possibly rename
if (fEngine->ClientCheck(fClientControl.fName, -1, name_res, JACK_PROTOCOL_VERSION, (int)JackNullOption, (int*)&status) < 0) {
jack_error("Client name = %s conflits with another running client", fClientControl.fName);
return -1;
}
strcpy(fClientControl.fName, name_res);
if (fEngine->ClientInternalOpen(fClientControl.fName, &refnum, &fEngineControl, &fGraphManager, this, false) != 0) {
jack_error("Cannot allocate internal client for driver");
......
......@@ -519,7 +519,7 @@ void JackEngine::EnsureUUID(int uuid)
for (int i = 0; i < CLIENT_NUM; i++) {
JackClientInterface* client = fClientTable[i];
if (client && (client->GetClientControl()->fSessionID==uuid)) {
if (client && (client->GetClientControl()->fSessionID == uuid)) {
client->GetClientControl()->fSessionID = GetNewUUID();
}
}
......@@ -550,13 +550,13 @@ int JackEngine::GetClientRefNum(const char* name)
// Used for external clients
int JackEngine::ClientExternalOpen(const char* name, int pid, int uuid, int* ref, int* shared_engine, int* shared_client, int* shared_graph_manager)
{
char real_name[JACK_CLIENT_NAME_SIZE+1];
char real_name[JACK_CLIENT_NAME_SIZE + 1];
if (uuid < 0) {
uuid = GetNewUUID();
strncpy(real_name, name, JACK_CLIENT_NAME_SIZE);
} else {
std::map<int,std::string>::iterator res = fReservationMap.find(uuid);
std::map<int, std::string>::iterator res = fReservationMap.find(uuid);
if (res != fReservationMap.end()) {
strncpy(real_name, res->second.c_str(), JACK_CLIENT_NAME_SIZE);
fReservationMap.erase(uuid);
......@@ -567,7 +567,7 @@ int JackEngine::ClientExternalOpen(const char* name, int pid, int uuid, int* ref
EnsureUUID(uuid);
}
jack_log("JackEngine::ClientExternalOpen: uuid=%d, name = %s ", uuid, real_name);
jack_log("JackEngine::ClientExternalOpen: uuid = %d, name = %s ", uuid, real_name);
int refnum = AllocateRefnum();
if (refnum < 0) {
......@@ -958,7 +958,7 @@ void JackEngine::SessionNotify(int refnum, const char *target, jack_session_even
if (client && client->GetClientControl()->fCallback[kSessionCallback]) {
// check if this is a notification to a specific client.
if (target!=NULL && strlen(target)!=0) {
if (target != NULL && strlen(target) != 0) {
if (strcmp(target, client->GetClientControl()->fName)) {
continue;
}
......@@ -1018,7 +1018,7 @@ void JackEngine::GetUUIDForClientName(const char *client_name, char *uuid_res, i
for (int i = 0; i < CLIENT_NUM; i++) {
JackClientInterface* client = fClientTable[i];
if (client && (strcmp(client_name, client->GetClientControl()->fName)==0)) {
if (client && (strcmp(client_name, client->GetClientControl()->fName) == 0)) {
snprintf(uuid_res, JACK_UUID_SIZE, "%d", client->GetClientControl()->fSessionID);
*result = 0;
return;
......
......@@ -123,7 +123,7 @@ int JackLoadableInternalClient::Init(const char* so_name)
{
char path_to_so[JACK_PATH_MAX + 1];
BuildClientPath(path_to_so, sizeof(path_to_so), so_name);
fHandle = LoadJackModule(path_to_so);
jack_log("JackLoadableInternalClient::JackLoadableInternalClient path_to_so = %s", path_to_so);
......@@ -151,7 +151,7 @@ int JackLoadableInternalClient1::Init(const char* so_name)
if (JackLoadableInternalClient::Init(so_name) < 0) {
return -1;
}
fInitialize = (InitializeCallback)GetJackProc(fHandle, "jack_initialize");
if (fInitialize == NULL) {
UnloadJackModule(fHandle);
......@@ -167,7 +167,7 @@ int JackLoadableInternalClient2::Init(const char* so_name)
if (JackLoadableInternalClient::Init(so_name) < 0) {
return -1;
}
fInitialize = (InternalInitializeCallback)GetJackProc(fHandle, "jack_internal_initialize");
if (fInitialize == NULL) {
UnloadJackModule(fHandle);
......@@ -181,7 +181,7 @@ int JackLoadableInternalClient2::Init(const char* so_name)
JackLoadableInternalClient1::JackLoadableInternalClient1(JackServer* server, JackSynchro* table, const char* object_data)
: JackLoadableInternalClient(server, table)
{
strncpy(fObjectData, object_data, JACK_LOAD_INIT_LIMIT);
strncpy(fObjectData, object_data, JACK_LOAD_INIT_LIMIT);
}
JackLoadableInternalClient2::JackLoadableInternalClient2(JackServer* server, JackSynchro* table, const JSList* parameters)
......@@ -201,7 +201,7 @@ JackLoadableInternalClient::~JackLoadableInternalClient()
int JackLoadableInternalClient1::Open(const char* server_name, const char* name, int uuid, jack_options_t options, jack_status_t* status)
{
int res = -1;
if (JackInternalClient::Open(server_name, name, uuid, options, status) == 0) {
if (fInitialize((jack_client_t*)this, fObjectData) == 0) {
res = 0;
......@@ -210,14 +210,14 @@ int JackLoadableInternalClient1::Open(const char* server_name, const char* name,
fFinish = NULL;
}
}
return res;
}
int JackLoadableInternalClient2::Open(const char* server_name, const char* name, int uuid, jack_options_t options, jack_status_t* status)
{
int res = -1;
if (JackInternalClient::Open(server_name, name, uuid, options, status) == 0) {
if (fInitialize((jack_client_t*)this, fParameters) == 0) {
res = 0;
......@@ -226,7 +226,7 @@ int JackLoadableInternalClient2::Open(const char* server_name, const char* name,
fFinish = NULL;
}
}
return res;
}
......
......@@ -39,23 +39,23 @@ extern "C"
}
jack_varargs_t;
static const char* jack_default_server_name (void)
{
static const char* jack_default_server_name (void)
{
const char *server_name;
if ((server_name = getenv("JACK_DEFAULT_SERVER")) == NULL)
server_name = "default";
return server_name;
}
static inline void jack_varargs_init (jack_varargs_t *va)
{
static inline void jack_varargs_init (jack_varargs_t *va)
{
memset (va, 0, sizeof(jack_varargs_t));
va->server_name = (char*)jack_default_server_name();
va->session_id = -1;
}
static inline void jack_varargs_parse (jack_options_t options, va_list ap, jack_varargs_t *va)
{
static inline void jack_varargs_parse (jack_options_t options, va_list ap, jack_varargs_t *va)
{
// initialize default settings
jack_varargs_init (va);
......
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