code cleanup (removed tabs), 2008 -> 2009

This commit is contained in:
Volker Fischer 2009-02-22 11:07:18 +00:00
parent 5eea2d96a9
commit c077f6ecf8
39 changed files with 467 additions and 465 deletions

View file

@ -1,13 +1,13 @@
2.1.4 2.1.4
- added automatic jitter buffer size setting - added automatic jitter buffer size setting
- speed optimizations to improve audio interface stability - speed optimizations to improve audio interface stability
- new defaults (e.g. turn off Reverb by default since it requires significant - new defaults (e.g. turn off Reverb by default since it requires significant
CPU CPU)
2.1.3 2.1.3
- added sound card selection - added sound card selection
@ -23,7 +23,8 @@
- ping time measurement problems on Windows OS fixed - ping time measurement problems on Windows OS fixed
- security checks for protocol messages (wrong messages could crash the software) - security checks for protocol messages (wrong messages could crash the
software)
2.1.1 2.1.1
@ -51,7 +52,8 @@
- new client settings dialog - new client settings dialog
- at each client a separate audio mix can be generated for all connected clients at the server - at each client a separate audio mix can be generated for all connected clients
at the server
0.9.4 0.9.4

View file

@ -1,5 +1,5 @@
/******************************************************************************\ /******************************************************************************\
* Copyright (c) 2004-2008 * Copyright (c) 2004-2009
* *
* Author(s): * Author(s):
* Volker Fischer * Volker Fischer

2
README
View file

@ -1,5 +1,5 @@
/******************************************************************************\ /******************************************************************************\
* Copyright (c) 2004-2008 * Copyright (c) 2004-2009
* *
* Author(s): * Author(s):
* Volker Fischer * Volker Fischer

View file

@ -1,5 +1,5 @@
/******************************************************************************\ /******************************************************************************\
* Copyright (c) 2004-2008 * Copyright (c) 2004-2009
* *
* Author(s): * Author(s):
* Volker Fischer, Erik de Castro Lopo * Volker Fischer, Erik de Castro Lopo
@ -97,9 +97,9 @@ CVector<short> CAudioCompression::Decode ( const CVector<unsigned char>& vecbyAd
{ {
int current = vecbyAdpcm[2 * i] | ( vecbyAdpcm[2 * i + 1] << 8 ); int current = vecbyAdpcm[2 * i] | ( vecbyAdpcm[2 * i + 1] << 8 );
if ( current & 0x8000 ) if ( current & 0x8000 )
{ {
current -= 0x10000; current -= 0x10000;
} }
vecsOut[i] = (short) current; vecsOut[i] = (short) current;
} }
@ -188,13 +188,13 @@ CVector<unsigned char> CImaAdpcm::Encode ( const CVector<short>& vecsAudio )
} }
if ( bytecode & 8 ) if ( bytecode & 8 )
{ {
iPrevAudio -= vpdiff; iPrevAudio -= vpdiff;
} }
else else
{ {
iPrevAudio += vpdiff; iPrevAudio += vpdiff;
} }
// adjust step size // adjust step size
Q_ASSERT ( bytecode < IMA_INDX_ADJUST_TAB_LEN ); Q_ASSERT ( bytecode < IMA_INDX_ADJUST_TAB_LEN );
@ -233,9 +233,9 @@ CVector<short> CImaAdpcm::Decode ( const CVector<unsigned char>& vecbyAdpcm )
/* Read the block header ------------------------------------------------ */ /* Read the block header ------------------------------------------------ */
int current = vecbyAdpcm[0] | ( vecbyAdpcm[1] << 8 ); int current = vecbyAdpcm[0] | ( vecbyAdpcm[1] << 8 );
if ( current & 0x8000 ) if ( current & 0x8000 )
{ {
current -= 0x10000; current -= 0x10000;
} }
// get and bound step index // get and bound step index
int iStepindDec = CheckBounds ( vecbyAdpcm[2], 0, IMA_STEP_SIZE_TAB_LEN - 1 ); int iStepindDec = CheckBounds ( vecbyAdpcm[2], 0, IMA_STEP_SIZE_TAB_LEN - 1 );
@ -270,21 +270,21 @@ CVector<short> CImaAdpcm::Decode ( const CVector<unsigned char>& vecbyAdpcm )
int diff = step >> 3; int diff = step >> 3;
if ( bytecode & 1 ) if ( bytecode & 1 )
{ {
diff += step >> 2; diff += step >> 2;
} }
if ( bytecode & 2 ) if ( bytecode & 2 )
{ {
diff += step >> 1; diff += step >> 1;
} }
if ( bytecode & 4 ) if ( bytecode & 4 )
{ {
diff += step; diff += step;
} }
if ( bytecode & 8 ) if ( bytecode & 8 )
{ {
diff = -diff; diff = -diff;
} }
current += diff; current += diff;
@ -345,70 +345,70 @@ CVector<unsigned char> CMsAdpcm::Encode ( const CVector<short>& vecsAudio )
/* Encode the block header ---------------------------------------------- */ /* Encode the block header ---------------------------------------------- */
vecbyAdpcm[0] = bpred; vecbyAdpcm[0] = bpred;
vecbyAdpcm[1] = idelta & 0xFF; vecbyAdpcm[1] = idelta & 0xFF;
vecbyAdpcm[2] = ( idelta >> 8 ) & 0xFF; vecbyAdpcm[2] = ( idelta >> 8 ) & 0xFF;
vecbyAdpcm[3] = vecsAudio[1] & 0xFF; vecbyAdpcm[3] = vecsAudio[1] & 0xFF;
vecbyAdpcm[4] = ( vecsAudio[1] >> 8 ) & 0xFF; vecbyAdpcm[4] = ( vecsAudio[1] >> 8 ) & 0xFF;
vecbyAdpcm[5] = vecsAudio[0] & 0xFF; vecbyAdpcm[5] = vecsAudio[0] & 0xFF;
vecbyAdpcm[6] = ( vecsAudio[0] >> 8 ) & 0xFF; vecbyAdpcm[6] = ( vecsAudio[0] >> 8 ) & 0xFF;
/* Encode the samples as 4 bit ------------------------------------------ */ /* Encode the samples as 4 bit ------------------------------------------ */
unsigned int blockindx = 7; unsigned int blockindx = 7;
unsigned char byte = 0; unsigned char byte = 0;
for ( int k = 2; k < iAudSize; k++ ) for ( int k = 2; k < iAudSize; k++ )
{ {
const int predict = ( vecsAudioTemp[k - 1] * ms_AdaptCoeff1[bpred] + const int predict = ( vecsAudioTemp[k - 1] * ms_AdaptCoeff1[bpred] +
vecsAudioTemp[k - 2] * ms_AdaptCoeff2[bpred] ) >> 8; vecsAudioTemp[k - 2] * ms_AdaptCoeff2[bpred] ) >> 8;
int errordelta = ( vecsAudio[k] - predict ) / idelta; int errordelta = ( vecsAudio[k] - predict ) / idelta;
if ( errordelta < -8 ) if ( errordelta < -8 )
{ {
errordelta = -8 ; errordelta = -8 ;
} }
else else
{ {
if (errordelta > 7) if (errordelta > 7)
{ {
errordelta = 7; errordelta = 7;
} }
} }
int newsamp = predict + ( idelta * errordelta ); int newsamp = predict + ( idelta * errordelta );
if ( newsamp > 32767 ) if ( newsamp > 32767 )
{ {
newsamp = 32767; newsamp = 32767;
} }
else else
{ {
if ( newsamp < -32768 ) if ( newsamp < -32768 )
{ {
newsamp = -32768; newsamp = -32768;
} }
} }
if ( errordelta < 0 ) if ( errordelta < 0 )
{ {
errordelta += 0x10; errordelta += 0x10;
} }
byte = ( byte << 4 ) | ( errordelta & 0xF ); byte = ( byte << 4 ) | ( errordelta & 0xF );
if ( k % 2 ) if ( k % 2 )
{ {
vecbyAdpcm[blockindx++] = byte; vecbyAdpcm[blockindx++] = byte;
byte = 0; byte = 0;
}
idelta = ( idelta * ms_AdaptationTable[errordelta] ) >> 8;
if ( idelta < 16 )
{
idelta = 16;
} }
vecsAudioTemp[k] = newsamp;
} idelta = ( idelta * ms_AdaptationTable[errordelta] ) >> 8;
if ( idelta < 16 )
{
idelta = 16;
}
vecsAudioTemp[k] = newsamp;
}
return vecbyAdpcm; return vecbyAdpcm;
} }
@ -430,10 +430,10 @@ CVector<short> CMsAdpcm::Decode ( const CVector<unsigned char>& vecbyAdpcm )
return vecsAudio; return vecsAudio;
} }
short chan_idelta = vecbyAdpcm[1] | ( vecbyAdpcm[2] << 8 ); short chan_idelta = vecbyAdpcm[1] | ( vecbyAdpcm[2] << 8 );
vecsAudio[1] = vecbyAdpcm[3] | ( vecbyAdpcm[4] << 8 ); vecsAudio[1] = vecbyAdpcm[3] | ( vecbyAdpcm[4] << 8 );
vecsAudio[0] = vecbyAdpcm[5] | ( vecbyAdpcm[6] << 8 ); vecsAudio[0] = vecbyAdpcm[5] | ( vecbyAdpcm[6] << 8 );
/* ------------------------------------------------------------------------- /* -------------------------------------------------------------------------
@ -448,48 +448,48 @@ CVector<short> CMsAdpcm::Decode ( const CVector<unsigned char>& vecbyAdpcm )
/* Decode the encoded 4 bit samples ------------------------------------- */ /* Decode the encoded 4 bit samples ------------------------------------- */
for ( int k = 2; k < iAudSize; k ++ ) for ( int k = 2; k < iAudSize; k ++ )
{ {
bytecode = vecsAudio[k] & 0xF; bytecode = vecsAudio[k] & 0xF;
// compute next Adaptive Scale Factor (ASF) // compute next Adaptive Scale Factor (ASF)
int idelta = chan_idelta; int idelta = chan_idelta;
// => / 256 => FIXED_POINT_ADAPTATION_BASE == 256 // => / 256 => FIXED_POINT_ADAPTATION_BASE == 256
chan_idelta = ( ms_AdaptationTable[bytecode] * idelta ) >> 8; chan_idelta = ( ms_AdaptationTable[bytecode] * idelta ) >> 8;
if ( chan_idelta < 16 ) if ( chan_idelta < 16 )
{ {
chan_idelta = 16; chan_idelta = 16;
} }
if ( bytecode & 0x8 ) if ( bytecode & 0x8 )
{ {
bytecode -= 0x10; bytecode -= 0x10;
} }
// => / 256 => FIXED_POINT_COEFF_BASE == 256 // => / 256 => FIXED_POINT_COEFF_BASE == 256
const int predict = ( ( vecsAudio[k - 1] * ms_AdaptCoeff1[bpred] ) + const int predict = ( ( vecsAudio[k - 1] * ms_AdaptCoeff1[bpred] ) +
( vecsAudio[k - 2] * ms_AdaptCoeff2[bpred] ) ) >> 8; ( vecsAudio[k - 2] * ms_AdaptCoeff2[bpred] ) ) >> 8;
int current = ( bytecode * idelta ) + predict; int current = ( bytecode * idelta ) + predict;
if ( current > 32767 ) if ( current > 32767 )
{ {
current = 32767; current = 32767;
} }
else else
{ {
if ( current < -32768 ) if ( current < -32768 )
{ {
current = -32768; current = -32768;
} }
} }
vecsAudio[k] = current; vecsAudio[k] = current;
} }
return vecsAudio; return vecsAudio;
} }
void CMsAdpcm::ChoosePredictor ( const CVector<short>& vecsAudio, void CMsAdpcm::ChoosePredictor ( const CVector<short>& vecsAudio,
@ -516,39 +516,39 @@ void CMsAdpcm::ChoosePredictor ( const CVector<short>& vecsAudio,
by using all the samples to choose the predictor. */ by using all the samples to choose the predictor. */
unsigned int idelta_count = min ( MSADPCM_IDELTA_COUNT, vecsAudio.Size() - 1 ); unsigned int idelta_count = min ( MSADPCM_IDELTA_COUNT, vecsAudio.Size() - 1 );
for ( unsigned int bpred = 0; bpred < MSADPCM_ADAPT_COEFF_COUNT; bpred++ ) for ( unsigned int bpred = 0; bpred < MSADPCM_ADAPT_COEFF_COUNT; bpred++ )
{ {
unsigned int idelta_sum = 0; unsigned int idelta_sum = 0;
for ( unsigned int k = 2; k < 2 + idelta_count; k++ ) for ( unsigned int k = 2; k < 2 + idelta_count; k++ )
{ {
idelta_sum += abs ( vecsAudio[k] - idelta_sum += abs ( vecsAudio[k] -
( ( vecsAudio[k - 1] * ms_AdaptCoeff1[bpred] + ( ( vecsAudio[k - 1] * ms_AdaptCoeff1[bpred] +
vecsAudio[k - 2] * ms_AdaptCoeff2[bpred] ) >> 8 ) ); vecsAudio[k - 2] * ms_AdaptCoeff2[bpred] ) >> 8 ) );
} }
idelta_sum /= ( 4 * idelta_count ); idelta_sum /= ( 4 * idelta_count );
if ( bpred == 0 || idelta_sum < best_idelta ) if ( bpred == 0 || idelta_sum < best_idelta )
{ {
best_bpred = bpred; best_bpred = bpred;
best_idelta = idelta_sum; best_idelta = idelta_sum;
} }
if ( !idelta_sum ) if ( !idelta_sum )
{ {
best_bpred = bpred; best_bpred = bpred;
best_idelta = 16; best_idelta = 16;
break; break;
} }
}
if ( best_idelta < 16 )
{
best_idelta = 16;
} }
block_pred = best_bpred; if ( best_idelta < 16 )
idelta = best_idelta; {
best_idelta = 16;
}
return; block_pred = best_bpred;
idelta = best_idelta;
return;
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************\ /******************************************************************************\
* Copyright (c) 2004-2008 * Copyright (c) 2004-2009
* *
* Author(s): * Author(s):
* Volker Fischer, Erik de Castro Lopo * Volker Fischer, Erik de Castro Lopo
@ -70,7 +70,7 @@ static int ms_AdaptCoeff2[MSADPCM_ADAPT_COEFF_COUNT] =
static int ms_AdaptationTable[] = static int ms_AdaptationTable[] =
{ {
230, 230, 230, 230, 307, 409, 512, 614, 230, 230, 230, 230, 307, 409, 512, 614,
768, 614, 512, 409, 307, 230, 230, 230 768, 614, 512, 409, 307, 230, 230, 230
}; };

View file

@ -1,5 +1,5 @@
/******************************************************************************\ /******************************************************************************\
* Copyright (c) 2004-2008 * Copyright (c) 2004-2009
* *
* Author(s): * Author(s):
* Volker Fischer * Volker Fischer

View file

@ -1,5 +1,5 @@
/******************************************************************************\ /******************************************************************************\
* Copyright (c) 2004-2008 * Copyright (c) 2004-2009
* *
* Author(s): * Author(s):
* Volker Fischer * Volker Fischer

View file

@ -1,5 +1,5 @@
/******************************************************************************\ /******************************************************************************\
* Copyright (c) 2004-2008 * Copyright (c) 2004-2009
* *
* Author(s): * Author(s):
* Volker Fischer * Volker Fischer
@ -46,22 +46,22 @@ void CNetBuf::Init ( const int iNewBlockSize, const int iNewNumBlocks )
// initialize number of samples for fading effect // initialize number of samples for fading effect
if ( FADE_IN_OUT_NUM_SAM < iBlockSize ) if ( FADE_IN_OUT_NUM_SAM < iBlockSize )
{ {
iNumSamFading = iBlockSize; iNumSamFading = iBlockSize;
} }
else else
{ {
iNumSamFading = FADE_IN_OUT_NUM_SAM; iNumSamFading = FADE_IN_OUT_NUM_SAM;
} }
if ( FADE_IN_OUT_NUM_SAM_EXTRA > iBlockSize ) if ( FADE_IN_OUT_NUM_SAM_EXTRA > iBlockSize )
{ {
iNumSamFadingExtra = iBlockSize; iNumSamFadingExtra = iBlockSize;
} }
else else
{ {
iNumSamFadingExtra = FADE_IN_OUT_NUM_SAM_EXTRA; iNumSamFadingExtra = FADE_IN_OUT_NUM_SAM_EXTRA;
} }
// init variables for extrapolation (in case a fade out is needed) // init variables for extrapolation (in case a fade out is needed)
dExPDiff = 0.0; dExPDiff = 0.0;
@ -96,9 +96,9 @@ fflush(pFileBI);
// fade in new block if required // fade in new block if required
if ( bFadeInNewPutData ) if ( bFadeInNewPutData )
{ {
FadeInAudioDataBlock ( vecdData ); FadeInAudioDataBlock ( vecdData );
} }
// copy new data in internal buffer // copy new data in internal buffer
int iCurPos = 0; int iCurPos = 0;
@ -109,34 +109,34 @@ fflush(pFileBI);
// data must be written in two steps because of wrap around // data must be written in two steps because of wrap around
while ( iPutPos < iMemSize ) while ( iPutPos < iMemSize )
{ {
vecdMemory[iPutPos++] = vecdData[iCurPos++]; vecdMemory[iPutPos++] = vecdData[iCurPos++];
} }
for ( iPutPos = 0; iPutPos < iRemSpace; iPutPos++ ) for ( iPutPos = 0; iPutPos < iRemSpace; iPutPos++ )
{ {
vecdMemory[iPutPos] = vecdData[iCurPos++]; vecdMemory[iPutPos] = vecdData[iCurPos++];
} }
} }
else else
{ {
// data can be written in one step // data can be written in one step
const int iEnd = iPutPos + iInSize; const int iEnd = iPutPos + iInSize;
while ( iPutPos < iEnd ) while ( iPutPos < iEnd )
{ {
vecdMemory[iPutPos++] = vecdData[iCurPos++]; vecdMemory[iPutPos++] = vecdData[iCurPos++];
} }
} }
// set buffer state flag // set buffer state flag
if ( iPutPos == iGetPos ) if ( iPutPos == iGetPos )
{ {
eBufState = CNetBuf::BS_FULL; eBufState = CNetBuf::BS_FULL;
} }
else else
{ {
eBufState = CNetBuf::BS_OK; eBufState = CNetBuf::BS_OK;
} }
return bPutOK; return bPutOK;
} }
@ -173,34 +173,34 @@ bool CNetBuf::Get ( CVector<double>& vecdData )
// data must be read in two steps because of wrap around // data must be read in two steps because of wrap around
while ( iGetPos < iMemSize ) while ( iGetPos < iMemSize )
{ {
vecdData[iCurPos++] = vecdMemory[iGetPos++]; vecdData[iCurPos++] = vecdMemory[iGetPos++];
} }
for ( iGetPos = 0; iGetPos < iRemData; iGetPos++ ) for ( iGetPos = 0; iGetPos < iRemData; iGetPos++ )
{ {
vecdData[iCurPos++] = vecdMemory[iGetPos]; vecdData[iCurPos++] = vecdMemory[iGetPos];
} }
} }
else else
{ {
// data can be read in one step // data can be read in one step
const int iEnd = iGetPos + iInSize; const int iEnd = iGetPos + iInSize;
while ( iGetPos < iEnd ) while ( iGetPos < iEnd )
{ {
vecdData[iCurPos++] = vecdMemory[iGetPos++]; vecdData[iCurPos++] = vecdMemory[iGetPos++];
} }
} }
// set buffer state flag // set buffer state flag
if ( iPutPos == iGetPos ) if ( iPutPos == iGetPos )
{ {
eBufState = CNetBuf::BS_EMPTY; eBufState = CNetBuf::BS_EMPTY;
} }
else else
{ {
eBufState = CNetBuf::BS_OK; eBufState = CNetBuf::BS_OK;
} }
/* extrapolate data from old block to avoid "clicks" /* extrapolate data from old block to avoid "clicks"
@ -208,9 +208,9 @@ bool CNetBuf::Get ( CVector<double>& vecdData )
anymore since it is already gone (processed or send through the anymore since it is already gone (processed or send through the
network) */ network) */
if ( bFadeOutExtrap ) if ( bFadeOutExtrap )
{ {
FadeOutExtrapolateAudioDataBlock ( vecdData, dExPDiff, dExPLastV ); FadeOutExtrapolateAudioDataBlock ( vecdData, dExPDiff, dExPLastV );
} }
/* save some paramters from last block which is needed in case we do not /* save some paramters from last block which is needed in case we do not
have enough data for next "get" operation and need to extrapolate the have enough data for next "get" operation and need to extrapolate the
@ -229,16 +229,16 @@ int CNetBuf::GetAvailSpace() const
// check for special case and wrap around // check for special case and wrap around
if ( iAvSpace < 0 ) if ( iAvSpace < 0 )
{ {
iAvSpace += iMemSize; // wrap around iAvSpace += iMemSize; // wrap around
} }
else else
{ {
if ( ( iAvSpace == 0 ) && ( eBufState == BS_EMPTY ) ) if ( ( iAvSpace == 0 ) && ( eBufState == BS_EMPTY ) )
{ {
iAvSpace = iMemSize; iAvSpace = iMemSize;
} }
} }
return iAvSpace; return iAvSpace;
} }
@ -250,16 +250,16 @@ int CNetBuf::GetAvailData() const
// check for special case and wrap around // check for special case and wrap around
if ( iAvData < 0 ) if ( iAvData < 0 )
{ {
iAvData += iMemSize; // wrap around iAvData += iMemSize; // wrap around
} }
else else
{ {
if ( ( iAvData == 0 ) && ( eBufState == BS_FULL ) ) if ( ( iAvData == 0 ) && ( eBufState == BS_FULL ) )
{ {
iAvData = iMemSize; iAvData = iMemSize;
} }
} }
return iAvData; return iAvData;
} }
@ -298,13 +298,13 @@ void CNetBuf::Clear ( const EClearType eClearType )
/* check for special case */ /* check for special case */
if ( iPutPos == iGetPos ) if ( iPutPos == iGetPos )
{ {
eBufState = CNetBuf::BS_FULL; eBufState = CNetBuf::BS_FULL;
} }
else else
{ {
eBufState = CNetBuf::BS_OK; eBufState = CNetBuf::BS_OK;
} }
} }
else else
{ {
@ -316,9 +316,9 @@ void CNetBuf::Clear ( const EClearType eClearType )
// wrap around // wrap around
iPutPos += iGetPos; iPutPos += iGetPos;
if ( iPutPos > iMemSize ) if ( iPutPos > iMemSize )
{ {
iPutPos -= iMemSize; iPutPos -= iMemSize;
} }
// fade out old data right before new put pointer // fade out old data right before new put pointer
int iCurPos = iPutPos - iNumSamFading; int iCurPos = iPutPos - iNumSamFading;

View file

@ -1,5 +1,5 @@
/******************************************************************************\ /******************************************************************************\
* Copyright (c) 2004-2008 * Copyright (c) 2004-2009
* *
* Author(s): * Author(s):
* Volker Fischer * Volker Fischer

View file

@ -1,5 +1,5 @@
/******************************************************************************\ /******************************************************************************\
* Copyright (c) 2004-2008 * Copyright (c) 2004-2009
* *
* Author(s): * Author(s):
* Volker Fischer * Volker Fischer

View file

@ -1,5 +1,5 @@
/******************************************************************************\ /******************************************************************************\
* Copyright (c) 2004-2008 * Copyright (c) 2004-2009
* *
* Author(s): * Author(s):
* Volker Fischer * Volker Fischer

View file

@ -1,5 +1,5 @@
/******************************************************************************\ /******************************************************************************\
* Copyright (c) 2004-2008 * Copyright (c) 2004-2009
* *
* Author(s): * Author(s):
* Volker Fischer * Volker Fischer

View file

@ -1,5 +1,5 @@
/******************************************************************************\ /******************************************************************************\
* Copyright (c) 2004-2008 * Copyright (c) 2004-2009
* *
* Author(s): * Author(s):
* Volker Fischer * Volker Fischer

View file

@ -1,5 +1,5 @@
/******************************************************************************\ /******************************************************************************\
* Copyright (c) 2004-2008 * Copyright (c) 2004-2009
* *
* Author(s): * Author(s):
* Volker Fischer * Volker Fischer

View file

@ -1,5 +1,5 @@
/******************************************************************************\ /******************************************************************************\
* Copyright (c) 2004-2008 * Copyright (c) 2004-2009
* *
* Author(s): * Author(s):
* Volker Fischer * Volker Fischer
@ -95,7 +95,7 @@ public:
} }
void SetDoAutoSockBufSize ( const bool bValue ) { bDoAutoSockBufSize = bValue; } void SetDoAutoSockBufSize ( const bool bValue ) { bDoAutoSockBufSize = bValue; }
bool GetDoAutoSockBufSize() { return bDoAutoSockBufSize; } bool GetDoAutoSockBufSize() { return bDoAutoSockBufSize; }
void SetSockBufSize ( const int iNumBlocks ) void SetSockBufSize ( const int iNumBlocks )
{ {
if ( Channel.GetSockBufSize() != iNumBlocks ) if ( Channel.GetSockBufSize() != iNumBlocks )

View file

@ -1,5 +1,5 @@
/******************************************************************************\ /******************************************************************************\
* Copyright (c) 2004-2008 * Copyright (c) 2004-2009
* *
* Author(s): * Author(s):
* Volker Fischer * Volker Fischer
@ -185,15 +185,15 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
void CClientSettingsDlg::UpdateJitterBufferFrame() void CClientSettingsDlg::UpdateJitterBufferFrame()
{ {
// update slider value and text // update slider value and text
const int iCurNumNetBuf = pClient->GetSockBufSize(); const int iCurNumNetBuf = pClient->GetSockBufSize();
SliderNetBuf->setValue ( iCurNumNetBuf ); SliderNetBuf->setValue ( iCurNumNetBuf );
TextNetBuf->setText ( "Size: " + QString().setNum ( iCurNumNetBuf ) ); TextNetBuf->setText ( "Size: " + QString().setNum ( iCurNumNetBuf ) );
// if auto setting is enabled, disable slider control // if auto setting is enabled, disable slider control
cbAutoJitBuf->setChecked ( pClient->GetDoAutoSockBufSize() ); cbAutoJitBuf->setChecked ( pClient->GetDoAutoSockBufSize() );
SliderNetBuf->setEnabled ( !pClient->GetDoAutoSockBufSize() ); SliderNetBuf->setEnabled ( !pClient->GetDoAutoSockBufSize() );
TextNetBuf->setEnabled ( !pClient->GetDoAutoSockBufSize() ); TextNetBuf->setEnabled ( !pClient->GetDoAutoSockBufSize() );
} }
void CClientSettingsDlg::UpdateSndBufInSlider ( const int iCurNumInBuf ) void CClientSettingsDlg::UpdateSndBufInSlider ( const int iCurNumInBuf )
@ -280,8 +280,8 @@ void CClientSettingsDlg::OnSoundCrdSelection ( int iSndDevIdx )
void CClientSettingsDlg::OnAutoJitBuf ( int value ) void CClientSettingsDlg::OnAutoJitBuf ( int value )
{ {
pClient->SetDoAutoSockBufSize ( value == Qt::Checked ); pClient->SetDoAutoSockBufSize ( value == Qt::Checked );
UpdateJitterBufferFrame(); UpdateJitterBufferFrame();
} }
void CClientSettingsDlg::OnOpenChatOnNewMessageStateChanged ( int value ) void CClientSettingsDlg::OnOpenChatOnNewMessageStateChanged ( int value )

View file

@ -1,5 +1,5 @@
/******************************************************************************\ /******************************************************************************\
* Copyright (c) 2004-2008 * Copyright (c) 2004-2009
* *
* Author(s): * Author(s):
* Volker Fischer * Volker Fischer
@ -84,7 +84,7 @@ public slots:
void OnSliderNetBuf ( int value ); void OnSliderNetBuf ( int value );
void OnSliderNetBufSiFactIn ( int value ); void OnSliderNetBufSiFactIn ( int value );
void OnSliderNetBufSiFactOut ( int value ); void OnSliderNetBufSiFactOut ( int value );
void OnAutoJitBuf ( int value ); void OnAutoJitBuf ( int value );
void OnOpenChatOnNewMessageStateChanged ( int value ); void OnOpenChatOnNewMessageStateChanged ( int value );
void OnAudioCompressionButtonGroupClicked ( QAbstractButton* button ); void OnAudioCompressionButtonGroupClicked ( QAbstractButton* button );
void OnPingTimeResult ( int iPingTime ); void OnPingTimeResult ( int iPingTime );

View file

@ -1,5 +1,5 @@
/******************************************************************************\ /******************************************************************************\
* Copyright (c) 2004-2008 * Copyright (c) 2004-2009
* *
* Author(s): * Author(s):
* Volker Fischer * Volker Fischer

View file

@ -1,5 +1,5 @@
/******************************************************************************\ /******************************************************************************\
* Copyright (c) 2004-2008 * Copyright (c) 2004-2009
* *
* Author(s): * Author(s):
* Volker Fischer * Volker Fischer

View file

@ -1,5 +1,5 @@
/******************************************************************************\ /******************************************************************************\
* Copyright (c) 2004-2008 * Copyright (c) 2004-2009
* *
* Author(s): * Author(s):
* Volker Fischer * Volker Fischer

View file

@ -1,5 +1,5 @@
/******************************************************************************\ /******************************************************************************\
* Copyright (c) 2004-2008 * Copyright (c) 2004-2009
* *
* Author(s): * Author(s):
* Volker Fischer * Volker Fischer

View file

@ -1,5 +1,5 @@
/******************************************************************************\ /******************************************************************************\
* Copyright (c) 2004-2008 * Copyright (c) 2004-2009
* *
* Author(s): * Author(s):
* Volker Fischer * Volker Fischer
@ -39,7 +39,7 @@ QDialog* pMainWindow = NULL;
int main ( int argc, char** argv ) int main ( int argc, char** argv )
{ {
std::string strArgument; std::string strArgument;
double rDbleArgument; double rDbleArgument;
/* check if server or client application shall be started */ /* check if server or client application shall be started */
@ -47,96 +47,96 @@ int main ( int argc, char** argv )
bool bUseGUI = true; bool bUseGUI = true;
bool bForceLowUploadRate = false; bool bForceLowUploadRate = false;
quint16 iPortNumber = LLCON_PORT_NUMBER; quint16 iPortNumber = LLCON_PORT_NUMBER;
std::string strIniFileName = ""; std::string strIniFileName = "";
std::string strHTMLStatusFileName = ""; std::string strHTMLStatusFileName = "";
std::string strServerName = ""; std::string strServerName = "";
std::string strLoggingFileName = ""; std::string strLoggingFileName = "";
/* QT docu: argv()[0] is the program name, argv()[1] is the first /* QT docu: argv()[0] is the program name, argv()[1] is the first
argument and argv()[argc()-1] is the last argument. argument and argv()[argc()-1] is the last argument.
Start with first argument, therefore "i = 1" */ Start with first argument, therefore "i = 1" */
for ( int i = 1; i < argc; i++ ) for ( int i = 1; i < argc; i++ )
{ {
// server mode flag ---------------------------------------------------------- // server mode flag ----------------------------------------------------------
if ( GetFlagArgument ( argc, argv, i, "-s", "--server" ) ) if ( GetFlagArgument ( argc, argv, i, "-s", "--server" ) )
{ {
bIsClient = false; bIsClient = false;
cerr << "server mode chosen" << std::endl; cerr << "server mode chosen" << std::endl;
continue; continue;
} }
// use GUI flag -------------------------------------------------------------- // use GUI flag --------------------------------------------------------------
if ( GetFlagArgument ( argc, argv, i, "-n", "--nogui" ) ) if ( GetFlagArgument ( argc, argv, i, "-n", "--nogui" ) )
{ {
bUseGUI = false; bUseGUI = false;
cerr << "no GUI mode chosen" << std::endl; cerr << "no GUI mode chosen" << std::endl;
continue; continue;
} }
// use logging --------------------------------------------------------------- // use logging ---------------------------------------------------------------
if ( GetStringArgument ( argc, argv, i, "-l", "--log", strArgument ) ) if ( GetStringArgument ( argc, argv, i, "-l", "--log", strArgument ) )
{ {
strLoggingFileName = strArgument; strLoggingFileName = strArgument;
cerr << "logging file name: " << strLoggingFileName << std::endl; cerr << "logging file name: " << strLoggingFileName << std::endl;
continue; continue;
} }
// force low upload data rate flag ------------------------------------------- // force low upload data rate flag -------------------------------------------
if ( GetFlagArgument ( argc, argv, i, "-u", "--lowuploadrate" ) ) if ( GetFlagArgument ( argc, argv, i, "-u", "--lowuploadrate" ) )
{ {
bForceLowUploadRate = true; bForceLowUploadRate = true;
cerr << "force low upload rate" << std::endl; cerr << "force low upload rate" << std::endl;
continue; continue;
} }
// port number --------------------------------------------------------------- // port number ---------------------------------------------------------------
if ( GetNumericArgument ( argc, argv, i, "-p", "--port", if ( GetNumericArgument ( argc, argv, i, "-p", "--port",
0, 65535, rDbleArgument ) ) 0, 65535, rDbleArgument ) )
{ {
iPortNumber = static_cast<quint16> ( rDbleArgument ); iPortNumber = static_cast<quint16> ( rDbleArgument );
cerr << "selected port number: " << iPortNumber << std::endl; cerr << "selected port number: " << iPortNumber << std::endl;
continue; continue;
} }
// HTML status file ---------------------------------------------------------- // HTML status file ----------------------------------------------------------
if ( GetStringArgument ( argc, argv, i, "-m", "--htmlstatus", strArgument ) ) if ( GetStringArgument ( argc, argv, i, "-m", "--htmlstatus", strArgument ) )
{ {
strHTMLStatusFileName = strArgument; strHTMLStatusFileName = strArgument;
cerr << "HTML status file name: " << strHTMLStatusFileName << std::endl; cerr << "HTML status file name: " << strHTMLStatusFileName << std::endl;
continue; continue;
} }
if ( GetStringArgument ( argc, argv, i, "-a", "--servername", strArgument ) ) if ( GetStringArgument ( argc, argv, i, "-a", "--servername", strArgument ) )
{ {
strServerName = strArgument; strServerName = strArgument;
cerr << "server name for HTML status file: " << strServerName << std::endl; cerr << "server name for HTML status file: " << strServerName << std::endl;
continue; continue;
} }
// initialization file ------------------------------------------------------- // initialization file -------------------------------------------------------
if ( GetStringArgument ( argc, argv, i, "-i", "--inifile", strArgument ) ) if ( GetStringArgument ( argc, argv, i, "-i", "--inifile", strArgument ) )
{ {
strIniFileName = strArgument; strIniFileName = strArgument;
cerr << "initialization file name: " << strIniFileName << std::endl; cerr << "initialization file name: " << strIniFileName << std::endl;
continue; continue;
} }
// help (usage) flag --------------------------------------------------------- // help (usage) flag ---------------------------------------------------------
if ( ( !strcmp ( argv[i], "--help" ) ) || if ( ( !strcmp ( argv[i], "--help" ) ) ||
( !strcmp ( argv[i], "-h" ) ) || ( !strcmp ( argv[i], "-?" ) ) ) ( !strcmp ( argv[i], "-h" ) ) || ( !strcmp ( argv[i], "-?" ) ) )
{ {
const std::string strHelp = UsageArguments(argv); const std::string strHelp = UsageArguments(argv);
cerr << strHelp; cerr << strHelp;
exit ( 1 ); exit ( 1 );
} }
// unknown option ------------------------------------------------------------ // unknown option ------------------------------------------------------------
cerr << argv[0] << ": "; cerr << argv[0] << ": ";
cerr << "Unknown option '" << argv[i] << "' -- use '--help' for help" cerr << "Unknown option '" << argv[i] << "' -- use '--help' for help"
<< endl; << endl;
exit ( 1 ); exit ( 1 );
} }
#ifdef _WIN32 #ifdef _WIN32
// Set application priority class -> high priority // Set application priority class -> high priority
@ -240,54 +240,54 @@ int main ( int argc, char** argv )
\******************************************************************************/ \******************************************************************************/
std::string UsageArguments ( char **argv ) std::string UsageArguments ( char **argv )
{ {
return return
"Usage: " + std::string ( argv[0] ) + " [option] [argument]\n" "Usage: " + std::string ( argv[0] ) + " [option] [argument]\n"
"Recognized options:\n" "Recognized options:\n"
" -s, --server start server\n" " -s, --server start server\n"
" -n, --nogui disable GUI (only avaiable for server)\n" " -n, --nogui disable GUI (only avaiable for server)\n"
" -l, --log enable logging, set file name\n" " -l, --log enable logging, set file name\n"
" -i, --inifile initialization file name (only available for client)\n" " -i, --inifile initialization file name (only available for client)\n"
" -p, --port local port number (only avaiable for server)\n" " -p, --port local port number (only avaiable for server)\n"
" -m, --htmlstatus enable HTML status file, set file name (only avaiable for server)\n" " -m, --htmlstatus enable HTML status file, set file name (only avaiable for server)\n"
" -u, --lowuploadrate force low upload rate (only avaiable for server)\n" " -u, --lowuploadrate force low upload rate (only avaiable for server)\n"
" -h, -?, --help this help text\n" " -h, -?, --help this help text\n"
"Example: " + std::string ( argv[0] ) + " -l -inifile myinifile.ini\n"; "Example: " + std::string ( argv[0] ) + " -l -inifile myinifile.ini\n";
} }
bool GetFlagArgument ( int, char **argv, int &i, bool GetFlagArgument ( int, char **argv, int &i,
std::string strShortOpt, std::string strLongOpt ) std::string strShortOpt, std::string strLongOpt )
{ {
if ( ( !strShortOpt.compare ( argv[i] ) ) || ( !strLongOpt.compare ( argv[i] ) ) ) if ( ( !strShortOpt.compare ( argv[i] ) ) || ( !strLongOpt.compare ( argv[i] ) ) )
{ {
return true; return true;
} }
else else
{ {
return false; return false;
} }
} }
bool GetStringArgument ( int argc, char **argv, int &i, bool GetStringArgument ( int argc, char **argv, int &i,
std::string strShortOpt, std::string strLongOpt, std::string strShortOpt, std::string strLongOpt,
std::string & strArg ) std::string & strArg )
{ {
if ( ( !strShortOpt.compare ( argv[i] ) ) || ( !strLongOpt.compare ( argv[i] ) ) ) if ( ( !strShortOpt.compare ( argv[i] ) ) || ( !strLongOpt.compare ( argv[i] ) ) )
{ {
if ( ++i >= argc ) if ( ++i >= argc )
{ {
cerr << argv[0] << ": "; cerr << argv[0] << ": ";
cerr << "'" << strLongOpt << "' needs a string argument" << endl; cerr << "'" << strLongOpt << "' needs a string argument" << endl;
exit ( 1 ); exit ( 1 );
} }
strArg = argv[i]; strArg = argv[i];
return true; return true;
} }
else else
{ {
return false; return false;
} }
} }
bool GetNumericArgument ( int argc, char **argv, int &i, bool GetNumericArgument ( int argc, char **argv, int &i,
@ -295,32 +295,32 @@ bool GetNumericArgument ( int argc, char **argv, int &i,
double rRangeStart, double rRangeStop, double rRangeStart, double rRangeStop,
double & rValue) double & rValue)
{ {
if ( ( !strShortOpt.compare ( argv[i] ) ) || ( !strLongOpt.compare ( argv[i] ) ) ) if ( ( !strShortOpt.compare ( argv[i] ) ) || ( !strLongOpt.compare ( argv[i] ) ) )
{ {
if ( ++i >= argc ) if ( ++i >= argc )
{ {
cerr << argv[0] << ": "; cerr << argv[0] << ": ";
cerr << "'" << strLongOpt << "' needs a numeric argument between " cerr << "'" << strLongOpt << "' needs a numeric argument between "
<< rRangeStart << " and " << rRangeStop << endl; << rRangeStart << " and " << rRangeStop << endl;
exit ( 1 ); exit ( 1 );
} }
char *p; char *p;
rValue = strtod ( argv[i], &p ); rValue = strtod ( argv[i], &p );
if ( *p || rValue < rRangeStart || rValue > rRangeStop ) if ( *p || rValue < rRangeStart || rValue > rRangeStop )
{ {
cerr << argv[0] << ": "; cerr << argv[0] << ": ";
cerr << "'" << strLongOpt << "' needs a numeric argument between " cerr << "'" << strLongOpt << "' needs a numeric argument between "
<< rRangeStart << " and " << rRangeStop << endl; << rRangeStart << " and " << rRangeStop << endl;
exit ( 1 ); exit ( 1 );
} }
return true; return true;
} }
else else
{ {
return false; return false;
} }
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************\ /******************************************************************************\
* Copyright (c) 2004-2008 * Copyright (c) 2004-2009
* *
* Author(s): * Author(s):
* Volker Fischer * Volker Fischer

View file

@ -1,5 +1,5 @@
/******************************************************************************\ /******************************************************************************\
* Copyright (c) 2004-2008 * Copyright (c) 2004-2009
* *
* Author(s): * Author(s):
* Volker Fischer * Volker Fischer

View file

@ -1,5 +1,5 @@
/******************************************************************************\ /******************************************************************************\
* Copyright (c) 2004-2008 * Copyright (c) 2004-2009
* *
* Author(s): * Author(s):
* Volker Fischer * Volker Fischer

View file

@ -1,5 +1,5 @@
/******************************************************************************\ /******************************************************************************\
* Copyright (c) 2004-2008 * Copyright (c) 2004-2009
* *
* Author(s): * Author(s):
* Volker Fischer * Volker Fischer

View file

@ -1,5 +1,5 @@
/******************************************************************************\ /******************************************************************************\
* Copyright (c) 2004-2008 * Copyright (c) 2004-2009
* *
* Author(s): * Author(s):
* Volker Fischer * Volker Fischer

View file

@ -1,5 +1,5 @@
/******************************************************************************\ /******************************************************************************\
* Copyright (c) 2004-2008 * Copyright (c) 2004-2009
* *
* Author(s): * Author(s):
* Volker Fischer * Volker Fischer

View file

@ -1,5 +1,5 @@
/******************************************************************************\ /******************************************************************************\
* Copyright (c) 2004-2008 * Copyright (c) 2004-2009
* *
* Author(s): * Author(s):
* Volker Fischer * Volker Fischer

View file

@ -1,5 +1,5 @@
/******************************************************************************\ /******************************************************************************\
* Copyright (c) 2004-2008 * Copyright (c) 2004-2009
* *
* Author(s): * Author(s):
* Volker Fischer * Volker Fischer

View file

@ -1,5 +1,5 @@
/******************************************************************************\ /******************************************************************************\
* Copyright (c) 2004-2008 * Copyright (c) 2004-2009
* *
* Author(s): * Author(s):
* Volker Fischer * Volker Fischer

View file

@ -48,8 +48,8 @@ public:
void Save ( const QString& sFileName = "" ) { WriteIniFile ( sFileName ); } void Save ( const QString& sFileName = "" ) { WriteIniFile ( sFileName ); }
protected: protected:
void ReadIniFile ( const QString& sFileName ); void ReadIniFile ( const QString& sFileName );
void WriteIniFile ( const QString& sFileName ); void WriteIniFile ( const QString& sFileName );
// init file access function for read/write // init file access function for read/write
void SetNumericIniSet ( QDomDocument& xmlFile, const QString& strSection, void SetNumericIniSet ( QDomDocument& xmlFile, const QString& strSection,

View file

@ -1,5 +1,5 @@
/******************************************************************************\ /******************************************************************************\
* Copyright (c) 2004-2008 * Copyright (c) 2004-2009
* *
* Author(s): * Author(s):
* Volker Fischer * Volker Fischer
@ -76,59 +76,59 @@ void CSocket::SendPacket ( const CVector<unsigned char>& vecbySendBuf,
void CSocket::OnDataReceived() void CSocket::OnDataReceived()
{ {
while ( SocketDevice.hasPendingDatagrams() ) while ( SocketDevice.hasPendingDatagrams() )
{ {
QHostAddress SenderAddress; QHostAddress SenderAddress;
quint16 SenderPort; quint16 SenderPort;
// read block from network interface and query address of sender // read block from network interface and query address of sender
int iNumBytesRead = SocketDevice.readDatagram ( (char*) &vecbyRecBuf[0], int iNumBytesRead = SocketDevice.readDatagram ( (char*) &vecbyRecBuf[0],
MAX_SIZE_BYTES_NETW_BUF, &SenderAddress, &SenderPort ); MAX_SIZE_BYTES_NETW_BUF, &SenderAddress, &SenderPort );
// check if an error occurred // check if an error occurred
if ( iNumBytesRead < 0 ) if ( iNumBytesRead < 0 )
{ {
return; return;
} }
// convert address of client // convert address of client
const CHostAddress RecHostAddr ( SenderAddress, SenderPort ); const CHostAddress RecHostAddr ( SenderAddress, SenderPort );
if ( bIsClient ) if ( bIsClient )
{ {
// client // client
// check if packet comes from the server we want to connect // check if packet comes from the server we want to connect
if ( ! ( pChannel->GetAddress() == RecHostAddr ) ) if ( ! ( pChannel->GetAddress() == RecHostAddr ) )
{ {
return; return;
} }
switch ( pChannel->PutData ( vecbyRecBuf, iNumBytesRead ) ) switch ( pChannel->PutData ( vecbyRecBuf, iNumBytesRead ) )
{ {
case PS_AUDIO_OK: case PS_AUDIO_OK:
PostWinMessage ( MS_JIT_BUF_PUT, MUL_COL_LED_GREEN ); PostWinMessage ( MS_JIT_BUF_PUT, MUL_COL_LED_GREEN );
break; break;
case PS_AUDIO_ERR: case PS_AUDIO_ERR:
case PS_GEN_ERROR: case PS_GEN_ERROR:
PostWinMessage ( MS_JIT_BUF_PUT, MUL_COL_LED_RED ); PostWinMessage ( MS_JIT_BUF_PUT, MUL_COL_LED_RED );
break; break;
case PS_PROT_ERR: case PS_PROT_ERR:
PostWinMessage ( MS_JIT_BUF_PUT, MUL_COL_LED_YELLOW ); PostWinMessage ( MS_JIT_BUF_PUT, MUL_COL_LED_YELLOW );
break; break;
} }
} }
else else
{ {
// server // server
if ( pChannelSet->PutData ( vecbyRecBuf, iNumBytesRead, RecHostAddr ) ) if ( pChannelSet->PutData ( vecbyRecBuf, iNumBytesRead, RecHostAddr ) )
{ {
// this was an audio packet, start server // this was an audio packet, start server
// tell the server object to wake up if it // tell the server object to wake up if it
// is in sleep mode (Qt will delete the event object when done) // is in sleep mode (Qt will delete the event object when done)
QCoreApplication::postEvent ( pServer, QCoreApplication::postEvent ( pServer,
new CLlconEvent ( MS_PACKET_RECEIVED, 0, 0 ) ); new CLlconEvent ( MS_PACKET_RECEIVED, 0, 0 ) );
} }
} }
} }
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************\ /******************************************************************************\
* Copyright (c) 2004-2008 * Copyright (c) 2004-2009
* *
* Author(s): * Author(s):
* Volker Fischer * Volker Fischer

View file

@ -1,5 +1,5 @@
/******************************************************************************\ /******************************************************************************\
* Copyright (c) 2004-2008 * Copyright (c) 2004-2009
* *
* Author(s): * Author(s):
* Volker Fischer * Volker Fischer

View file

@ -1,5 +1,5 @@
/******************************************************************************\ /******************************************************************************\
* Copyright (c) 2004-2008 * Copyright (c) 2004-2009
* *
* Author(s): * Author(s):
* Volker Fischer * Volker Fischer
@ -54,15 +54,15 @@ inline short Double2Short ( const double dInput )
{ {
// lower bound // lower bound
if ( dInput < _MINSHORT ) if ( dInput < _MINSHORT )
{ {
return _MINSHORT; return _MINSHORT;
} }
// upper bound // upper bound
if ( dInput > _MAXSHORT ) if ( dInput > _MAXSHORT )
{ {
return _MAXSHORT; return _MAXSHORT;
} }
return (short) dInput; return (short) dInput;
} }
@ -187,9 +187,9 @@ template<class TData> void CVector<TData>::Reset ( const TData tResetVal )
{ {
// set all values to reset value // set all values to reset value
for ( int i = 0; i < iVectorSize; i++ ) for ( int i = 0; i < iVectorSize; i++ )
{ {
pData[i] = tResetVal; pData[i] = tResetVal;
} }
} }
@ -234,9 +234,9 @@ template<class TData> void CFIFO<TData>::Add ( const TData tNewD )
// increment index // increment index
iCurIdx++; iCurIdx++;
if ( iCurIdx >= this->iVectorSize ) if ( iCurIdx >= this->iVectorSize )
{ {
iCurIdx = 0; iCurIdx = 0;
} }
} }

View file

@ -1,5 +1,5 @@
rem/******************************************************************************\ rem/******************************************************************************\
rem * Copyright (c) 2004-2008 rem * Copyright (c) 2004-2009
rem * rem *
rem * Author(s): rem * Author(s):
rem * Volker Fischer rem * Volker Fischer

View file

@ -100,7 +100,7 @@ bool CSound::Read ( CVector<short>& psData )
while ( iBufferPosCapture < iBufferSizeStereo ) while ( iBufferPosCapture < iBufferSizeStereo )
{ {
if ( bBlockingRec ) if ( bBlockingRec )
{ {
if ( !bCaptureBufferOverrun ) if ( !bCaptureBufferOverrun )
{ {
// regular case // regular case
@ -121,11 +121,11 @@ bool CSound::Read ( CVector<short>& psData )
return true; return true;
} }
} }
} }
else else
{ {
return true; return true;
} }
} }
ASIOMutex.lock(); // get mutex lock ASIOMutex.lock(); // get mutex lock
@ -140,9 +140,9 @@ bool CSound::Read ( CVector<short>& psData )
// copy data from sound card capture buffer in function output buffer // copy data from sound card capture buffer in function output buffer
for ( i = 0; i < iBufferSizeStereo; i++ ) for ( i = 0; i < iBufferSizeStereo; i++ )
{ {
psData[i] = psCaptureBuffer[i]; psData[i] = psCaptureBuffer[i];
} }
// move all other data in buffer // move all other data in buffer
const int iLenCopyRegion = iBufferPosCapture - iBufferSizeStereo; const int iLenCopyRegion = iBufferPosCapture - iBufferSizeStereo;
@ -166,7 +166,7 @@ void CSound::SetInNumBuf ( int iNewNum )
{ {
// check new parameter // check new parameter
if ( ( iNewNum < MAX_SND_BUF_IN ) && ( iNewNum >= iMinNumSndBuf ) ) if ( ( iNewNum < MAX_SND_BUF_IN ) && ( iNewNum >= iMinNumSndBuf ) )
{ {
// change only if parameter is different // change only if parameter is different
if ( iNewNum != iNewNumSndBufIn ) if ( iNewNum != iNewNumSndBufIn )
{ {
@ -232,7 +232,7 @@ void CSound::SetOutNumBuf ( int iNewNum )
{ {
// check new parameter // check new parameter
if ( ( iNewNum < MAX_SND_BUF_OUT ) && ( iNewNum >= iMinNumSndBuf ) ) if ( ( iNewNum < MAX_SND_BUF_OUT ) && ( iNewNum >= iMinNumSndBuf ) )
{ {
// change only if parameter is different // change only if parameter is different
if ( iNewNum != iNewNumSndBufOut ) if ( iNewNum != iNewNumSndBufOut )
{ {
@ -262,9 +262,9 @@ void CSound::SetDev ( const int iNewDev )
// set event to ensure that thread leaves the waiting function // set event to ensure that thread leaves the waiting function
if ( m_ASIOEvent != NULL ) if ( m_ASIOEvent != NULL )
{ {
SetEvent ( m_ASIOEvent ); SetEvent ( m_ASIOEvent );
} }
// wait for the thread to terminate // wait for the thread to terminate
Sleep ( 500 ); Sleep ( 500 );
@ -568,31 +568,31 @@ if ( iASIOBufferSizeMono == 256 )
// prepare input channels // prepare input channels
for ( i = 0; i < NUM_IN_OUT_CHANNELS; i++ ) for ( i = 0; i < NUM_IN_OUT_CHANNELS; i++ )
{ {
bufferInfos[i].isInput = ASIOTrue; bufferInfos[i].isInput = ASIOTrue;
bufferInfos[i].channelNum = i; bufferInfos[i].channelNum = i;
bufferInfos[i].buffers[0] = 0; bufferInfos[i].buffers[0] = 0;
bufferInfos[i].buffers[1] = 0; bufferInfos[i].buffers[1] = 0;
} }
// prepare output channels // prepare output channels
for ( i = 0; i < NUM_IN_OUT_CHANNELS; i++ ) for ( i = 0; i < NUM_IN_OUT_CHANNELS; i++ )
{ {
bufferInfos[NUM_IN_OUT_CHANNELS + i].isInput = ASIOFalse; bufferInfos[NUM_IN_OUT_CHANNELS + i].isInput = ASIOFalse;
bufferInfos[NUM_IN_OUT_CHANNELS + i].channelNum = i; bufferInfos[NUM_IN_OUT_CHANNELS + i].channelNum = i;
bufferInfos[NUM_IN_OUT_CHANNELS + i].buffers[0] = 0; bufferInfos[NUM_IN_OUT_CHANNELS + i].buffers[0] = 0;
bufferInfos[NUM_IN_OUT_CHANNELS + i].buffers[1] = 0; bufferInfos[NUM_IN_OUT_CHANNELS + i].buffers[1] = 0;
} }
// create and activate ASIO buffers (buffer size in samples) // create and activate ASIO buffers (buffer size in samples)
ASIOCreateBuffers ( bufferInfos, 2 /* in/out */ * NUM_IN_OUT_CHANNELS /* stereo */, ASIOCreateBuffers ( bufferInfos, 2 /* in/out */ * NUM_IN_OUT_CHANNELS /* stereo */,
iASIOBufferSizeMono, &asioCallbacks ); iASIOBufferSizeMono, &asioCallbacks );
// now get some buffer details // now get some buffer details
for ( i = 0; i < 2 * NUM_IN_OUT_CHANNELS; i++ ) for ( i = 0; i < 2 * NUM_IN_OUT_CHANNELS; i++ )
{ {
channelInfos[i].channel = bufferInfos[i].channelNum; channelInfos[i].channel = bufferInfos[i].channelNum;
channelInfos[i].isInput = bufferInfos[i].isInput; channelInfos[i].isInput = bufferInfos[i].isInput;
ASIOGetChannelInfo ( &channelInfos[i] ); ASIOGetChannelInfo ( &channelInfos[i] );
// only 16/24/32 LSB is supported // only 16/24/32 LSB is supported
if ( ( channelInfos[i].type != ASIOSTInt16LSB ) && if ( ( channelInfos[i].type != ASIOSTInt16LSB ) &&
@ -631,9 +631,9 @@ void CSound::InitRecordingAndPlayback()
// create memory for capture buffer // create memory for capture buffer
if ( psCaptureBuffer != NULL ) if ( psCaptureBuffer != NULL )
{ {
delete[] psCaptureBuffer; delete[] psCaptureBuffer;
} }
psCaptureBuffer = new short[iCurNumSndBufIn * iBufferSizeStereo]; psCaptureBuffer = new short[iCurNumSndBufIn * iBufferSizeStereo];
// initialize write block pointer out and underrun flag // initialize write block pointer out and underrun flag
@ -642,16 +642,16 @@ void CSound::InitRecordingAndPlayback()
// create memory for play buffer // create memory for play buffer
if ( psPlayBuffer != NULL ) if ( psPlayBuffer != NULL )
{ {
delete[] psPlayBuffer; delete[] psPlayBuffer;
} }
psPlayBuffer = new short[iCurNumSndBufOut * iBufferSizeStereo]; psPlayBuffer = new short[iCurNumSndBufOut * iBufferSizeStereo];
// clear new buffer // clear new buffer
for ( int i = 0; i < iCurNumSndBufOut * iBufferSizeStereo; i++ ) for ( int i = 0; i < iCurNumSndBufOut * iBufferSizeStereo; i++ )
{ {
psPlayBuffer[i] = 0; psPlayBuffer[i] = 0;
} }
// reset event // reset event
ResetEvent ( m_ASIOEvent ); ResetEvent ( m_ASIOEvent );
@ -669,9 +669,9 @@ void CSound::Close()
// set event to ensure that thread leaves the waiting function // set event to ensure that thread leaves the waiting function
if ( m_ASIOEvent != NULL ) if ( m_ASIOEvent != NULL )
{ {
SetEvent ( m_ASIOEvent ); SetEvent ( m_ASIOEvent );
} }
// wait for the thread to terminate // wait for the thread to terminate
Sleep ( 500 ); Sleep ( 500 );
@ -698,7 +698,7 @@ CSound::CSound ( const int iNewBufferSizeStereo )
m_ASIOEvent = NULL; m_ASIOEvent = NULL;
// get available ASIO driver names in system // get available ASIO driver names in system
for ( int i = 0; i < MAX_NUMBER_SOUND_CARDS; i++ ) for ( int i = 0; i < MAX_NUMBER_SOUND_CARDS; i++ )
{ {
cDriverNames[i] = new char[32]; cDriverNames[i] = new char[32];
} }
@ -717,11 +717,11 @@ CSound::CSound ( const int iNewBufferSizeStereo )
// init device index with illegal value to show that driver is not initialized // init device index with illegal value to show that driver is not initialized
lCurDev = -1; lCurDev = -1;
// set up the asioCallback structure // set up the asioCallback structure
asioCallbacks.bufferSwitch = &bufferSwitch; asioCallbacks.bufferSwitch = &bufferSwitch;
asioCallbacks.sampleRateDidChange = &sampleRateChanged; asioCallbacks.sampleRateDidChange = &sampleRateChanged;
asioCallbacks.asioMessage = &asioMessages; asioCallbacks.asioMessage = &asioMessages;
asioCallbacks.bufferSwitchTimeInfo = &bufferSwitchTimeInfo; asioCallbacks.bufferSwitchTimeInfo = &bufferSwitchTimeInfo;
// init buffer pointer to zero // init buffer pointer to zero
psCaptureBuffer = NULL; psCaptureBuffer = NULL;
@ -747,19 +747,19 @@ CSound::~CSound()
// delete allocated memory // delete allocated memory
if ( psCaptureBuffer != NULL ) if ( psCaptureBuffer != NULL )
{ {
delete[] psCaptureBuffer; delete[] psCaptureBuffer;
} }
if ( psPlayBuffer != NULL ) if ( psPlayBuffer != NULL )
{ {
delete[] psPlayBuffer; delete[] psPlayBuffer;
} }
// close the handle for the event // close the handle for the event
if ( m_ASIOEvent != NULL ) if ( m_ASIOEvent != NULL )
{ {
CloseHandle ( m_ASIOEvent ); CloseHandle ( m_ASIOEvent );
} }
} }
// ASIO callbacks ------------------------------------------------------------- // ASIO callbacks -------------------------------------------------------------
@ -767,8 +767,8 @@ ASIOTime* CSound::bufferSwitchTimeInfo ( ASIOTime *timeInfo,
long index, long index,
ASIOBool processNow ) ASIOBool processNow )
{ {
bufferSwitch ( index, processNow ); bufferSwitch ( index, processNow );
return 0L; return 0L;
} }
void CSound::bufferSwitch ( long index, ASIOBool processNow ) void CSound::bufferSwitch ( long index, ASIOBool processNow )
@ -786,28 +786,28 @@ void CSound::bufferSwitch ( long index, ASIOBool processNow )
bPlayBufferUnderrun = ( 2 * iASIOBufferSizeMono > iBufferPosPlay ); bPlayBufferUnderrun = ( 2 * iASIOBufferSizeMono > iBufferPosPlay );
// perform the processing for input and output // perform the processing for input and output
for ( int i = 0; i < 2 * NUM_IN_OUT_CHANNELS; i++ ) // stereo for ( int i = 0; i < 2 * NUM_IN_OUT_CHANNELS; i++ ) // stereo
{ {
if ( bufferInfos[i].isInput == ASIOTrue ) if ( bufferInfos[i].isInput == ASIOTrue )
{ {
// CAPTURE ----------------------------------------------------- // CAPTURE -----------------------------------------------------
// first check if space in buffer is available // first check if space in buffer is available
if ( !bCaptureBufferOverrun ) if ( !bCaptureBufferOverrun )
{ {
// copy new captured block in thread transfer buffer (copy // copy new captured block in thread transfer buffer (copy
// mono data interleaved in stereo buffer) // mono data interleaved in stereo buffer)
switch ( channelInfos[i].type ) switch ( channelInfos[i].type )
{ {
case ASIOSTInt16LSB: case ASIOSTInt16LSB:
for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ )
{ {
psCaptureBuffer[iBufferPosCapture + psCaptureBuffer[iBufferPosCapture +
2 * iCurSample + bufferInfos[i].channelNum] = 2 * iCurSample + bufferInfos[i].channelNum] =
( (short*) bufferInfos[i].buffers[index] )[iCurSample]; ( (short*) bufferInfos[i].buffers[index] )[iCurSample];
} }
break; break;
case ASIOSTInt24LSB: case ASIOSTInt24LSB:
// not yet tested, horrible things might happen with the following code ;-) // not yet tested, horrible things might happen with the following code ;-)
@ -821,9 +821,9 @@ void CSound::bufferSwitch ( long index, ASIOBool processNow )
psCaptureBuffer[iBufferPosCapture + psCaptureBuffer[iBufferPosCapture +
2 * iCurSample + bufferInfos[i].channelNum] = static_cast<short> ( iCurSam ); 2 * iCurSample + bufferInfos[i].channelNum] = static_cast<short> ( iCurSam );
} }
break; break;
case ASIOSTInt32LSB: case ASIOSTInt32LSB:
for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ )
{ {
// convert to 16 bit // convert to 16 bit
@ -831,10 +831,10 @@ void CSound::bufferSwitch ( long index, ASIOBool processNow )
2 * iCurSample + bufferInfos[i].channelNum] = 2 * iCurSample + bufferInfos[i].channelNum] =
(((int*) bufferInfos[i].buffers[index])[iCurSample] >> 16); (((int*) bufferInfos[i].buffers[index])[iCurSample] >> 16);
} }
break; break;
} }
} }
} }
else else
{ {
// PLAYBACK ---------------------------------------------------- // PLAYBACK ----------------------------------------------------
@ -842,42 +842,42 @@ void CSound::bufferSwitch ( long index, ASIOBool processNow )
{ {
// copy data from sound card in output buffer (copy // copy data from sound card in output buffer (copy
// interleaved stereo data in mono sound card buffer) // interleaved stereo data in mono sound card buffer)
switch ( channelInfos[i].type ) switch ( channelInfos[i].type )
{ {
case ASIOSTInt16LSB: case ASIOSTInt16LSB:
for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ )
{ {
( (short*) bufferInfos[i].buffers[index] )[iCurSample] = ( (short*) bufferInfos[i].buffers[index] )[iCurSample] =
psPlayBuffer[2 * iCurSample + bufferInfos[i].channelNum]; psPlayBuffer[2 * iCurSample + bufferInfos[i].channelNum];
} }
break; break;
case ASIOSTInt24LSB: case ASIOSTInt24LSB:
// not yet tested, horrible things might happen with the following code ;-) // not yet tested, horrible things might happen with the following code ;-)
for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ )
{ {
// convert current sample in 24 bit format // convert current sample in 24 bit format
int iCurSam = static_cast<int> ( psPlayBuffer[2 * iCurSample + bufferInfos[i].channelNum] ); int iCurSam = static_cast<int> ( psPlayBuffer[2 * iCurSample + bufferInfos[i].channelNum] );
iCurSam <<= 8; iCurSam <<= 8;
memcpy ( ( (char*) bufferInfos[i].buffers[index] ) + iCurSample * 3, &iCurSam, 3 ); memcpy ( ( (char*) bufferInfos[i].buffers[index] ) + iCurSample * 3, &iCurSam, 3 );
} }
break; break;
case ASIOSTInt32LSB: case ASIOSTInt32LSB:
for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ )
{ {
// convert to 32 bit // convert to 32 bit
int iCurSam = static_cast<int> ( psPlayBuffer[2 * iCurSample + bufferInfos[i].channelNum] ); int iCurSam = static_cast<int> ( psPlayBuffer[2 * iCurSample + bufferInfos[i].channelNum] );
( (int*) bufferInfos[i].buffers[index] )[iCurSample] = ( iCurSam << 16 ); ( (int*) bufferInfos[i].buffers[index] )[iCurSample] = ( iCurSam << 16 );
} }
break; break;
} }
} }
} }
} }
// Manage thread interface buffers for input and output ---------------- // Manage thread interface buffers for input and output ----------------
@ -907,7 +907,7 @@ void CSound::bufferSwitch ( long index, ASIOBool processNow )
// do it here, all data are in place ----------------------------------- // do it here, all data are in place -----------------------------------
if ( bASIOPostOutput ) if ( bASIOPostOutput )
{ {
ASIOOutputReady(); ASIOOutputReady();
} }
// set event // set event
@ -918,13 +918,13 @@ void CSound::bufferSwitch ( long index, ASIOBool processNow )
long CSound::asioMessages ( long selector, long value, void* message, double* opt ) long CSound::asioMessages ( long selector, long value, void* message, double* opt )
{ {
long ret = 0; long ret = 0;
switch(selector) switch(selector)
{ {
case kAsioEngineVersion: case kAsioEngineVersion:
// return the supported ASIO version of the host application // return the supported ASIO version of the host application
ret = 2L; ret = 2L;
break; break;
} }
return ret; return ret;
} }

View file

@ -92,10 +92,10 @@ protected:
// audio hardware buffer info // audio hardware buffer info
struct sHWBufferInfo struct sHWBufferInfo
{ {
long lMinSize; long lMinSize;
long lMaxSize; long lMaxSize;
long lPreferredSize; long lPreferredSize;
long lGranularity; long lGranularity;
} HWBufferInfo; } HWBufferInfo;
// callbacks // callbacks