diff --git a/src/client.cpp b/src/client.cpp index 0d2dceb8..5c0ec492 100755 --- a/src/client.cpp +++ b/src/client.cpp @@ -37,8 +37,10 @@ bool CClient::SetServerAddr(QString strNAddr) return true; } - else - return false; /* invalid address */ + else + { + return false; /* invalid address */ + } } void CClient::Init() diff --git a/src/global.h b/src/global.h index 407d5a18..b9656a67 100755 --- a/src/global.h +++ b/src/global.h @@ -64,17 +64,10 @@ #define MIN_BLOCK_SIZE_SAMPLES ( MIN_BLOCK_DURATION_MS * SAMPLE_RATE / 1000 ) #define MIN_SND_CRD_BLOCK_SIZE_SAMPLES ( MIN_BLOCK_DURATION_MS * SND_CRD_SAMPLE_RATE / 1000 ) -/* block length in milliseconds (it seems that with the standard windows time - a minimum block duration of 10 ms can be used) */ -#ifdef _WIN32 -# define BLOCK_DURATION_MS 6 /* ms */ -#else /* first tests showed that with 24000 kHz a block time shorter than 5 ms leads to much higher DSL network latencies. A length of 6 ms seems to be optimal */ -# define BLOCK_DURATION_MS 6 /* ms */ -#endif +#define BLOCK_DURATION_MS 6 /* ms */ - #define BLOCK_SIZE_SAMPLES (BLOCK_DURATION_MS * SAMPLE_RATE / 1000) #define SND_CRD_BLOCK_SIZE_SAMPLES (BLOCK_DURATION_MS * SND_CRD_SAMPLE_RATE / 1000) diff --git a/src/llconclientdlg.cpp b/src/llconclientdlg.cpp index e1e86d4a..9c7d83b0 100755 --- a/src/llconclientdlg.cpp +++ b/src/llconclientdlg.cpp @@ -27,7 +27,7 @@ /* Implementation *************************************************************/ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QWidget* parent, - const char* name, bool modal, WFlags f) : pClient ( pNCliP ), + const char* name, bool modal, WFlags f) : pClient ( pNCliP ), CLlconClientDlgBase ( parent, name, modal, f ) { /* add help text to controls */ diff --git a/src/llconserverdlg.cpp b/src/llconserverdlg.cpp index caa3ec9b..eac49fa5 100755 --- a/src/llconserverdlg.cpp +++ b/src/llconserverdlg.cpp @@ -26,8 +26,9 @@ /* Implementation *************************************************************/ -CLlconServerDlg::CLlconServerDlg(QWidget* parent, const char* name, bool modal, - WFlags f) : CLlconServerDlgBase(parent, name, modal, f) +CLlconServerDlg::CLlconServerDlg ( CServer* pNServP, QWidget* parent, + const char* name, bool modal, WFlags f ) : pServer ( pNServP ), + CLlconServerDlgBase ( parent, name, modal, f ) { /* set text for version and application name */ TextLabelNameVersion-> @@ -69,13 +70,10 @@ CLlconServerDlg::CLlconServerDlg(QWidget* parent, const char* name, bool modal, /* Init slider control */ SliderNetBuf->setRange(1, MAX_NET_BUF_SIZE_NUM_BL); - const int iCurNumNetBuf = Server.GetChannelSet()->GetSockBufSize(); + const int iCurNumNetBuf = pServer->GetChannelSet()->GetSockBufSize(); SliderNetBuf->setValue(iCurNumNetBuf); TextNetBuf->setText("Size: " + QString().setNum(iCurNumNetBuf)); - /* start the server */ - Server.Start(); - /* Init timing jitter text label */ TextLabelResponseTime->setText(""); @@ -112,7 +110,7 @@ void CLlconServerDlg::OnTimer() ListViewMutex.lock(); - Server.GetConCliParam(vecHostAddresses, vecdSamOffs); + pServer->GetConCliParam(vecHostAddresses, vecdSamOffs); /* fill list with connected clients */ for (int i = 0; i < MAX_NUM_CHANNELS; i++) @@ -142,7 +140,7 @@ void CLlconServerDlg::OnTimer() ListViewMutex.unlock(); /* response time (if available) */ - if ( Server.GetTimingStdDev ( dCurTiStdDev ) ) + if ( pServer->GetTimingStdDev ( dCurTiStdDev ) ) { TextLabelResponseTime->setText(QString(). setNum(dCurTiStdDev, 'f', 2) + " ms"); @@ -155,7 +153,7 @@ void CLlconServerDlg::OnTimer() void CLlconServerDlg::OnSliderNetBuf(int value) { - Server.GetChannelSet()->SetSockBufSize( BLOCK_SIZE_SAMPLES, value ); + pServer->GetChannelSet()->SetSockBufSize( BLOCK_SIZE_SAMPLES, value ); TextNetBuf->setText("Size: " + QString().setNum(value)); } diff --git a/src/llconserverdlg.h b/src/llconserverdlg.h index 37dbb55b..210dd762 100755 --- a/src/llconserverdlg.h +++ b/src/llconserverdlg.h @@ -51,18 +51,18 @@ class CLlconServerDlg : public CLlconServerDlgBase Q_OBJECT public: - CLlconServerDlg(QWidget* parent = 0, const char* name = 0, - bool modal = FALSE, WFlags f = 0); + CLlconServerDlg ( CServer* pNServP, QWidget* parent = 0, + const char* name = 0, bool modal = FALSE, WFlags f = 0 ); - virtual ~CLlconServerDlg() {} + virtual ~CLlconServerDlg () {} protected: - QTimer Timer; - CServer Server; + QTimer Timer; + CServer* pServer; - QPixmap BitmCubeGreen; - QPixmap BitmCubeYellow; - QPixmap BitmCubeRed; + QPixmap BitmCubeGreen; + QPixmap BitmCubeYellow; + QPixmap BitmCubeRed; CVector vecpListViewItems; QMutex ListViewMutex; diff --git a/src/main.cpp b/src/main.cpp index 80ed0f1e..1ccb9168 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -35,27 +35,39 @@ QApplication* pApp = NULL; int main ( int argc, char** argv ) -{ - /* Application object */ - QApplication app ( argc, argv ); - +{ /* check if server or client application shall be started */ - bool bIsClient = true; - + bool bIsClient = true; + bool bUseGUI = true; + /* QT docu: argv()[0] is the program name, argv()[1] is the first argument and argv()[argc()-1] is the last argument */ if ( argc > 1 ) - { - /* only "-s" is supported right now */ - std::string strShortOpt = "-s"; + { + std::string strShortOpt; + + /* "-s": start server with GUI enabled */ + strShortOpt = "-s"; if ( !strShortOpt.compare ( argv[1] ) ) { bIsClient = false; } - } + + /* "-sn": start server with GUI disabled (no GUI used) */ + strShortOpt = "-sn"; + if ( !strShortOpt.compare ( argv[1] ) ) + { + bIsClient = false; + bUseGUI = false; + } + } + + /* Application object */ + QApplication app ( argc, argv, bUseGUI ); if ( bIsClient ) { + /* client */ // actual client object CClient Client; @@ -63,7 +75,7 @@ int main ( int argc, char** argv ) CSettings Settings ( &Client ); Settings.Load (); - /* client */ + // GUI object CLlconClientDlg ClientDlg ( &Client, 0, 0, FALSE, Qt::WStyle_MinMax ); /* Set main window */ @@ -79,16 +91,28 @@ int main ( int argc, char** argv ) } else { - /* server */ - CLlconServerDlg ServerDlg ( 0, 0, FALSE, Qt::WStyle_MinMax ); + /* server */ + // actual server object + CServer Server; + + /* start the server */ + Server.Start (); + + if ( bUseGUI ) + { + // GUI object for the server + CLlconServerDlg ServerDlg ( &Server, 0, 0, FALSE, + Qt::WStyle_MinMax ); - /* Set main window */ - app.setMainWidget ( &ServerDlg ); - pApp = &app; /* Needed for post-event routine */ + /* Set main window */ + app.setMainWidget ( &ServerDlg ); + pApp = &app; /* Needed for post-event routine */ - /* Show dialog */ - ServerDlg.show (); - app.exec (); + /* Show dialog */ + ServerDlg.show (); + } + + app.exec (); } return 0; diff --git a/src/socket.cpp b/src/socket.cpp index 3db1ab6f..f9ea402a 100755 --- a/src/socket.cpp +++ b/src/socket.cpp @@ -109,8 +109,10 @@ void CSocket::OnDataReceived () { /* client */ /* check if packet comes from the server we want to connect */ - if ( ! ( pChannel->GetAddress () == RecHostAddr ) ) - return; + if ( ! ( pChannel->GetAddress () == RecHostAddr ) ) + { + return; + } if ( pChannel->PutData( vecbyRecBuf, iNumBytesRead ) ) { diff --git a/src/util.h b/src/util.h index 48896a6f..777b1499 100755 --- a/src/util.h +++ b/src/util.h @@ -83,7 +83,7 @@ public: default, reset */ CVector(const CVector& vecI) : std::vector(static_cast&>(vecI)), - iVectorSize(vecI.Size()), pData(this->begin()) {} + iVectorSize(vecI.Size()) { pData = this->begin(); } void Init(const int iNewSize);