diff --git a/src/channel.h b/src/channel.h index eea8b0c8e2..946eae007a 100644 --- a/src/channel.h +++ b/src/channel.h @@ -49,6 +49,7 @@ #include #include #include +#include #if QT_VERSION >= QT_VERSION_CHECK( 5, 6, 0 ) # include #endif @@ -231,14 +232,14 @@ class CChannel : public QObject // network protocol CProtocol Protocol; - int iConTimeOut; - int iConTimeOutStartVal; - int iFadeInCnt; - int iFadeInCntMax; + std::atomic iConTimeOut; + int iConTimeOutStartVal; + int iFadeInCnt; + int iFadeInCntMax; - bool bIsEnabled; - bool bIsServer; - bool bIsIdentified; + std::atomic bIsEnabled; + bool bIsServer; + bool bIsIdentified; int iNetwFrameSizeFact; int iNetwFrameSize; diff --git a/src/client.h b/src/client.h index fb77930723..5997dfe886 100644 --- a/src/client.h +++ b/src/client.h @@ -51,6 +51,7 @@ #include #include #include +#include #ifdef USE_OPUS_SHARED_LIB # include "opus/opus_custom.h" #else @@ -390,8 +391,8 @@ class CClient : public QObject EAudChanConf eAudioChannelConf; int iNumAudioChannels; bool bIsInitializationPhase; - bool bMuteOutStream; - float fMuteOutStreamGain; + std::atomic bMuteOutStream; + std::atomic fMuteOutStreamGain; CVector vecCeltData; bool bIPv6Available; // must be before Socket - passed by reference to Socket @@ -402,11 +403,11 @@ class CClient : public QObject CVector vecbyNetwData; - int iAudioInFader; - bool bReverbOnLeftChan; - int iReverbLevel; - CAudioReverb AudioReverb; - int iInputBoost; + std::atomic iAudioInFader; + std::atomic bReverbOnLeftChan; + std::atomic iReverbLevel; + CAudioReverb AudioReverb; + std::atomic iInputBoost; int iSndCrdPrefFrameSizeFactor; int iSndCrdFrameSizeFactor; diff --git a/src/server.cpp b/src/server.cpp index 2fd6b2a9bf..8daca7f0fd 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -944,9 +944,9 @@ void CServer::DecodeReceiveData ( const int iChanCnt, const int iNumClients ) FreeChannel ( iCurChanID ); // note that the channel is now not in use - // note that no mutex is needed for this shared resource since it is not a - // read-modify-write operation but an atomic write and also each thread can - // only set it to true and never to false + // note that no mutex is needed for this shared resource since it is a + // std::atomic write (not a read-modify-write operation) and also each + // thread can only set it to true and never to false bChannelIsNowDisconnected = true; // since the channel is no longer in use, we should return diff --git a/src/server.h b/src/server.h index 3e99ebb3dc..c2617a17ce 100644 --- a/src/server.h +++ b/src/server.h @@ -51,6 +51,7 @@ #include #include #include +#include #ifdef USE_OPUS_SHARED_LIB # include "opus/opus_custom.h" #else @@ -254,10 +255,10 @@ class CServer : public QObject, public CServerSlots int vecChannelOrder[MAX_NUM_CHANNELS]; QMutex MutexChanOrder; - CProtocol ConnLessProtocol; - QMutex Mutex; - QMutex MutexWelcomeMessage; - bool bChannelIsNowDisconnected; + CProtocol ConnLessProtocol; + QMutex Mutex; + QMutex MutexWelcomeMessage; + std::atomic bChannelIsNowDisconnected; // audio encoder/decoder OpusCustomMode* Opus64Mode[MAX_NUM_CHANNELS];