@@ -117,7 +117,10 @@ int JackClient::Close() | |||||
} | } | ||||
fChannel->Close(); | fChannel->Close(); | ||||
assert(JackGlobals::fSynchroMutex); | |||||
JackGlobals::fSynchroMutex->Lock(); | |||||
fSynchroTable[GetClientControl()->fRefNum].Disconnect(); | fSynchroTable[GetClientControl()->fRefNum].Disconnect(); | ||||
JackGlobals::fSynchroMutex->Unlock(); | |||||
JackGlobals::fClientTable[GetClientControl()->fRefNum] = NULL; | JackGlobals::fClientTable[GetClientControl()->fRefNum] = NULL; | ||||
return result; | return result; | ||||
} | } | ||||
@@ -34,6 +34,7 @@ jack_tls_key JackGlobals::fKeyLogFunction; | |||||
static bool fKeyLogFunctionInitialized = jack_tls_allocate_key(&JackGlobals::fKeyLogFunction); | static bool fKeyLogFunctionInitialized = jack_tls_allocate_key(&JackGlobals::fKeyLogFunction); | ||||
JackMutex* JackGlobals::fOpenMutex = new JackMutex(); | JackMutex* JackGlobals::fOpenMutex = new JackMutex(); | ||||
JackMutex* JackGlobals::fSynchroMutex = new JackMutex(); | |||||
volatile bool JackGlobals::fServerRunning = false; | volatile bool JackGlobals::fServerRunning = false; | ||||
JackClient* JackGlobals::fClientTable[CLIENT_NUM] = {}; | JackClient* JackGlobals::fClientTable[CLIENT_NUM] = {}; | ||||
@@ -41,8 +41,9 @@ struct JackGlobals { | |||||
static jack_tls_key fNotificationThread; | static jack_tls_key fNotificationThread; | ||||
static jack_tls_key fKeyLogFunction; | static jack_tls_key fKeyLogFunction; | ||||
static JackMutex* fOpenMutex; | static JackMutex* fOpenMutex; | ||||
static JackMutex* fSynchroMutex; | |||||
static volatile bool fServerRunning; | static volatile bool fServerRunning; | ||||
static JackClient* fClientTable[]; | |||||
static JackClient* fClientTable[CLIENT_NUM]; | |||||
static bool fVerbose; | static bool fVerbose; | ||||
#ifndef WIN32 | #ifndef WIN32 | ||||
static jack_thread_creator_t fJackThreadCreator; | static jack_thread_creator_t fJackThreadCreator; | ||||
@@ -84,6 +84,7 @@ JackLibClient::~JackLibClient() | |||||
int JackLibClient::Open(const char* server_name, const char* name, int uuid, jack_options_t options, jack_status_t* status) | int JackLibClient::Open(const char* server_name, const char* name, int uuid, jack_options_t options, jack_status_t* status) | ||||
{ | { | ||||
int shared_engine, shared_client, shared_graph, result; | int shared_engine, shared_client, shared_graph, result; | ||||
bool res; | |||||
jack_log("JackLibClient::Open name = %s", name); | jack_log("JackLibClient::Open name = %s", name); | ||||
strncpy(fServerName, server_name, sizeof(fServerName)); | strncpy(fServerName, server_name, sizeof(fServerName)); | ||||
@@ -122,7 +123,11 @@ int JackLibClient::Open(const char* server_name, const char* name, int uuid, jac | |||||
SetupDriverSync(false); | SetupDriverSync(false); | ||||
// Connect shared synchro : the synchro must be usable in I/O mode when several clients live in the same process | // Connect shared synchro : the synchro must be usable in I/O mode when several clients live in the same process | ||||
if (!fSynchroTable[GetClientControl()->fRefNum].Connect(name_res, fServerName)) { | |||||
assert(JackGlobals::fSynchroMutex); | |||||
JackGlobals::fSynchroMutex->Lock(); | |||||
res = fSynchroTable[GetClientControl()->fRefNum].Connect(name_res, fServerName); | |||||
JackGlobals::fSynchroMutex->Unlock(); | |||||
if (!res) { | |||||
jack_error("Cannot ConnectSemaphore %s client", name_res); | jack_error("Cannot ConnectSemaphore %s client", name_res); | ||||
goto error; | goto error; | ||||
} | } | ||||
@@ -145,6 +150,8 @@ error: | |||||
int JackLibClient::ClientNotifyImp(int refnum, const char* name, int notify, int sync, const char* message, int value1, int value2) | int JackLibClient::ClientNotifyImp(int refnum, const char* name, int notify, int sync, const char* message, int value1, int value2) | ||||
{ | { | ||||
int res = 0; | int res = 0; | ||||
assert(JackGlobals::fSynchroMutex); | |||||
JackGlobals::fSynchroMutex->Lock(); | |||||
// Done all time | // Done all time | ||||
switch (notify) { | switch (notify) { | ||||
@@ -157,11 +164,13 @@ int JackLibClient::ClientNotifyImp(int refnum, const char* name, int notify, int | |||||
case kRemoveClient: | case kRemoveClient: | ||||
jack_log("JackClient::RemoveClient name = %s, ref = %ld ", name, refnum); | jack_log("JackClient::RemoveClient name = %s, ref = %ld ", name, refnum); | ||||
if (GetClientControl() && strcmp(GetClientControl()->fName, name) != 0) | |||||
if (GetClientControl() && strcmp(GetClientControl()->fName, name) != 0) { | |||||
res = fSynchroTable[refnum].Disconnect() ? 0 : -1; | res = fSynchroTable[refnum].Disconnect() ? 0 : -1; | ||||
} | |||||
break; | break; | ||||
} | } | ||||
JackGlobals::fSynchroMutex->Unlock(); | |||||
return res; | return res; | ||||
} | } | ||||
@@ -31,7 +31,6 @@ namespace Jack | |||||
JackServer* JackServerGlobals::fInstance; | JackServer* JackServerGlobals::fInstance; | ||||
unsigned int JackServerGlobals::fUserCount; | unsigned int JackServerGlobals::fUserCount; | ||||
int JackServerGlobals::fRTNotificationSocket; | |||||
std::map<std::string, JackDriverInfo*> JackServerGlobals::fSlavesList; | std::map<std::string, JackDriverInfo*> JackServerGlobals::fSlavesList; | ||||
std::map<std::string, int> JackServerGlobals::fInternalsList; | std::map<std::string, int> JackServerGlobals::fInternalsList; | ||||
@@ -39,7 +39,6 @@ struct SERVER_EXPORT JackServerGlobals | |||||
{ | { | ||||
static JackServer* fInstance; | static JackServer* fInstance; | ||||
static unsigned int fUserCount; | static unsigned int fUserCount; | ||||
static int fRTNotificationSocket; // For debugging purpose | |||||
static std::map<std::string, JackDriverInfo*> fSlavesList; | static std::map<std::string, JackDriverInfo*> fSlavesList; | ||||
static std::map<std::string, int> fInternalsList; | static std::map<std::string, int> fInternalsList; | ||||
@@ -34,7 +34,6 @@ int JackSocketServerNotifyChannel::Open(const char* server_name) | |||||
return -1; | return -1; | ||||
} else { | } else { | ||||
fRequestSocket.SetNonBlocking(true); | fRequestSocket.SetNonBlocking(true); | ||||
JackServerGlobals::fRTNotificationSocket = fRequestSocket.GetFd(); | |||||
return 0; | return 0; | ||||
} | } | ||||
} | } | ||||
@@ -64,9 +64,9 @@ static inline char CAS(volatile UInt32 value, UInt32 newvalue, volatile void* ad | |||||
"# CAS \n\t" | "# CAS \n\t" | ||||
LOCK "cmpxchg %2, (%1) \n\t" | LOCK "cmpxchg %2, (%1) \n\t" | ||||
"sete %0 \n\t" | "sete %0 \n\t" | ||||
: "=a" (ret) | |||||
: "c" (addr), "d" (newvalue), "a" (value) | |||||
); | |||||
: "=a" (ret) | |||||
: "c" (addr), "d" (newvalue), "a" (value) | |||||
); | |||||
return ret; | return ret; | ||||
} | } | ||||