diff --git a/src/channel.cpp b/src/channel.cpp index ece0b8b4..dfe8ee70 100755 --- a/src/channel.cpp +++ b/src/channel.cpp @@ -31,28 +31,32 @@ int CChannelSet::GetFreeChan() { /* look for a free channel */ - for (int i = 0; i < MAX_NUM_CHANNELS; i++) + for ( int i = 0; i < MAX_NUM_CHANNELS; i++ ) { - if (!vecChannels[i].IsConnected()) - return i; + if ( !vecChannels[i].IsConnected () ) + { + return i; + } } /* no free channel found, return invalid ID */ return INVALID_CHANNEL_ID; } -int CChannelSet::CheckAddr(const CHostAddress& Addr) +int CChannelSet::CheckAddr ( const CHostAddress& Addr ) { CHostAddress InetAddr; /* Check for all possible channels if IP is already in use */ - for (int i = 0; i < MAX_NUM_CHANNELS; i++) + for ( int i = 0; i < MAX_NUM_CHANNELS; i++ ) { - if (vecChannels[i].GetAddress(InetAddr)) + if ( vecChannels[i].GetAddress ( InetAddr ) ) { /* IP found, return channel number */ - if (InetAddr == Addr) - return i; + if ( InetAddr == Addr ) + { + return i; + } } } @@ -60,8 +64,9 @@ int CChannelSet::CheckAddr(const CHostAddress& Addr) return INVALID_CHANNEL_ID; } -bool CChannelSet::PutData(const CVector& vecbyRecBuf, - const int iNumBytesRead, const CHostAddress& HostAdr) +bool CChannelSet::PutData ( const CVector& vecbyRecBuf, + const int iNumBytesRead, + const CHostAddress& HostAdr ) { Mutex.lock (); @@ -106,64 +111,68 @@ bool CChannelSet::PutData(const CVector& vecbyRecBuf, return !bChanOK; /* return 1 if error */ } -void CChannelSet::GetBlockAllConC(CVector& vecChanID, - CVector >& vecvecdData) +void CChannelSet::GetBlockAllConC ( CVector& vecChanID, + CVector >& vecvecdData ) { /* init temporal data vector and clear input buffers */ - CVector vecdData(BLOCK_SIZE_SAMPLES); + CVector vecdData ( MIN_BLOCK_SIZE_SAMPLES ); - vecChanID.Init(0); - vecvecdData.Init(0); + vecChanID.Init ( 0 ); + vecvecdData.Init ( 0 ); /* make put and get calls thread safe. Do not forget to unlock mutex afterwards! */ - Mutex.lock(); + Mutex.lock (); /* Check all possible channels */ - for (int i = 0; i < MAX_NUM_CHANNELS; i++) + for ( int i = 0; i < MAX_NUM_CHANNELS; i++ ) { /* read out all input buffers to decrease timeout counter on disconnected channels */ - bool bGetOK = vecChannels[i].GetData(vecdData); + const bool bGetOK = vecChannels[i].GetData ( vecdData ); - if (vecChannels[i].IsConnected()) + if ( vecChannels[i].IsConnected () ) { /* add ID and data */ - vecChanID.Add(i); + vecChanID.Add ( i ); - const int iOldSize = vecvecdData.Size(); - vecvecdData.Enlarge(1); - vecvecdData[iOldSize].Init(vecdData.Size()); + const int iOldSize = vecvecdData.Size (); + vecvecdData.Enlarge ( 1 ); + vecvecdData[iOldSize].Init ( vecdData.Size () ); vecvecdData[iOldSize] = vecdData; /* send message for get status (for GUI) */ - if (bGetOK) - PostWinMessage(MS_JIT_BUF_GET, MUL_COL_LED_GREEN, i); - else - PostWinMessage(MS_JIT_BUF_GET, MUL_COL_LED_RED, i); + if ( bGetOK ) + { + PostWinMessage ( MS_JIT_BUF_GET, MUL_COL_LED_GREEN, i ); + } + else + { + PostWinMessage ( MS_JIT_BUF_GET, MUL_COL_LED_RED, i ); + } } } - Mutex.unlock(); /* release mutex */ + Mutex.unlock (); /* release mutex */ } -void CChannelSet::GetConCliParam(CVector& vecHostAddresses, - CVector& vecdSamOffs) +void CChannelSet::GetConCliParam ( CVector& vecHostAddresses, + CVector& vecdSamOffs ) { CHostAddress InetAddr; /* init return values */ - vecHostAddresses.Init(MAX_NUM_CHANNELS); - vecdSamOffs.Init(MAX_NUM_CHANNELS); + vecHostAddresses.Init ( MAX_NUM_CHANNELS ); + vecdSamOffs.Init ( MAX_NUM_CHANNELS ); /* Check all possible channels */ - for (int i = 0; i < MAX_NUM_CHANNELS; i++) + for ( int i = 0; i < MAX_NUM_CHANNELS; i++ ) { - if (vecChannels[i].GetAddress(InetAddr)) + if ( vecChannels[i].GetAddress ( InetAddr ) ) { /* add new address and sample rate offset to vectors */ vecHostAddresses[i] = InetAddr; - vecdSamOffs[i] = vecChannels[i].GetResampleOffset(); + vecdSamOffs[i] = vecChannels[i].GetResampleOffset (); } } } @@ -195,7 +204,7 @@ CChannel::CChannel() byTimeStampIdxCnt = 0; /* init the socket buffer */ - SetSockBufSize ( BLOCK_SIZE_SAMPLES, DEF_NET_BUF_SIZE_NUM_BL ); + SetSockBufSize ( MIN_BLOCK_SIZE_SAMPLES, DEF_NET_BUF_SIZE_NUM_BL ); /* init conversion buffer */ ConvBuf.Init ( BLOCK_SIZE_SAMPLES ); diff --git a/src/global.h b/src/global.h index b9656a67..32771ff4 100755 --- a/src/global.h +++ b/src/global.h @@ -42,7 +42,7 @@ /* version and application name */ #ifndef VERSION -# define VERSION "0.9.2cvs" +# define VERSION "0.9.3cvs" #endif #define APP_NAME "llcon" @@ -72,14 +72,14 @@ #define SND_CRD_BLOCK_SIZE_SAMPLES (BLOCK_DURATION_MS * SND_CRD_SAMPLE_RATE / 1000) /* maximum network buffer size (which can be chosen by slider) */ -#define MAX_NET_BUF_SIZE_NUM_BL 10 /* number of blocks */ +#define MAX_NET_BUF_SIZE_NUM_BL 12 /* number of blocks */ /* default network buffer size */ -#define DEF_NET_BUF_SIZE_NUM_BL 2 /* number of blocks */ +#define DEF_NET_BUF_SIZE_NUM_BL 5 /* number of blocks */ // number of ticks of audio in/out buffer sliders #ifdef _WIN32 -# define AUD_SLIDER_LENGTH 15 +# define AUD_SLIDER_LENGTH 30 #else # define AUD_SLIDER_LENGTH 6 #endif diff --git a/src/llconserverdlg.cpp b/src/llconserverdlg.cpp index eac49fa5..077c5204 100755 --- a/src/llconserverdlg.cpp +++ b/src/llconserverdlg.cpp @@ -153,7 +153,7 @@ void CLlconServerDlg::OnTimer() void CLlconServerDlg::OnSliderNetBuf(int value) { - pServer->GetChannelSet()->SetSockBufSize( BLOCK_SIZE_SAMPLES, value ); + pServer->GetChannelSet()->SetSockBufSize( MIN_BLOCK_SIZE_SAMPLES, value ); TextNetBuf->setText("Size: " + QString().setNum(value)); } diff --git a/src/server.cpp b/src/server.cpp index 9845774c..92b9d659 100755 --- a/src/server.cpp +++ b/src/server.cpp @@ -26,39 +26,40 @@ /* Implementation *************************************************************/ -CServer::CServer() : Socket(&ChannelSet) +CServer::CServer () : Socket ( &ChannelSet ) { - vecsSendData.Init(BLOCK_SIZE_SAMPLES); + vecsSendData.Init ( MIN_BLOCK_SIZE_SAMPLES ); /* init moving average buffer for response time evaluation */ - RespTimeMoAvBuf.Init(LEN_MOV_AV_RESPONSE); + RespTimeMoAvBuf.Init ( LEN_MOV_AV_RESPONSE ); /* connect timer timeout signal */ - QObject::connect(&Timer, SIGNAL(timeout()), this, SLOT(OnTimer())); + QObject::connect ( &Timer, SIGNAL ( timeout () ), + this, SLOT ( OnTimer () ) ); } -void CServer::Start() +void CServer::Start () { if ( !IsRunning () ) { /* start main timer */ - Timer.start(BLOCK_DURATION_MS); + Timer.start ( MIN_BLOCK_DURATION_MS ); /* init time for response time evaluation */ - TimeLastBlock = QTime::currentTime(); + TimeLastBlock = QTime::currentTime (); } } -void CServer::Stop() +void CServer::Stop () { /* stop main timer */ - Timer.stop(); + Timer.stop (); } -void CServer::OnTimer() +void CServer::OnTimer () { CVector vecChanID; - CVector > vecvecdData ( BLOCK_SIZE_SAMPLES ); + CVector > vecvecdData ( MIN_BLOCK_SIZE_SAMPLES ); /* get data from all connected clients */ ChannelSet.GetBlockAllConC ( vecChanID, vecvecdData ); @@ -87,8 +88,8 @@ void CServer::OnTimer() /* we want to calculate the standard deviation (we assume that the mean is correct at the block period time) */ - const double dCurAddVal = - ( (double) TimeLastBlock.msecsTo ( CurTime ) - BLOCK_DURATION_MS ); + const double dCurAddVal = ( (double) TimeLastBlock.msecsTo ( CurTime ) - + MIN_BLOCK_DURATION_MS ); RespTimeMoAvBuf.Add ( dCurAddVal * dCurAddVal ); /* add squared value */ @@ -110,7 +111,7 @@ void CServer::OnTimer() CVector CServer::ProcessData ( CVector >& vecvecdData ) { CVector vecsOutData; - vecsOutData.Init ( BLOCK_SIZE_SAMPLES ); + vecsOutData.Init ( MIN_BLOCK_SIZE_SAMPLES ); const int iNumClients = vecvecdData.Size (); @@ -119,7 +120,7 @@ CVector CServer::ProcessData ( CVector >& vecvecdData ) const double dNorm = sqrt ( (double) iNumClients ); /* mix all audio data from all clients together */ - for ( int i = 0; i < BLOCK_SIZE_SAMPLES; i++ ) + for ( int i = 0; i < MIN_BLOCK_SIZE_SAMPLES; i++ ) { double dMixedData = 0.0;