use units in constants (e.g. HZ, MS), some more work on server list

This commit is contained in:
Volker Fischer 2011-03-31 07:10:43 +00:00
parent 2b594ad000
commit d470a0bb68
11 changed files with 109 additions and 70 deletions

View file

@ -37,7 +37,7 @@ CChannel::CChannel ( const bool bNIsServer ) :
// initial value for connection time out counter, we calculate the total
// number of samples here and subtract the number of samples of the block
// which we take out of the buffer to be independent of block sizes
iConTimeOutStartVal = CON_TIME_OUT_SEC_MAX * SYSTEM_SAMPLE_RATE;
iConTimeOutStartVal = CON_TIME_OUT_SEC_MAX * SYSTEM_SAMPLE_RATE_HZ;
// init time-out for the buffer with zero -> no connection
iConTimeOut = 0;
@ -47,7 +47,7 @@ CChannel::CChannel ( const bool bNIsServer ) :
// initialize cycle time variance measurement with defaults
CycleTimeVariance.Init ( SYSTEM_FRAME_SIZE_SAMPLES,
SYSTEM_SAMPLE_RATE, TIME_MOV_AV_RESPONSE );
SYSTEM_SAMPLE_RATE_HZ, TIME_MOV_AV_RESPONSE_SECONDS );
// initialize channel name
ResetName();
@ -155,7 +155,7 @@ void CChannel::SetAudioStreamProperties ( const int iNewNetwFrameSize,
// initialize and reset cycle time variance measurement
CycleTimeVariance.Init ( iNetwFrameSizeFact * SYSTEM_FRAME_SIZE_SAMPLES,
SYSTEM_SAMPLE_RATE, TIME_MOV_AV_RESPONSE );
SYSTEM_SAMPLE_RATE_HZ, TIME_MOV_AV_RESPONSE_SECONDS );
CycleTimeVariance.Reset();
@ -321,7 +321,7 @@ void CChannel::CreateNetTranspPropsMessFromCurrentSettings()
iNetwFrameSize,
iNetwFrameSizeFact,
iNumAudioChannels,
SYSTEM_SAMPLE_RATE,
SYSTEM_SAMPLE_RATE_HZ,
CT_CELT, // always CELT coding
0, // version of the codec
0 );
@ -546,7 +546,7 @@ int CChannel::GetUploadRateKbps()
// 8 (UDP) + 20 (IP without optional fields) = 28 bytes
return ( iNetwFrameSize * iNetwFrameSizeFact + 28 /* header */ ) *
8 /* bits per byte */ *
SYSTEM_SAMPLE_RATE / iAudioSizeOut / 1000;
SYSTEM_SAMPLE_RATE_HZ / iAudioSizeOut / 1000;
}

View file

@ -58,7 +58,7 @@ CClient::CClient ( const quint16 iPortNumber ) :
{
// init audio encoder/decoder (mono)
CeltModeMono = celt_mode_create (
SYSTEM_SAMPLE_RATE, 1, SYSTEM_FRAME_SIZE_SAMPLES, NULL );
SYSTEM_SAMPLE_RATE_HZ, 1, SYSTEM_FRAME_SIZE_SAMPLES, NULL );
CeltEncoderMono = celt_encoder_create ( CeltModeMono );
CeltDecoderMono = celt_decoder_create ( CeltModeMono );
@ -71,7 +71,7 @@ CClient::CClient ( const quint16 iPortNumber ) :
// init audio encoder/decoder (stereo)
CeltModeStereo = celt_mode_create (
SYSTEM_SAMPLE_RATE, 2, SYSTEM_FRAME_SIZE_SAMPLES, NULL );
SYSTEM_SAMPLE_RATE_HZ, 2, SYSTEM_FRAME_SIZE_SAMPLES, NULL );
CeltEncoderStereo = celt_encoder_create ( CeltModeStereo );
CeltDecoderStereo = celt_decoder_create ( CeltModeStereo );
@ -557,13 +557,13 @@ void CClient::Init()
// init response time evaluation
CycleTimeVariance.Init ( iMonoBlockSizeSam,
SYSTEM_SAMPLE_RATE, TIME_MOV_AV_RESPONSE );
SYSTEM_SAMPLE_RATE_HZ, TIME_MOV_AV_RESPONSE_SECONDS );
CycleTimeVariance.Reset();
// init reverberation
AudioReverbL.Init ( SYSTEM_SAMPLE_RATE );
AudioReverbR.Init ( SYSTEM_SAMPLE_RATE );
AudioReverbL.Init ( SYSTEM_SAMPLE_RATE_HZ );
AudioReverbR.Init ( SYSTEM_SAMPLE_RATE_HZ );
// inits for CELT coding
if ( bCeltDoHighQuality )
@ -931,7 +931,7 @@ void CClient::UpdateSocketBufferSize()
const double dAudioBufferDurationMs =
( GetSndCrdActualMonoBlSize() +
GetSndCrdConvBufAdditionalDelayMonoBlSize() ) *
1000 / SYSTEM_SAMPLE_RATE;
1000 / SYSTEM_SAMPLE_RATE_HZ;
// jitter introduced in the server by the timer implementation
const double dServerJitterMs = 0.666666; // ms
@ -996,12 +996,12 @@ int CClient::EstimatedOverallDelay ( const int iPingTimeMs )
const double dTotalSoundCardDelayMs =
( 3 * GetSndCrdActualMonoBlSize() +
GetSndCrdConvBufAdditionalDelayMonoBlSize() ) *
1000 / SYSTEM_SAMPLE_RATE;
1000 / SYSTEM_SAMPLE_RATE_HZ;
// network packets are of the same size as the audio packets per definition
// if no sound card conversion buffer is used
const double dDelayToFillNetworkPacketsMs =
GetSystemMonoBlSize() * 1000 / SYSTEM_SAMPLE_RATE;
GetSystemMonoBlSize() * 1000 / SYSTEM_SAMPLE_RATE_HZ;
// CELT additional delay at small frame sizes is half a frame size
const double dAdditionalAudioCodecDelayMs =

View file

@ -236,7 +236,7 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
#endif
// init delay and other information controls
CLEDOverallDelay->SetUpdateTime ( 2 * PING_UPDATE_TIME );
CLEDOverallDelay->SetUpdateTime ( 2 * PING_UPDATE_TIME_MS );
CLEDOverallDelay->Reset();
TextLabelPingTime->setText ( "" );
TextLabelOverallDelay->setText ( "" );
@ -394,7 +394,7 @@ QString CClientSettingsDlg::GenSndCrdBufferDelayString ( const int iFrameSize,
// use two times the buffer delay for the entire delay since
// we have input and output
return QString().setNum ( (double) iFrameSize * 2 *
1000 / SYSTEM_SAMPLE_RATE, 'f', 2 ) + " ms (" +
1000 / SYSTEM_SAMPLE_RATE_HZ, 'f', 2 ) + " ms (" +
QString().setNum ( iFrameSize ) + strAddText + ")";
}

View file

@ -58,7 +58,7 @@ pListViewItem = new QTreeWidgetItem ( ListViewServers );
void CConnectDlg::showEvent ( QShowEvent* )
{
// only activate ping timer if window is actually shown
TimerPing.start ( PING_UPDATE_TIME );
TimerPing.start ( PING_UPDATE_TIME_MS );
// UpdateDisplay();
}

View file

@ -62,7 +62,7 @@
#define LLCON_DEFAULT_PORT_NUMBER 22124
// system sample rate (the sound card and audio coder works on this sample rate)
#define SYSTEM_SAMPLE_RATE 48000
#define SYSTEM_SAMPLE_RATE_HZ 48000 // Hz
// System block size, this is the block size on which the audio coder works.
// All other block sizes must be a multiple of this size
@ -70,7 +70,7 @@
#define SYSTEM_BLOCK_DURATION_MS_FLOAT \
( static_cast<double> ( SYSTEM_FRAME_SIZE_SAMPLES ) / \
SYSTEM_SAMPLE_RATE * 1000 )
SYSTEM_SAMPLE_RATE_HZ * 1000 )
// define the allowed audio frame size factors (since the
// "SYSTEM_FRAME_SIZE_SAMPLES" is quite small, it may be that on some
@ -128,11 +128,24 @@
// without any other changes in the code
#define USED_NUM_CHANNELS 6 // used number channels for server
// defines the time interval at which the ping time is updated in the GUI
#define PING_UPDATE_TIME 500 // ms
#define PING_UPDATE_TIME_MS 500 // ms
// time-out until a registered server is deleted from the server list if no
// new registering was made in minutes
#define SERVLIST_TIME_OUT_MINUTES 60 // minutes
// poll time for server list (to check if entries are time-out)
#define SERVLIST_POLL_TIME_MINUTES 1 // minute
// time until a slave server registers in the server list
#define SERVLIST_REGIST_INTERV_MINUTES 30 // minutes
// length of the moving average buffer for response time measurement
#define TIME_MOV_AV_RESPONSE 30 // seconds
#define TIME_MOV_AV_RESPONSE_SECONDS 30 // seconds
// Maximum length of fader tag and text message strings (Since for chat messages
// some HTML code is added, we also have to define a second length which includes

View file

@ -280,9 +280,9 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP,
MultiColorLEDBarInputLevelR->setValue ( 0 );
// init status LEDs
LEDConnection->SetUpdateTime ( 2 * LED_BAR_UPDATE_TIME );
LEDChat->SetUpdateTime ( 2 * LED_BAR_UPDATE_TIME );
LEDDelay->SetUpdateTime ( 2 * PING_UPDATE_TIME );
LEDConnection->SetUpdateTime ( 2 * LED_BAR_UPDATE_TIME_MS );
LEDChat->SetUpdateTime ( 2 * LED_BAR_UPDATE_TIME_MS );
LEDDelay->SetUpdateTime ( 2 * PING_UPDATE_TIME_MS );
LEDDelay->Reset();
@ -442,7 +442,7 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP,
// Timers ------------------------------------------------------------------
// start timer for status bar
TimerStatus.start ( LED_BAR_UPDATE_TIME );
TimerStatus.start ( LED_BAR_UPDATE_TIME_MS );
// TEST
@ -797,8 +797,8 @@ void CLlconClientDlg::ConnectDisconnect ( const bool bDoStart )
PushButtonConnect->setText ( CON_BUT_DISCONNECTTEXT );
// start timer for level meter bar and ping time measurement
TimerSigMet.start ( LEVELMETER_UPDATE_TIME );
TimerPing.start ( PING_UPDATE_TIME );
TimerSigMet.start ( LEVELMETER_UPDATE_TIME_MS );
TimerPing.start ( PING_UPDATE_TIME_MS );
}
}
else

View file

@ -57,8 +57,8 @@
#define CON_BUT_DISCONNECTTEXT "D&isconnect"
// update time for GUI controls
#define LEVELMETER_UPDATE_TIME 100 // ms
#define LED_BAR_UPDATE_TIME 1000 // ms
#define LEVELMETER_UPDATE_TIME_MS 100 // ms
#define LED_BAR_UPDATE_TIME_MS 1000 // ms
// range for signal level meter
#define LOW_BOUND_SIG_METER ( -50.0 ) // dB

View file

@ -37,7 +37,7 @@ CHighPrecisionTimer::CHighPrecisionTimer() :
// calculate delay in mach absolute time
const uint64_t iNsDelay =
( (uint64_t) SYSTEM_FRAME_SIZE_SAMPLES * 1000000000 ) /
(uint64_t) SYSTEM_SAMPLE_RATE; // in ns
(uint64_t) SYSTEM_SAMPLE_RATE_HZ; // in ns
struct mach_timebase_info timeBaseInfo;
mach_timebase_info ( &timeBaseInfo );
@ -94,7 +94,7 @@ CHighPrecisionTimer::CHighPrecisionTimer()
#if ( SYSTEM_FRAME_SIZE_SAMPLES != 128 )
# error "Only system frame size of 128 samples is supported by this module"
#endif
#if SYSTEM_SAMPLE_RATE != 48000
#if SYSTEM_SAMPLE_RATE_HZ != 48000
# error "Only a system sample rate of 48 kHz is supported by this module"
#endif
@ -181,7 +181,7 @@ CServer::CServer ( const QString& strLoggingFileName,
{
// init audio endocder/decoder (mono)
CeltModeMono[i] = celt_mode_create (
SYSTEM_SAMPLE_RATE, 1, SYSTEM_FRAME_SIZE_SAMPLES, NULL );
SYSTEM_SAMPLE_RATE_HZ, 1, SYSTEM_FRAME_SIZE_SAMPLES, NULL );
CeltEncoderMono[i] = celt_encoder_create ( CeltModeMono[i] );
CeltDecoderMono[i] = celt_decoder_create ( CeltModeMono[i] );
@ -194,7 +194,7 @@ CServer::CServer ( const QString& strLoggingFileName,
// init audio endocder/decoder (stereo)
CeltModeStereo[i] = celt_mode_create (
SYSTEM_SAMPLE_RATE, 2, SYSTEM_FRAME_SIZE_SAMPLES, NULL );
SYSTEM_SAMPLE_RATE_HZ, 2, SYSTEM_FRAME_SIZE_SAMPLES, NULL );
CeltEncoderStereo[i] = celt_encoder_create ( CeltModeStereo[i] );
CeltDecoderStereo[i] = celt_decoder_create ( CeltModeStereo[i] );
@ -219,7 +219,7 @@ CServer::CServer ( const QString& strLoggingFileName,
// init moving average buffer for response time evaluation
CycleTimeVariance.Init ( SYSTEM_FRAME_SIZE_SAMPLES,
SYSTEM_SAMPLE_RATE, TIME_MOV_AV_RESPONSE );
SYSTEM_SAMPLE_RATE_HZ, TIME_MOV_AV_RESPONSE_SECONDS );
// enable history graph (if requested)
if ( !strHistoryFileName.isEmpty() )

View file

@ -27,8 +27,9 @@
#include <qlocale.h>
#include <qlist.h>
#include <qtimer.h>
#include "global.h"
#include "util.h"
/*
MAIN POINTS:
@ -112,11 +113,35 @@ public:
strCity ( "" ),
iNumClients ( 0 ),
iMaxNumClients ( 0 ),
bPermanentOnline ( false ) {}
bPermanentOnline ( false ) { RegisterTime.start(); }
CServerListProperties (
const CHostAddress& NIAddr,
const QString& NsName,
const QString& NsTopic,
const QLocale::Country& NeCountry,
const QString& NsCity,
const int NiNumClients,
const int NiMaxNumClients,
const bool NbPermOnline) :
InetAddr ( NIAddr ),
strName ( NsName ),
strTopic ( NsTopic ),
eCountry ( NeCountry ),
strCity ( NsCity ),
iNumClients ( NiNumClients ),
iMaxNumClients ( NiMaxNumClients ),
bPermanentOnline ( NbPermOnline ) { RegisterTime.start(); }
virtual ~CServerListProperties() {}
protected:
public:
// time on which the entry was registered
QTime RegisterTime;
// internet address of the server
CHostAddress InetAddr;
// name of the server
QString strName;
@ -141,27 +166,20 @@ protected:
};
class CServerList : public QList<CServerListProperties>//, public QObject
class CServerListManager : public QObject
{
// Q_OBJECT
Q_OBJECT
public:
CServerList() {}
virtual ~CServerList() {}
protected:
};
class CServerListManager
{
public:
CServerListManager() {}
virtual ~CServerListManager() {}
protected:
QTimer TimerPollList;
QList<CServerListProperties> ServerList;
public slots:
void OnTimerPollList() { /* TODO */ }
};
#endif /* !defined ( SERVERLIST_HOIJH8OUWEF_WFEIOBU_3_43445KJIUHF1912__INCLUDED_ ) */

View file

@ -388,24 +388,32 @@ class CHostAddress
{
public:
CHostAddress() :
InetAddr ( (quint32) 0 ),
InetAddr ( static_cast<quint32> ( 0 ) ),
iPort ( 0 ) {}
CHostAddress ( const QHostAddress NInetAddr,
const quint16 iNPort ) :
const quint16 iNPort ) :
InetAddr ( NInetAddr ),
iPort ( iNPort ) {}
CHostAddress ( const CHostAddress& NHAddr ) :
InetAddr ( NHAddr.InetAddr ),
iPort ( NHAddr.iPort ) {}
iPort ( NHAddr.iPort ) {}
// copy and compare operators
// copy operator
CHostAddress& operator= ( const CHostAddress& NHAddr )
{ InetAddr = NHAddr.InetAddr; iPort = NHAddr.iPort; return *this; }
{
InetAddr = NHAddr.InetAddr;
iPort = NHAddr.iPort;
return *this;
}
// compare operator
bool operator== ( const CHostAddress& CompAddr ) // compare operator
{ return ( ( CompAddr.InetAddr == InetAddr ) && ( CompAddr.iPort == iPort ) ); }
{
return ( ( CompAddr.InetAddr == InetAddr ) &&
( CompAddr.iPort == iPort ) );
}
QString GetIpAddressStringNoLastByte() const
{
@ -425,7 +433,7 @@ public:
iIpAddr ( 0 ),
strName ( "" ) {}
CChannelShortInfo ( const int iNID,
CChannelShortInfo ( const int iNID,
const quint32 nIP,
const QString nN ) :
iChanID ( iNID ),
@ -468,13 +476,13 @@ public:
eAudioCodingType ( CT_NONE ),
iAudioCodingArg ( 0 ) {}
CNetworkTransportProps ( const uint32_t iNBNPS,
const uint16_t iNBSF,
const uint32_t iNNACH,
const uint32_t iNSR,
CNetworkTransportProps ( const uint32_t iNBNPS,
const uint16_t iNBSF,
const uint32_t iNNACH,
const uint32_t iNSR,
const EAudComprType eNACT,
const uint32_t iNVers,
const int32_t iNACA ) :
const uint32_t iNVers,
const int32_t iNACA ) :
iBaseNetworkPacketSize ( iNBNPS ),
iBlockSizeFact ( iNBSF ),
iNumAudioChannels ( iNNACH ),
@ -581,8 +589,8 @@ public:
dIntervalTime ( 0.0 ), iNewValueBoundFactor ( 0 ) {}
void Init ( const int iNewBlockLengthAtSystemSampleRate,
const int iNewSystemSampleRate,
const int iHistoryLengthTime,
const int iNewSystemSampleRateHz,
const int iHistoryLengthTimeSec,
const int iNewNewValueBoundFactor = 4 )
{
// store block size and new value bound factor
@ -591,11 +599,11 @@ public:
// calculate interval time
dIntervalTime = static_cast<double> (
iBlockLengthAtSystemSampleRate ) * 1000 / iNewSystemSampleRate;
iBlockLengthAtSystemSampleRate ) * 1000 / iNewSystemSampleRateHz;
// calculate actual moving average length and initialize buffer
RespTimeMoAvBuf.Init ( iHistoryLengthTime *
iNewSystemSampleRate / iNewBlockLengthAtSystemSampleRate );
RespTimeMoAvBuf.Init ( iHistoryLengthTimeSec *
iNewSystemSampleRateHz / iNewBlockLengthAtSystemSampleRate );
}
int GetBlockLength() { return iBlockLengthAtSystemSampleRate; }

View file

@ -220,14 +220,14 @@ QString CSound::CheckDeviceCapabilities()
// message is returned.
// check the sample rate
const ASIOError CanSaRateReturn = ASIOCanSampleRate ( SYSTEM_SAMPLE_RATE );
const ASIOError CanSaRateReturn = ASIOCanSampleRate ( SYSTEM_SAMPLE_RATE_HZ );
if ( ( CanSaRateReturn == ASE_NoClock ) ||
( CanSaRateReturn == ASE_NotPresent ) )
{
// return error string
return tr ( "The audio device does not support the "
"required sample rate. The required sample rate is: " ) +
QString().setNum ( SYSTEM_SAMPLE_RATE ) + " Hz";
QString().setNum ( SYSTEM_SAMPLE_RATE_HZ ) + " Hz";
}
// check the number of available channels
@ -467,7 +467,7 @@ int CSound::Init ( const int iNewPrefMonoBufferSize )
iASIOBufferSizeStereo = 2 * iASIOBufferSizeMono;
// set the sample rate
ASIOSetSampleRate ( SYSTEM_SAMPLE_RATE );
ASIOSetSampleRate ( SYSTEM_SAMPLE_RATE_HZ );
// create memory for intermediate audio buffer
vecsTmpAudioSndCrdStereo.Init ( iASIOBufferSizeStereo );