diff --git a/common/JackClient.cpp b/common/JackClient.cpp index 39dfbe81..834d541f 100644 --- a/common/JackClient.cpp +++ b/common/JackClient.cpp @@ -149,8 +149,9 @@ void JackClient::SetupDriverSync(bool freewheel) } } else { jack_log("JackClient::SetupDriverSync driver sem in normal mode"); - for (int i = 0; i < GetEngineControl()->fDriverNum; i++) + for (int i = 0; i < GetEngineControl()->fDriverNum; i++) { fSynchroTable[i].SetFlush(false); + } } } @@ -339,7 +340,7 @@ int JackClient::HandleLatencyCallback(int status) list::iterator it; for (it = fPortList.begin(); it != fPortList.end(); it++) { - JackPort* port = GetGraphManager()->GetPort(*it); + JackPort* port = GetGraphManager()->GetPort(*it); if ((port->GetFlags() & JackPortIsOutput) && (mode == JackPlaybackLatency)) { GetGraphManager()->RecalculateLatency(*it, mode); } diff --git a/common/JackClientControl.h b/common/JackClientControl.h index 925f09dd..23b536af 100644 --- a/common/JackClientControl.h +++ b/common/JackClientControl.h @@ -68,8 +68,9 @@ struct JackClientControl : public JackShmMemAble void Init(const char* name, int pid, int refnum, int uuid) { strcpy(fName, name); - for (int i = 0; i < kMaxNotification; i++) + for (int i = 0; i < kMaxNotification; i++) { fCallback[i] = false; + } // Always activated fCallback[kAddClient] = true; fCallback[kRemoveClient] = true; diff --git a/common/JackConnectionManager.cpp b/common/JackConnectionManager.cpp index 2be93fc9..cefb39fd 100644 --- a/common/JackConnectionManager.cpp +++ b/common/JackConnectionManager.cpp @@ -69,8 +69,9 @@ bool JackConnectionManager::IsLoopPathAux(int ref1, int ref2) const return true; } else { for (int i = 0; i < CLIENT_NUM && output[i] != EMPTY; i++) { // Otherwise recurse for all ref1 outputs - if (IsLoopPathAux(output[i], ref2)) + if (IsLoopPathAux(output[i], ref2)) { return true; // Stop when a path is found + } } return false; } @@ -304,8 +305,9 @@ void JackConnectionManager::TopologicalSort(std::vector& sorted) tmp.ClearItem(refnum, dst); jack_int_t output_ref2[CLIENT_NUM]; tmp.GetOutputTable1(dst, output_ref2); - if (HasNoConnection(output_ref2)) + if (HasNoConnection(output_ref2)) { level.insert(dst); + } } } } @@ -380,8 +382,9 @@ bool JackConnectionManager::IsDirectConnection(int ref1, int ref2) const int JackConnectionManager::GetInputRefNum(jack_port_id_t port_index) const { for (int i = 0; i < CLIENT_NUM; i++) { - if (fInputPort[i].CheckItem(port_index)) + if (fInputPort[i].CheckItem(port_index)) { return i; + } } return -1; @@ -393,8 +396,9 @@ int JackConnectionManager::GetInputRefNum(jack_port_id_t port_index) const int JackConnectionManager::GetOutputRefNum(jack_port_id_t port_index) const { for (int i = 0; i < CLIENT_NUM; i++) { - if (fOutputPort[i].CheckItem(port_index)) + if (fOutputPort[i].CheckItem(port_index)) { return i; + } } return -1; @@ -422,8 +426,9 @@ bool JackConnectionManager::IncFeedbackConnection(jack_port_id_t port_src, jack_ jack_log("JackConnectionManager::IncFeedbackConnection ref1 = %ld ref2 = %ld", ref1, ref2); assert(ref1 >= 0 && ref2 >= 0); - if (ref1 != ref2) + if (ref1 != ref2) { DirectConnect(ref2, ref1); + } return fLoopFeedback.IncConnection(ref1, ref2); // Add the feedback connection } @@ -437,8 +442,9 @@ bool JackConnectionManager::DecFeedbackConnection(jack_port_id_t port_src, jack_ jack_log("JackConnectionManager::DecFeedbackConnection ref1 = %ld ref2 = %ld", ref1, ref2); assert(ref1 >= 0 && ref2 >= 0); - if (ref1 != ref2) + if (ref1 != ref2) { DirectDisconnect(ref2, ref1); + } return fLoopFeedback.DecConnection(ref1, ref2); // Remove the feedback connection } diff --git a/common/JackEngine.cpp b/common/JackEngine.cpp index 771ad445..146a8ce8 100644 --- a/common/JackEngine.cpp +++ b/common/JackEngine.cpp @@ -271,10 +271,7 @@ int JackEngine::ComputeTotalLatencies() int JackEngine::ClientNotify(JackClientInterface* client, int refnum, const char* name, int notify, int sync, const char* message, int value1, int value2) { - if (!client) { - return 0; - } - + // Check if notification is needed if (!client->GetClientControl()->fCallback[notify]) { jack_log("JackEngine::ClientNotify: no callback for notification = %ld", notify); return 0; @@ -342,7 +339,10 @@ void JackEngine::NotifyRemoveClient(const char* name, int refnum) { // Notify existing clients (including the one beeing suppressed) of the removed client for (int i = 0; i < CLIENT_NUM; i++) { - ClientNotify(fClientTable[i], refnum, name, kRemoveClient, false, "", 0, 0); + JackClientInterface* client = fClientTable[refnum]; + if (client) { + ClientNotify(fClientTable[i], refnum, name, kRemoveClient, false, "", 0, 0); + } } } @@ -425,6 +425,7 @@ void JackEngine::NotifyActivate(int refnum) int JackEngine::GetInternalClientName(int refnum, char* name_res) { JackClientInterface* client = fClientTable[refnum]; + assert(client); strncpy(name_res, client->GetClientControl()->fName, JACK_CLIENT_NAME_SIZE); return 0; } @@ -712,6 +713,7 @@ int JackEngine::ClientExternalClose(int refnum) { jack_log("JackEngine::ClientExternalClose ref = %ld", refnum); JackClientInterface* client = fClientTable[refnum]; + assert(client); int res = ClientCloseAux(refnum, true); client->Close(); delete client; @@ -887,6 +889,7 @@ int JackEngine::PortUnRegister(int refnum, jack_port_id_t port_index) { jack_log("JackEngine::PortUnRegister ref = %ld port_index = %ld", refnum, port_index); JackClientInterface* client = fClientTable[refnum]; + assert(client); // Disconnect port ==> notification is sent PortDisconnect(refnum, port_index, ALL_PORTS); @@ -1080,6 +1083,7 @@ void JackEngine::SessionNotify(int refnum, const char *target, jack_session_even int JackEngine::SessionReply(int refnum) { JackClientInterface* client = fClientTable[refnum]; + assert(client); char uuid_buf[JACK_UUID_SIZE]; snprintf(uuid_buf, sizeof(uuid_buf), "%d", client->GetClientControl()->fSessionID); fSessionResult->fCommandList.push_back(JackSessionCommand(uuid_buf, diff --git a/common/JackEngineControl.h b/common/JackEngineControl.h index f6d32f44..7101b9ce 100644 --- a/common/JackEngineControl.h +++ b/common/JackEngineControl.h @@ -70,11 +70,11 @@ struct SERVER_EXPORT JackEngineControl : public JackShmMem bool fVerbose; // CPU Load - jack_time_t fPrevCycleTime; - jack_time_t fCurCycleTime; - jack_time_t fSpareUsecs; - jack_time_t fMaxUsecs; - jack_time_t fRollingClientUsecs[JACK_ENGINE_ROLLING_COUNT]; + jack_time_t fPrevCycleTime; + jack_time_t fCurCycleTime; + jack_time_t fSpareUsecs; + jack_time_t fMaxUsecs; + jack_time_t fRollingClientUsecs[JACK_ENGINE_ROLLING_COUNT]; unsigned int fRollingClientUsecsCnt; int fRollingClientUsecsIndex; int fRollingInterval; diff --git a/common/JackFilters.h b/common/JackFilters.h index 6b5f0d32..e245d58b 100644 --- a/common/JackFilters.h +++ b/common/JackFilters.h @@ -46,8 +46,9 @@ namespace Jack JackFilter() { - for (int i = 0; i < MAX_SIZE; i++) + for (int i = 0; i < MAX_SIZE; i++) { fTable[i] = 0; + } } void AddValue(jack_time_t val) @@ -59,8 +60,9 @@ namespace Jack jack_time_t GetVal() { jack_time_t mean = 0; - for (int i = 0; i < MAX_SIZE; i++) + for (int i = 0; i < MAX_SIZE; i++) { mean += fTable[i]; + } return mean / MAX_SIZE; } diff --git a/common/JackNotification.h b/common/JackNotification.h index 673ab838..74b9df4b 100644 --- a/common/JackNotification.h +++ b/common/JackNotification.h @@ -47,7 +47,7 @@ enum NotificationType { kQUIT = 16, kSessionCallback = 17, kLatencyCallback = 18, - kMaxNotification + kMaxNotification = 64 // To keep some room in JackClientControl fCallback table }; } // end of namespace diff --git a/macosx/coreaudio/JackCoreAudioAdapter.cpp b/macosx/coreaudio/JackCoreAudioAdapter.cpp index 3cf08ad6..f4a79bc2 100644 --- a/macosx/coreaudio/JackCoreAudioAdapter.cpp +++ b/macosx/coreaudio/JackCoreAudioAdapter.cpp @@ -167,11 +167,11 @@ OSStatus JackCoreAudioAdapter::AudioHardwareNotificationCallback(AudioHardwarePr switch (inPropertyID) { - case kAudioHardwarePropertyDevices: { - jack_log("JackCoreAudioAdapter::AudioHardwareNotificationCallback kAudioHardwarePropertyDevices"); - DisplayDeviceNames(); - break; - } + case kAudioHardwarePropertyDevices: { + jack_log("JackCoreAudioAdapter::AudioHardwareNotificationCallback kAudioHardwarePropertyDevices"); + DisplayDeviceNames(); + break; + } } return noErr;