code cleanup;

4.11f_maint
Bryan Biedenkapp 11 months ago
parent e38488f602
commit 086730320d

@ -658,8 +658,7 @@ int HostBridge::run()
// -- Network Clocking -- // -- Network Clocking --
// ------------------------------------------------------ // ------------------------------------------------------
if (m_network != nullptr) if (m_network != nullptr) {
{
std::lock_guard<std::mutex> lock(HostBridge::m_networkMutex); std::lock_guard<std::mutex> lock(HostBridge::m_networkMutex);
m_network->clock(ms); m_network->clock(ms);
} }
@ -2434,11 +2433,12 @@ void HostBridge::encodeP25AudioFrame(uint8_t* pcm, uint32_t forcedSrcId, uint32_
/* Helper to send USRP end of transmission */ /* Helper to send USRP end of transmission */
void HostBridge::sendUsrpEot() { void HostBridge::sendUsrpEot()
{
sockaddr_storage addr; sockaddr_storage addr;
uint32_t addrLen; uint32_t addrLen;
uint8_t* usrpHeader = new uint8_t[USRP_HEADER_LENGTH]; uint8_t usrpHeader[USRP_HEADER_LENGTH];
m_usrpSeqNo = 0U; m_usrpSeqNo = 0U;
::memcpy(usrpHeader, "USRP", 4); ::memcpy(usrpHeader, "USRP", 4);
@ -2621,18 +2621,12 @@ void* HostBridge::threadAudioProcess(void* arg)
::pthread_setname_np(th->thread, threadName.c_str()); ::pthread_setname_np(th->thread, threadName.c_str());
#endif // _GNU_SOURCE #endif // _GNU_SOURCE
StopWatch stopWatch;
stopWatch.start();
while (!g_killed) { while (!g_killed) {
if (!bridge->m_running) { if (!bridge->m_running) {
Thread::sleep(1U); Thread::sleep(1U);
continue; continue;
} }
uint32_t ms = stopWatch.elapsed();
stopWatch.start();
// scope is intentional // scope is intentional
{ {
std::lock_guard<std::mutex> lock(m_audioMutex); std::lock_guard<std::mutex> lock(m_audioMutex);
@ -2779,18 +2773,12 @@ void* HostBridge::threadNetworkProcess(void* arg)
::pthread_setname_np(th->thread, threadName.c_str()); ::pthread_setname_np(th->thread, threadName.c_str());
#endif // _GNU_SOURCE #endif // _GNU_SOURCE
StopWatch stopWatch;
stopWatch.start();
while (!g_killed) { while (!g_killed) {
if (!bridge->m_running) { if (!bridge->m_running) {
Thread::sleep(1U); Thread::sleep(1U);
continue; continue;
} }
uint32_t ms = stopWatch.elapsed();
stopWatch.start();
uint32_t length = 0U; uint32_t length = 0U;
bool netReadRet = false; bool netReadRet = false;
if (bridge->m_txMode == TX_MODE_DMR) { if (bridge->m_txMode == TX_MODE_DMR) {

@ -182,7 +182,7 @@ namespace lookups
* @brief Helper to set the reload time of this lookup table. * @brief Helper to set the reload time of this lookup table.
* @param reloadTime Lookup time in seconds. * @param reloadTime Lookup time in seconds.
*/ */
void setReloadTime(uint32_t reloadTime) { m_reloadTime = 0U; } void setReloadTime(uint32_t reloadTime) { m_reloadTime = reloadTime; }
protected: protected:
std::string m_filename; std::string m_filename;

@ -603,7 +603,7 @@ namespace lookups
* @brief Helper to set the reload time of this lookup table. * @brief Helper to set the reload time of this lookup table.
* @param reloadTime Lookup time in seconds. * @param reloadTime Lookup time in seconds.
*/ */
void setReloadTime(uint32_t reloadTime) { m_reloadTime = 0U; } void setReloadTime(uint32_t reloadTime) { m_reloadTime = reloadTime; }
private: private:
std::string m_rulesFile; std::string m_rulesFile;

@ -333,6 +333,7 @@ bool Socket::write(const uint8_t* buffer, uint32_t length, const sockaddr_storag
cryptedLen += alignment; cryptedLen += alignment;
// reallocate buffer and copy // reallocate buffer and copy
delete[] cryptoBuffer;
cryptoBuffer = new uint8_t[cryptedLen]; cryptoBuffer = new uint8_t[cryptedLen];
::memset(cryptoBuffer, 0x00U, cryptedLen); ::memset(cryptoBuffer, 0x00U, cryptedLen);
::memcpy(cryptoBuffer, buffer, length); ::memcpy(cryptoBuffer, buffer, length);

@ -122,13 +122,13 @@ namespace p25
m_netId = dist(mt); m_netId = dist(mt);
// netId clamping // netId clamping
netId = P25Utils::netId(netId); m_netId = P25Utils::netId(netId);
dist = std::uniform_int_distribution<uint32_t>(0x01, 0xFFEU); dist = std::uniform_int_distribution<uint32_t>(0x01, 0xFFEU);
m_sysId = dist(mt); m_sysId = dist(mt);
// sysId clamping // sysId clamping
sysId = P25Utils::sysId(sysId); m_sysId = P25Utils::sysId(sysId);
} }
m_rfssId = rfssId; m_rfssId = rfssId;

@ -281,18 +281,18 @@ int HostFNE::run()
} }
if (m_tidLookup != nullptr) { if (m_tidLookup != nullptr) {
m_tidLookup->setReloadTime(0U); // no reload
m_tidLookup->stop(); m_tidLookup->stop();
delete m_tidLookup;
} }
if (m_ridLookup != nullptr) { if (m_ridLookup != nullptr) {
m_ridLookup->setReloadTime(0U); // no reload
m_ridLookup->stop(); m_ridLookup->stop();
delete m_ridLookup;
} }
if (m_peerListLookup != nullptr) { if (m_peerListLookup != nullptr) {
m_peerListLookup->setReloadTime(0U); // no reload
m_peerListLookup->stop(); m_peerListLookup->stop();
delete m_peerListLookup;
} }
#if !defined(_WIN32) #if !defined(_WIN32)
if (m_tun != nullptr) { if (m_tun != nullptr) {

@ -1666,12 +1666,12 @@ void Host::setState(uint8_t state)
} }
if (m_tidLookup != nullptr) { if (m_tidLookup != nullptr) {
m_tidLookup->setReloadTime(0U);
m_tidLookup->stop(); m_tidLookup->stop();
//delete m_tidLookup;
} }
if (m_ridLookup != nullptr) { if (m_ridLookup != nullptr) {
m_tidLookup->setReloadTime(0U);
m_ridLookup->stop(); m_ridLookup->stop();
//delete m_ridLookup;
} }
} }
else { else {

@ -1317,7 +1317,7 @@ void Control::processNetwork()
} }
if (!m_dedicatedControl) if (!m_dedicatedControl)
ret = m_data->processNetwork(data.get(), frameLength, blockLength); m_data->processNetwork(data.get(), frameLength, blockLength);
return; return;
} }
@ -1414,7 +1414,7 @@ void Control::processNetwork()
break; break;
} }
ret = m_voice->processNetwork(data.get(), frameLength, control, lsd, duid, frameType); m_voice->processNetwork(data.get(), frameLength, control, lsd, duid, frameType);
break; break;
case DUID::TDU: case DUID::TDU:

Loading…
Cancel
Save

Powered by TurnKey Linux.