Commit ddb61e60 authored by Stephane Letz's avatar Stephane Letz
Browse files

Correct JackClient::OnShutdown.

parent 76491d3b
...@@ -975,6 +975,8 @@ void JackClient::OnShutdown(JackShutdownCallback callback, void *arg) ...@@ -975,6 +975,8 @@ void JackClient::OnShutdown(JackShutdownCallback callback, void *arg)
if (IsActive()) { if (IsActive()) {
jack_error("You cannot set callbacks on an active client"); jack_error("You cannot set callbacks on an active client");
} else { } else {
// Shutdown callback will either be an old API version or the new version (with info)
GetClientControl()->fCallback[kShutDownCallback] = (callback != NULL);
fShutdownArg = arg; fShutdownArg = arg;
fShutdown = callback; fShutdown = callback;
} }
...@@ -985,6 +987,7 @@ void JackClient::OnInfoShutdown(JackInfoShutdownCallback callback, void *arg) ...@@ -985,6 +987,7 @@ void JackClient::OnInfoShutdown(JackInfoShutdownCallback callback, void *arg)
if (IsActive()) { if (IsActive()) {
jack_error("You cannot set callbacks on an active client"); jack_error("You cannot set callbacks on an active client");
} else { } else {
// Shutdown callback will either be an old API version or the new version (with info)
GetClientControl()->fCallback[kShutDownCallback] = (callback != NULL); GetClientControl()->fCallback[kShutDownCallback] = (callback != NULL);
fInfoShutdownArg = arg; fInfoShutdownArg = arg;
fInfoShutdown = callback; fInfoShutdown = callback;
......
...@@ -264,24 +264,24 @@ int JackEngine::ClientNotify(JackClientInterface* client, int refnum, const char ...@@ -264,24 +264,24 @@ int JackEngine::ClientNotify(JackClientInterface* client, int refnum, const char
return 0; return 0;
} }
int ret; int res1;
// External client // External client
if (dynamic_cast<JackExternalClient*>(client)) { if (dynamic_cast<JackExternalClient*>(client)) {
ret = client->ClientNotify(refnum, name, notify, sync, message, value1, value2); res1 = client->ClientNotify(refnum, name, notify, sync, message, value1, value2);
// Important for internal client : unlock before calling the notification callbacks // Important for internal client : unlock before calling the notification callbacks
} else { } else {
bool res = Unlock(); bool res2 = Unlock();
ret = client->ClientNotify(refnum, name, notify, sync, message, value1, value2); res1 = client->ClientNotify(refnum, name, notify, sync, message, value1, value2);
if (res) { if (res2) {
Lock(); Lock();
} }
} }
if (ret < 0) { if (res1 < 0) {
jack_error("ClientNotify fails name = %s notification = %ld val1 = %ld val2 = %ld", name, notify, value1, value2); jack_error("ClientNotify fails name = %s notification = %ld val1 = %ld val2 = %ld", name, notify, value1, value2);
} }
return ret; return res1;
} }
void JackEngine::NotifyClient(int refnum, int event, int sync, const char* message, int value1, int value2) void JackEngine::NotifyClient(int refnum, int event, int sync, const char* message, int value1, int value2)
...@@ -958,22 +958,22 @@ int JackEngine::PortDisconnect(int refnum, jack_port_id_t src, jack_port_id_t ds ...@@ -958,22 +958,22 @@ int JackEngine::PortDisconnect(int refnum, jack_port_id_t src, jack_port_id_t ds
fGraphManager->GetConnections(src, connections); fGraphManager->GetConnections(src, connections);
JackPort* port = fGraphManager->GetPort(src); JackPort* port = fGraphManager->GetPort(src);
int ret = 0; int res = 0;
if (port->GetFlags() & JackPortIsOutput) { if (port->GetFlags() & JackPortIsOutput) {
for (int i = 0; (i < CONNECTION_NUM_FOR_PORT) && (connections[i] != EMPTY); i++) { for (int i = 0; (i < CONNECTION_NUM_FOR_PORT) && (connections[i] != EMPTY); i++) {
if (PortDisconnect(refnum, src, connections[i]) != 0) { if (PortDisconnect(refnum, src, connections[i]) != 0) {
ret = -1; res = -1;
} }
} }
} else { } else {
for (int i = 0; (i < CONNECTION_NUM_FOR_PORT) && (connections[i] != EMPTY); i++) { for (int i = 0; (i < CONNECTION_NUM_FOR_PORT) && (connections[i] != EMPTY); i++) {
if (PortDisconnect(refnum, connections[i], src) != 0) { if (PortDisconnect(refnum, connections[i], src) != 0) {
ret = -1; res = -1;
} }
} }
} }
return ret; return res;
} else if (fGraphManager->CheckPorts(src, dst) < 0) { } else if (fGraphManager->CheckPorts(src, dst) < 0) {
return -1; return -1;
} else if (fGraphManager->Disconnect(src, dst) == 0) { } else if (fGraphManager->Disconnect(src, dst) == 0) {
......
...@@ -640,15 +640,15 @@ namespace Jack ...@@ -640,15 +640,15 @@ namespace Jack
int JackNetMasterManager::SyncCallback(jack_transport_state_t state, jack_position_t* pos) int JackNetMasterManager::SyncCallback(jack_transport_state_t state, jack_position_t* pos)
{ {
//check if each slave is ready to roll //check if each slave is ready to roll
int ret = 1; int res = 1;
master_list_it_t it; master_list_it_t it;
for (it = fMasterList.begin(); it != fMasterList.end(); it++) { for (it = fMasterList.begin(); it != fMasterList.end(); it++) {
if (!(*it)->IsSlaveReadyToRoll()) { if (!(*it)->IsSlaveReadyToRoll()) {
ret = 0; res = 0;
} }
} }
jack_log("JackNetMasterManager::SyncCallback returns '%s'", (ret) ? "true" : "false"); jack_log("JackNetMasterManager::SyncCallback returns '%s'", (res) ? "true" : "false");
return ret; return res;
} }
void* JackNetMasterManager::NetManagerThread(void* arg) void* JackNetMasterManager::NetManagerThread(void* arg)
......
...@@ -114,7 +114,7 @@ bool JackServerGlobals::Init() ...@@ -114,7 +114,7 @@ bool JackServerGlobals::Init()
int loopback = 0; int loopback = 0;
int sync = 0; int sync = 0;
int rc, i; int rc, i;
int ret; int res;
int replace_registry = 0; int replace_registry = 0;
FILE* fp = 0; FILE* fp = 0;
...@@ -174,11 +174,11 @@ bool JackServerGlobals::Init() ...@@ -174,11 +174,11 @@ bool JackServerGlobals::Init()
argc = 0; argc = 0;
if (fp) { if (fp) {
ret = fscanf(fp, "%s", buffer); res = fscanf(fp, "%s", buffer);
while (ret != 0 && ret != EOF) { while (res != 0 && res != EOF) {
argv[argc] = (char*)malloc(64); argv[argc] = (char*)malloc(64);
strcpy(argv[argc], buffer); strcpy(argv[argc], buffer);
ret = fscanf(fp, "%s", buffer); res = fscanf(fp, "%s", buffer);
argc++; argc++;
} }
fclose(fp); fclose(fp);
......
...@@ -140,7 +140,7 @@ static jack_time_t jack_get_mhz (void) ...@@ -140,7 +140,7 @@ static jack_time_t jack_get_mhz (void)
if (f == 0) if (f == 0)
{ {
perror("can't open /proc/cpuinfo\n"); perror("can't open /proc/cpuinfo\n");
exit(1); exit(1); // TODO : should be remplaced by an exception
} }
for (;;) for (;;)
...@@ -150,9 +150,8 @@ static jack_time_t jack_get_mhz (void) ...@@ -150,9 +150,8 @@ static jack_time_t jack_get_mhz (void)
char buf[1000]; char buf[1000];
if (fgets(buf, sizeof(buf), f) == NULL) { if (fgets(buf, sizeof(buf), f) == NULL) {
jack_error ("FATAL: cannot locate cpu MHz in " jack_error ("FATAL: cannot locate cpu MHz in /proc/cpuinfo\n");
"/proc/cpuinfo\n"); exit(1); // TODO : should be remplaced by an exception
exit(1);
} }
#if defined(__powerpc__) #if defined(__powerpc__)
...@@ -225,42 +224,42 @@ SERVER_EXPORT void EndTime() ...@@ -225,42 +224,42 @@ SERVER_EXPORT void EndTime()
void SetClockSource(jack_timer_type_t source) void SetClockSource(jack_timer_type_t source)
{ {
jack_log("Clock source : %s", ClockSourceName(source)); jack_log("Clock source : %s", ClockSourceName(source));
switch (source) switch (source)
{ {
case JACK_TIMER_CYCLE_COUNTER: case JACK_TIMER_CYCLE_COUNTER:
_jack_get_microseconds = jack_get_microseconds_from_cycles; _jack_get_microseconds = jack_get_microseconds_from_cycles;
break; break;
case JACK_TIMER_HPET: case JACK_TIMER_HPET:
if (jack_hpet_init () == 0) { if (jack_hpet_init () == 0) {
_jack_get_microseconds = jack_get_microseconds_from_hpet; _jack_get_microseconds = jack_get_microseconds_from_hpet;
} else { } else {
_jack_get_microseconds = jack_get_microseconds_from_system; _jack_get_microseconds = jack_get_microseconds_from_system;
} }
break; break;
case JACK_TIMER_SYSTEM_CLOCK: case JACK_TIMER_SYSTEM_CLOCK:
default: default:
_jack_get_microseconds = jack_get_microseconds_from_system; _jack_get_microseconds = jack_get_microseconds_from_system;
break; break;
} }
} }
const char* ClockSourceName(jack_timer_type_t source) const char* ClockSourceName(jack_timer_type_t source)
{ {
switch (source) { switch (source) {
case JACK_TIMER_CYCLE_COUNTER: case JACK_TIMER_CYCLE_COUNTER:
return "cycle counter"; return "cycle counter";
case JACK_TIMER_HPET: case JACK_TIMER_HPET:
return "hpet"; return "hpet";
case JACK_TIMER_SYSTEM_CLOCK: case JACK_TIMER_SYSTEM_CLOCK:
#ifdef HAVE_CLOCK_GETTIME #ifdef HAVE_CLOCK_GETTIME
return "system clock via clock_gettime"; return "system clock via clock_gettime";
#else #else
return "system clock via gettimeofday"; return "system clock via gettimeofday";
#endif #endif
} }
/* what is wrong with gcc ? */ /* what is wrong with gcc ? */
......
...@@ -93,7 +93,7 @@ static void start_server_classic_aux(const char* server_name) ...@@ -93,7 +93,7 @@ static void start_server_classic_aux(const char* server_name)
char** argv = 0; char** argv = 0;
int i = 0; int i = 0;
int good = 0; int good = 0;
int ret; int res;
snprintf(filename, 255, "%s/.jackdrc", getenv("HOME")); snprintf(filename, 255, "%s/.jackdrc", getenv("HOME"));
fp = fopen(filename, "r"); fp = fopen(filename, "r");
...@@ -108,11 +108,11 @@ static void start_server_classic_aux(const char* server_name) ...@@ -108,11 +108,11 @@ static void start_server_classic_aux(const char* server_name)
if (fp) { if (fp) {
arguments[0] = '\0'; arguments[0] = '\0';
ret = fscanf(fp, "%s", buffer); res = fscanf(fp, "%s", buffer);
while (ret != 0 && ret != EOF) { while (ret != 0 && ret != EOF) {
strcat(arguments, buffer); strcat(arguments, buffer);
strcat(arguments, " "); strcat(arguments, " ");
ret = fscanf(fp, "%s", buffer); res = fscanf(fp, "%s", buffer);
} }
if (strlen(arguments) > 0) { if (strlen(arguments) > 0) {
good = 1; good = 1;
......
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