server runs on short blocks

This commit is contained in:
Volker Fischer 2006-02-17 21:08:05 +00:00
parent 6d226d0a24
commit 136fe90d4d
4 changed files with 66 additions and 56 deletions

View file

@ -34,8 +34,10 @@ int CChannelSet::GetFreeChan()
for ( int i = 0; i < MAX_NUM_CHANNELS; i++ ) for ( int i = 0; i < MAX_NUM_CHANNELS; i++ )
{ {
if ( !vecChannels[i].IsConnected () ) if ( !vecChannels[i].IsConnected () )
{
return i; return i;
} }
}
/* no free channel found, return invalid ID */ /* no free channel found, return invalid ID */
return INVALID_CHANNEL_ID; return INVALID_CHANNEL_ID;
@ -52,16 +54,19 @@ int CChannelSet::CheckAddr(const CHostAddress& Addr)
{ {
/* IP found, return channel number */ /* IP found, return channel number */
if ( InetAddr == Addr ) if ( InetAddr == Addr )
{
return i; return i;
} }
} }
}
/* IP not found, return invalid ID */ /* IP not found, return invalid ID */
return INVALID_CHANNEL_ID; return INVALID_CHANNEL_ID;
} }
bool CChannelSet::PutData ( const CVector<unsigned char>& vecbyRecBuf, bool CChannelSet::PutData ( const CVector<unsigned char>& vecbyRecBuf,
const int iNumBytesRead, const CHostAddress& HostAdr) const int iNumBytesRead,
const CHostAddress& HostAdr )
{ {
Mutex.lock (); Mutex.lock ();
@ -110,7 +115,7 @@ void CChannelSet::GetBlockAllConC(CVector<int>& vecChanID,
CVector<CVector<double> >& vecvecdData ) CVector<CVector<double> >& vecvecdData )
{ {
/* init temporal data vector and clear input buffers */ /* init temporal data vector and clear input buffers */
CVector<double> vecdData(BLOCK_SIZE_SAMPLES); CVector<double> vecdData ( MIN_BLOCK_SIZE_SAMPLES );
vecChanID.Init ( 0 ); vecChanID.Init ( 0 );
vecvecdData.Init ( 0 ); vecvecdData.Init ( 0 );
@ -124,7 +129,7 @@ void CChannelSet::GetBlockAllConC(CVector<int>& vecChanID,
{ {
/* read out all input buffers to decrease timeout counter on /* read out all input buffers to decrease timeout counter on
disconnected channels */ disconnected channels */
bool bGetOK = vecChannels[i].GetData(vecdData); const bool bGetOK = vecChannels[i].GetData ( vecdData );
if ( vecChannels[i].IsConnected () ) if ( vecChannels[i].IsConnected () )
{ {
@ -138,11 +143,15 @@ void CChannelSet::GetBlockAllConC(CVector<int>& vecChanID,
/* send message for get status (for GUI) */ /* send message for get status (for GUI) */
if ( bGetOK ) if ( bGetOK )
{
PostWinMessage ( MS_JIT_BUF_GET, MUL_COL_LED_GREEN, i ); PostWinMessage ( MS_JIT_BUF_GET, MUL_COL_LED_GREEN, i );
}
else else
{
PostWinMessage ( MS_JIT_BUF_GET, MUL_COL_LED_RED, i ); PostWinMessage ( MS_JIT_BUF_GET, MUL_COL_LED_RED, i );
} }
} }
}
Mutex.unlock (); /* release mutex */ Mutex.unlock (); /* release mutex */
} }
@ -195,7 +204,7 @@ CChannel::CChannel()
byTimeStampIdxCnt = 0; byTimeStampIdxCnt = 0;
/* init the socket buffer */ /* 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 */ /* init conversion buffer */
ConvBuf.Init ( BLOCK_SIZE_SAMPLES ); ConvBuf.Init ( BLOCK_SIZE_SAMPLES );

View file

@ -42,7 +42,7 @@
/* version and application name */ /* version and application name */
#ifndef VERSION #ifndef VERSION
# define VERSION "0.9.2cvs" # define VERSION "0.9.3cvs"
#endif #endif
#define APP_NAME "llcon" #define APP_NAME "llcon"
@ -72,14 +72,14 @@
#define SND_CRD_BLOCK_SIZE_SAMPLES (BLOCK_DURATION_MS * SND_CRD_SAMPLE_RATE / 1000) #define SND_CRD_BLOCK_SIZE_SAMPLES (BLOCK_DURATION_MS * SND_CRD_SAMPLE_RATE / 1000)
/* maximum network buffer size (which can be chosen by slider) */ /* 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 */ /* 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 // number of ticks of audio in/out buffer sliders
#ifdef _WIN32 #ifdef _WIN32
# define AUD_SLIDER_LENGTH 15 # define AUD_SLIDER_LENGTH 30
#else #else
# define AUD_SLIDER_LENGTH 6 # define AUD_SLIDER_LENGTH 6
#endif #endif

View file

@ -153,7 +153,7 @@ void CLlconServerDlg::OnTimer()
void CLlconServerDlg::OnSliderNetBuf(int value) 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)); TextNetBuf->setText("Size: " + QString().setNum(value));
} }

View file

@ -28,13 +28,14 @@
/* Implementation *************************************************************/ /* 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 */ /* init moving average buffer for response time evaluation */
RespTimeMoAvBuf.Init ( LEN_MOV_AV_RESPONSE ); RespTimeMoAvBuf.Init ( LEN_MOV_AV_RESPONSE );
/* connect timer timeout signal */ /* 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 ()
@ -42,7 +43,7 @@ void CServer::Start()
if ( !IsRunning () ) if ( !IsRunning () )
{ {
/* start main timer */ /* start main timer */
Timer.start(BLOCK_DURATION_MS); Timer.start ( MIN_BLOCK_DURATION_MS );
/* init time for response time evaluation */ /* init time for response time evaluation */
TimeLastBlock = QTime::currentTime (); TimeLastBlock = QTime::currentTime ();
@ -58,7 +59,7 @@ void CServer::Stop()
void CServer::OnTimer () void CServer::OnTimer ()
{ {
CVector<int> vecChanID; CVector<int> vecChanID;
CVector<CVector<double> > vecvecdData ( BLOCK_SIZE_SAMPLES ); CVector<CVector<double> > vecvecdData ( MIN_BLOCK_SIZE_SAMPLES );
/* get data from all connected clients */ /* get data from all connected clients */
ChannelSet.GetBlockAllConC ( vecChanID, vecvecdData ); ChannelSet.GetBlockAllConC ( vecChanID, vecvecdData );
@ -87,8 +88,8 @@ void CServer::OnTimer()
/* we want to calculate the standard deviation (we assume that the mean /* we want to calculate the standard deviation (we assume that the mean
is correct at the block period time) */ is correct at the block period time) */
const double dCurAddVal = const double dCurAddVal = ( (double) TimeLastBlock.msecsTo ( CurTime ) -
( (double) TimeLastBlock.msecsTo ( CurTime ) - BLOCK_DURATION_MS ); MIN_BLOCK_DURATION_MS );
RespTimeMoAvBuf.Add ( dCurAddVal * dCurAddVal ); /* add squared value */ RespTimeMoAvBuf.Add ( dCurAddVal * dCurAddVal ); /* add squared value */
@ -110,7 +111,7 @@ void CServer::OnTimer()
CVector<short> CServer::ProcessData ( CVector<CVector<double> >& vecvecdData ) CVector<short> CServer::ProcessData ( CVector<CVector<double> >& vecvecdData )
{ {
CVector<short> vecsOutData; CVector<short> vecsOutData;
vecsOutData.Init ( BLOCK_SIZE_SAMPLES ); vecsOutData.Init ( MIN_BLOCK_SIZE_SAMPLES );
const int iNumClients = vecvecdData.Size (); const int iNumClients = vecvecdData.Size ();
@ -119,7 +120,7 @@ CVector<short> CServer::ProcessData ( CVector<CVector<double> >& vecvecdData )
const double dNorm = sqrt ( (double) iNumClients ); const double dNorm = sqrt ( (double) iNumClients );
/* mix all audio data from all clients together */ /* 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; double dMixedData = 0.0;