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++ )
{
if ( !vecChannels[i].IsConnected () )
{
return i;
}
}
/* no free channel found, return invalid ID */
return INVALID_CHANNEL_ID;
@ -52,16 +54,19 @@ int CChannelSet::CheckAddr(const CHostAddress& Addr)
{
/* IP found, return channel number */
if ( InetAddr == Addr )
{
return i;
}
}
}
/* IP not found, return invalid ID */
return INVALID_CHANNEL_ID;
}
bool CChannelSet::PutData ( const CVector<unsigned char>& vecbyRecBuf,
const int iNumBytesRead, const CHostAddress& HostAdr)
const int iNumBytesRead,
const CHostAddress& HostAdr )
{
Mutex.lock ();
@ -110,7 +115,7 @@ void CChannelSet::GetBlockAllConC(CVector<int>& vecChanID,
CVector<CVector<double> >& vecvecdData )
{
/* init temporal data vector and clear input buffers */
CVector<double> vecdData(BLOCK_SIZE_SAMPLES);
CVector<double> vecdData ( MIN_BLOCK_SIZE_SAMPLES );
vecChanID.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
disconnected channels */
bool bGetOK = vecChannels[i].GetData(vecdData);
const bool bGetOK = vecChannels[i].GetData ( vecdData );
if ( vecChannels[i].IsConnected () )
{
@ -138,11 +143,15 @@ void CChannelSet::GetBlockAllConC(CVector<int>& vecChanID,
/* 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 );
}
}
}
Mutex.unlock (); /* release mutex */
}
@ -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 );

View File

@ -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

View File

@ -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));
}

View File

@ -28,13 +28,14 @@
/* Implementation *************************************************************/
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 );
/* connect timer timeout signal */
QObject::connect(&Timer, SIGNAL(timeout()), this, SLOT(OnTimer()));
QObject::connect ( &Timer, SIGNAL ( timeout () ),
this, SLOT ( OnTimer () ) );
}
void CServer::Start ()
@ -42,7 +43,7 @@ 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 ();
@ -58,7 +59,7 @@ void CServer::Stop()
void CServer::OnTimer ()
{
CVector<int> vecChanID;
CVector<CVector<double> > vecvecdData ( BLOCK_SIZE_SAMPLES );
CVector<CVector<double> > 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<short> CServer::ProcessData ( CVector<CVector<double> >& vecvecdData )
{
CVector<short> vecsOutData;
vecsOutData.Init ( BLOCK_SIZE_SAMPLES );
vecsOutData.Init ( MIN_BLOCK_SIZE_SAMPLES );
const int iNumClients = vecvecdData.Size ();
@ -119,7 +120,7 @@ CVector<short> CServer::ProcessData ( CVector<CVector<double> >& 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;