diff --git a/mac/sound.cpp b/mac/sound.cpp index 4f708da7..18adbaf0 100755 --- a/mac/sound.cpp +++ b/mac/sound.cpp @@ -163,7 +163,7 @@ CSound::CSound ( void (*fpNewProcessCallback) ( CVector& psData } // init device index as not initialized (invalid) - lCurDev = INVALID_SNC_CARD_DEVICE; + lCurDev = INVALID_INDEX; CurrentAudioInputDeviceID = 0; CurrentAudioOutputDeviceID = 0; iNumInChan = 0; @@ -611,12 +611,12 @@ void CSound::UpdateChSelection() int iSelCHRight, iSelAddCHRight; // initialize all buffer indexes with an invalid value - iSelInBufferLeft = -1; - iSelInBufferRight = -1; - iSelAddInBufferLeft = -1; // if no additional channel used, this will stay on the invalid value - iSelAddInBufferRight = -1; // if no additional channel used, this will stay on the invalid value - iSelOutBufferLeft = -1; - iSelOutBufferRight = -1; + iSelInBufferLeft = INVALID_INDEX; + iSelInBufferRight = INVALID_INDEX; + iSelAddInBufferLeft = INVALID_INDEX; // if no additional channel used, this will stay on the invalid value + iSelAddInBufferRight = INVALID_INDEX; // if no additional channel used, this will stay on the invalid value + iSelOutBufferLeft = INVALID_INDEX; + iSelOutBufferRight = INVALID_INDEX; // input GetSelCHAndAddCH ( iSelInputLeftChannel, iNumInChan, iSelCHLeft, iSelAddCHLeft ); diff --git a/src/global.h b/src/global.h index 6183cd2b..5e2aeafd 100755 --- a/src/global.h +++ b/src/global.h @@ -152,10 +152,8 @@ LED bar: lbr #define AUD_MIX_FADER_MAX 100 #define AUD_MIX_PAN_MAX 100 -// maximum number of recognized sound cards installed in the system, -// definition for "no device" +// maximum number of recognized sound cards installed in the system #define MAX_NUMBER_SOUND_CARDS 129 // e.g. 16 inputs, 8 outputs + default entry (MacOS) -#define INVALID_SNC_CARD_DEVICE -1 // define the maximum number of audio channel for input/output we can store // channel infos for (and therefore this is the maximum number of entries in @@ -173,7 +171,7 @@ LED bar: lbr #define LOW_BOUND_SIG_METER ( -50.0 ) // dB #define UPPER_BOUND_SIG_METER ( 0.0 ) // dB -// Maximum number of connected clients at the server. +// maximum number of connected clients at the server (must not be larger than 256) #define MAX_NUM_CHANNELS 50 // max number channels for server // actual number of used channels in the server @@ -239,8 +237,8 @@ LED bar: lbr "" #define _MAXSHORT 32767 -#define _MAXBYTE 255 // binary: 11111111 #define _MINSHORT ( -32768 ) +#define INVALID_INDEX -1 // define invalid index as a negative value (a valid index must always be >= 0) #if HAVE_STDINT_H # include diff --git a/src/serverlist.cpp b/src/serverlist.cpp index 8e0a0f17..1d8e1a48 100755 --- a/src/serverlist.cpp +++ b/src/serverlist.cpp @@ -353,14 +353,11 @@ void CServerListManager::CentralServerRegisterServer ( const CHostAddress& In QMutexLocker locker ( &Mutex ); const int iCurServerListSize = ServerList.size(); - - // define invalid index used as a flag - const int ciInvalidIdx = -1; // Check if server is already registered. // The very first list entry must not be checked since // this is per definition the central server (i.e., this server) - int iSelIdx = ciInvalidIdx; // initialize with an illegal value + int iSelIdx = INVALID_INDEX; // initialize with an illegal value for ( int iIdx = 1; iIdx < iCurServerListSize; iIdx++ ) { if ( ServerList[iIdx].HostAddr == InetAddr ) @@ -374,7 +371,7 @@ void CServerListManager::CentralServerRegisterServer ( const CHostAddress& In } // if server is not yet registered, we have to create a new entry - if ( iSelIdx == ciInvalidIdx ) + if ( iSelIdx == INVALID_INDEX ) { // check for maximum allowed number of servers in the server list if ( iCurServerListSize < MAX_NUM_SERVERS_IN_SERVER_LIST ) @@ -401,7 +398,7 @@ void CServerListManager::CentralServerRegisterServer ( const CHostAddress& In } } - pConnLessProtocol->CreateCLRegisterServerResp ( InetAddr, iSelIdx == ciInvalidIdx + pConnLessProtocol->CreateCLRegisterServerResp ( InetAddr, iSelIdx == INVALID_INDEX ? ESvrRegResult::SRR_CENTRAL_SVR_FULL : ESvrRegResult::SRR_REGISTERED ); } diff --git a/src/settings.cpp b/src/settings.cpp index e8d859f1..b115db77 100755 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -189,9 +189,9 @@ void CSettings::Load() } else { - // use "INVALID_SNC_CARD_DEVICE" to tell the sound card driver that + // use "INVALID_INDEX" to tell the sound card driver that // no device selection was done previously - pClient->SetSndCrdDev ( INVALID_SNC_CARD_DEVICE ); + pClient->SetSndCrdDev ( INVALID_INDEX ); } // sound card channel mapping settings: make sure these settings are diff --git a/src/soundbase.cpp b/src/soundbase.cpp index 6c25d810..daadacff 100755 --- a/src/soundbase.cpp +++ b/src/soundbase.cpp @@ -116,7 +116,7 @@ QString CSoundBase::SetDev ( const int iNewDev ) } // check if an ASIO driver was already initialized - if ( lCurDev != INVALID_SNC_CARD_DEVICE ) + if ( lCurDev != INVALID_INDEX ) { // a device was already been initialized and is used, first clean up // driver @@ -158,7 +158,7 @@ QString CSoundBase::SetDev ( const int iNewDev ) // init flag for "load any driver" bool bTryLoadAnyDriver = false; - if ( iNewDev != INVALID_SNC_CARD_DEVICE ) + if ( iNewDev != INVALID_INDEX ) { // This is the first time a driver is to be initialized, we first // try to load the selected driver, if this fails, we try to load diff --git a/src/soundbase.h b/src/soundbase.h index f11d434c..32b62b5e 100755 --- a/src/soundbase.h +++ b/src/soundbase.h @@ -113,7 +113,7 @@ protected: } else { - iSelAddCHOut = -1; // set it to an invalid number + iSelAddCHOut = INVALID_INDEX; // set it to an invalid number iSelCHOut = iSelCH; } } diff --git a/src/util.h b/src/util.h index bdf7818f..ebeeb05e 100755 --- a/src/util.h +++ b/src/util.h @@ -212,7 +212,7 @@ template int CVector::StringFiFoWithCompare ( const QString CVector vstrTempList ( iVectorSize, "" ); // init with illegal index per definition - int iOldIndex = -1; + int iOldIndex = INVALID_INDEX; // init temporary list count (may be overwritten later on) int iTempListCnt = 0; @@ -1249,11 +1249,11 @@ public: CTimingMeas ( const int iNNMeas, const QString strNFName = "" ) : iNumMeas ( iNNMeas ), vElapsedTimes ( iNNMeas ), strFileName ( strNFName ) { Reset(); } - void Reset() { iCnt = -1; } + void Reset() { iCnt = INVALID_INDEX; } void Measure() { // exclude the very first measurement (initialization phase) - if ( iCnt == -1 ) + if ( iCnt == INVALID_INDEX ) { iCnt = 0; } diff --git a/windows/sound.cpp b/windows/sound.cpp index d3633d97..82cf37b0 100755 --- a/windows/sound.cpp +++ b/windows/sound.cpp @@ -533,7 +533,7 @@ CSound::CSound ( void (*fpNewCallback) ( CVector& psData, voi } // init device index as not initialized (invalid) - lCurDev = INVALID_SNC_CARD_DEVICE; + lCurDev = INVALID_INDEX; // init channel mapping ResetChannelMapping();