introduce global INVALID_INDEX for more consistent code
This commit is contained in:
parent
c740a19123
commit
8552863493
8 changed files with 22 additions and 27 deletions
|
@ -163,7 +163,7 @@ CSound::CSound ( void (*fpNewProcessCallback) ( CVector<short>& psData
|
||||||
}
|
}
|
||||||
|
|
||||||
// init device index as not initialized (invalid)
|
// init device index as not initialized (invalid)
|
||||||
lCurDev = INVALID_SNC_CARD_DEVICE;
|
lCurDev = INVALID_INDEX;
|
||||||
CurrentAudioInputDeviceID = 0;
|
CurrentAudioInputDeviceID = 0;
|
||||||
CurrentAudioOutputDeviceID = 0;
|
CurrentAudioOutputDeviceID = 0;
|
||||||
iNumInChan = 0;
|
iNumInChan = 0;
|
||||||
|
@ -611,12 +611,12 @@ void CSound::UpdateChSelection()
|
||||||
int iSelCHRight, iSelAddCHRight;
|
int iSelCHRight, iSelAddCHRight;
|
||||||
|
|
||||||
// initialize all buffer indexes with an invalid value
|
// initialize all buffer indexes with an invalid value
|
||||||
iSelInBufferLeft = -1;
|
iSelInBufferLeft = INVALID_INDEX;
|
||||||
iSelInBufferRight = -1;
|
iSelInBufferRight = INVALID_INDEX;
|
||||||
iSelAddInBufferLeft = -1; // if no additional channel used, this will stay on the invalid value
|
iSelAddInBufferLeft = INVALID_INDEX; // 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
|
iSelAddInBufferRight = INVALID_INDEX; // if no additional channel used, this will stay on the invalid value
|
||||||
iSelOutBufferLeft = -1;
|
iSelOutBufferLeft = INVALID_INDEX;
|
||||||
iSelOutBufferRight = -1;
|
iSelOutBufferRight = INVALID_INDEX;
|
||||||
|
|
||||||
// input
|
// input
|
||||||
GetSelCHAndAddCH ( iSelInputLeftChannel, iNumInChan, iSelCHLeft, iSelAddCHLeft );
|
GetSelCHAndAddCH ( iSelInputLeftChannel, iNumInChan, iSelCHLeft, iSelAddCHLeft );
|
||||||
|
|
|
@ -152,10 +152,8 @@ LED bar: lbr
|
||||||
#define AUD_MIX_FADER_MAX 100
|
#define AUD_MIX_FADER_MAX 100
|
||||||
#define AUD_MIX_PAN_MAX 100
|
#define AUD_MIX_PAN_MAX 100
|
||||||
|
|
||||||
// maximum number of recognized sound cards installed in the system,
|
// maximum number of recognized sound cards installed in the system
|
||||||
// definition for "no device"
|
|
||||||
#define MAX_NUMBER_SOUND_CARDS 129 // e.g. 16 inputs, 8 outputs + default entry (MacOS)
|
#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
|
// 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
|
// 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 LOW_BOUND_SIG_METER ( -50.0 ) // dB
|
||||||
#define UPPER_BOUND_SIG_METER ( 0.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
|
#define MAX_NUM_CHANNELS 50 // max number channels for server
|
||||||
|
|
||||||
// actual number of used channels in the server
|
// actual number of used channels in the server
|
||||||
|
@ -239,8 +237,8 @@ LED bar: lbr
|
||||||
"</i></font></div>"
|
"</i></font></div>"
|
||||||
|
|
||||||
#define _MAXSHORT 32767
|
#define _MAXSHORT 32767
|
||||||
#define _MAXBYTE 255 // binary: 11111111
|
|
||||||
#define _MINSHORT ( -32768 )
|
#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
|
#if HAVE_STDINT_H
|
||||||
# include <stdint.h>
|
# include <stdint.h>
|
||||||
|
|
|
@ -353,14 +353,11 @@ void CServerListManager::CentralServerRegisterServer ( const CHostAddress& In
|
||||||
QMutexLocker locker ( &Mutex );
|
QMutexLocker locker ( &Mutex );
|
||||||
|
|
||||||
const int iCurServerListSize = ServerList.size();
|
const int iCurServerListSize = ServerList.size();
|
||||||
|
|
||||||
// define invalid index used as a flag
|
|
||||||
const int ciInvalidIdx = -1;
|
|
||||||
|
|
||||||
// Check if server is already registered.
|
// Check if server is already registered.
|
||||||
// The very first list entry must not be checked since
|
// The very first list entry must not be checked since
|
||||||
// this is per definition the central server (i.e., this server)
|
// 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++ )
|
for ( int iIdx = 1; iIdx < iCurServerListSize; iIdx++ )
|
||||||
{
|
{
|
||||||
if ( ServerList[iIdx].HostAddr == InetAddr )
|
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 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
|
// check for maximum allowed number of servers in the server list
|
||||||
if ( iCurServerListSize < MAX_NUM_SERVERS_IN_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_CENTRAL_SVR_FULL
|
||||||
: ESvrRegResult::SRR_REGISTERED );
|
: ESvrRegResult::SRR_REGISTERED );
|
||||||
}
|
}
|
||||||
|
|
|
@ -189,9 +189,9 @@ void CSettings::Load()
|
||||||
}
|
}
|
||||||
else
|
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
|
// 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
|
// sound card channel mapping settings: make sure these settings are
|
||||||
|
|
|
@ -116,7 +116,7 @@ QString CSoundBase::SetDev ( const int iNewDev )
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if an ASIO driver was already initialized
|
// 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
|
// a device was already been initialized and is used, first clean up
|
||||||
// driver
|
// driver
|
||||||
|
@ -158,7 +158,7 @@ QString CSoundBase::SetDev ( const int iNewDev )
|
||||||
// init flag for "load any driver"
|
// init flag for "load any driver"
|
||||||
bool bTryLoadAnyDriver = false;
|
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
|
// 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
|
// try to load the selected driver, if this fails, we try to load
|
||||||
|
|
|
@ -113,7 +113,7 @@ protected:
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
iSelAddCHOut = -1; // set it to an invalid number
|
iSelAddCHOut = INVALID_INDEX; // set it to an invalid number
|
||||||
iSelCHOut = iSelCH;
|
iSelCHOut = iSelCH;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -212,7 +212,7 @@ template<class TData> int CVector<TData>::StringFiFoWithCompare ( const QString
|
||||||
CVector<QString> vstrTempList ( iVectorSize, "" );
|
CVector<QString> vstrTempList ( iVectorSize, "" );
|
||||||
|
|
||||||
// init with illegal index per definition
|
// init with illegal index per definition
|
||||||
int iOldIndex = -1;
|
int iOldIndex = INVALID_INDEX;
|
||||||
|
|
||||||
// init temporary list count (may be overwritten later on)
|
// init temporary list count (may be overwritten later on)
|
||||||
int iTempListCnt = 0;
|
int iTempListCnt = 0;
|
||||||
|
@ -1249,11 +1249,11 @@ public:
|
||||||
CTimingMeas ( const int iNNMeas, const QString strNFName = "" ) :
|
CTimingMeas ( const int iNNMeas, const QString strNFName = "" ) :
|
||||||
iNumMeas ( iNNMeas ), vElapsedTimes ( iNNMeas ), strFileName ( strNFName ) { Reset(); }
|
iNumMeas ( iNNMeas ), vElapsedTimes ( iNNMeas ), strFileName ( strNFName ) { Reset(); }
|
||||||
|
|
||||||
void Reset() { iCnt = -1; }
|
void Reset() { iCnt = INVALID_INDEX; }
|
||||||
void Measure()
|
void Measure()
|
||||||
{
|
{
|
||||||
// exclude the very first measurement (initialization phase)
|
// exclude the very first measurement (initialization phase)
|
||||||
if ( iCnt == -1 )
|
if ( iCnt == INVALID_INDEX )
|
||||||
{
|
{
|
||||||
iCnt = 0;
|
iCnt = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -533,7 +533,7 @@ CSound::CSound ( void (*fpNewCallback) ( CVector<int16_t>& psData, voi
|
||||||
}
|
}
|
||||||
|
|
||||||
// init device index as not initialized (invalid)
|
// init device index as not initialized (invalid)
|
||||||
lCurDev = INVALID_SNC_CARD_DEVICE;
|
lCurDev = INVALID_INDEX;
|
||||||
|
|
||||||
// init channel mapping
|
// init channel mapping
|
||||||
ResetChannelMapping();
|
ResetChannelMapping();
|
||||||
|
|
Loading…
Reference in a new issue