From c077f6ecf8ce535e6e05e60ef78028c4199ea6b6 Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Sun, 22 Feb 2009 11:07:18 +0000 Subject: [PATCH] code cleanup (removed tabs), 2008 -> 2009 --- ChangeLog | 26 ++-- INSTALL | 2 +- README | 2 +- src/audiocompr.cpp | 190 ++++++++++++++--------------- src/audiocompr.h | 4 +- src/audiomixerboard.cpp | 2 +- src/audiomixerboard.h | 2 +- src/buffer.cpp | 110 ++++++++--------- src/buffer.h | 2 +- src/channel.cpp | 2 +- src/channel.h | 2 +- src/chatdlg.cpp | 2 +- src/chatdlg.h | 2 +- src/client.cpp | 2 +- src/client.h | 4 +- src/clientsettingsdlg.cpp | 18 +-- src/clientsettingsdlg.h | 4 +- src/llconclientdlg.cpp | 2 +- src/llconclientdlg.h | 2 +- src/llconserverdlg.cpp | 2 +- src/llconserverdlg.h | 2 +- src/main.cpp | 244 +++++++++++++++++++------------------- src/multicolorled.cpp | 2 +- src/multicolorled.h | 2 +- src/protocol.cpp | 2 +- src/protocol.h | 2 +- src/resample.cpp | 2 +- src/resample.h | 2 +- src/server.cpp | 2 +- src/server.h | 2 +- src/settings.cpp | 2 +- src/settings.h | 4 +- src/socket.cpp | 96 +++++++-------- src/socket.h | 2 +- src/util.cpp | 2 +- src/util.h | 18 +-- windows/MocQT.bat | 2 +- windows/sound.cpp | 154 ++++++++++++------------ windows/sound.h | 8 +- 39 files changed, 467 insertions(+), 465 deletions(-) diff --git a/ChangeLog b/ChangeLog index aba39f12..8501cb86 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,13 +1,13 @@ -2.1.4 - -- added automatic jitter buffer size setting - -- speed optimizations to improve audio interface stability - -- new defaults (e.g. turn off Reverb by default since it requires significant - CPU - - +2.1.4 + +- added automatic jitter buffer size setting + +- speed optimizations to improve audio interface stability + +- new defaults (e.g. turn off Reverb by default since it requires significant + CPU) + + 2.1.3 - added sound card selection @@ -23,7 +23,8 @@ - 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 @@ -51,7 +52,8 @@ - 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 diff --git a/INSTALL b/INSTALL index e98257b8..aacff4ca 100755 --- a/INSTALL +++ b/INSTALL @@ -1,5 +1,5 @@ /******************************************************************************\ - * Copyright (c) 2004-2008 + * Copyright (c) 2004-2009 * * Author(s): * Volker Fischer diff --git a/README b/README index bb08033a..c30409fe 100755 --- a/README +++ b/README @@ -1,5 +1,5 @@ /******************************************************************************\ - * Copyright (c) 2004-2008 + * Copyright (c) 2004-2009 * * Author(s): * Volker Fischer diff --git a/src/audiocompr.cpp b/src/audiocompr.cpp index 452cddc9..6431af34 100755 --- a/src/audiocompr.cpp +++ b/src/audiocompr.cpp @@ -1,5 +1,5 @@ /******************************************************************************\ - * Copyright (c) 2004-2008 + * Copyright (c) 2004-2009 * * Author(s): * Volker Fischer, Erik de Castro Lopo @@ -97,9 +97,9 @@ CVector CAudioCompression::Decode ( const CVector& vecbyAd { int current = vecbyAdpcm[2 * i] | ( vecbyAdpcm[2 * i + 1] << 8 ); if ( current & 0x8000 ) - { + { current -= 0x10000; - } + } vecsOut[i] = (short) current; } @@ -188,13 +188,13 @@ CVector CImaAdpcm::Encode ( const CVector& vecsAudio ) } if ( bytecode & 8 ) - { + { iPrevAudio -= vpdiff; - } + } else - { + { iPrevAudio += vpdiff; - } + } // adjust step size Q_ASSERT ( bytecode < IMA_INDX_ADJUST_TAB_LEN ); @@ -233,9 +233,9 @@ CVector CImaAdpcm::Decode ( const CVector& vecbyAdpcm ) /* Read the block header ------------------------------------------------ */ int current = vecbyAdpcm[0] | ( vecbyAdpcm[1] << 8 ); if ( current & 0x8000 ) - { + { current -= 0x10000; - } + } // get and bound step index int iStepindDec = CheckBounds ( vecbyAdpcm[2], 0, IMA_STEP_SIZE_TAB_LEN - 1 ); @@ -270,21 +270,21 @@ CVector CImaAdpcm::Decode ( const CVector& vecbyAdpcm ) int diff = step >> 3; if ( bytecode & 1 ) - { + { diff += step >> 2; - } + } if ( bytecode & 2 ) - { + { diff += step >> 1; - } + } if ( bytecode & 4 ) - { + { diff += step; - } + } if ( bytecode & 8 ) - { + { diff = -diff; - } + } current += diff; @@ -345,70 +345,70 @@ CVector CMsAdpcm::Encode ( const CVector& vecsAudio ) /* Encode the block header ---------------------------------------------- */ vecbyAdpcm[0] = bpred; - vecbyAdpcm[1] = idelta & 0xFF; - vecbyAdpcm[2] = ( idelta >> 8 ) & 0xFF; - vecbyAdpcm[3] = vecsAudio[1] & 0xFF; - vecbyAdpcm[4] = ( vecsAudio[1] >> 8 ) & 0xFF; - vecbyAdpcm[5] = vecsAudio[0] & 0xFF; - vecbyAdpcm[6] = ( vecsAudio[0] >> 8 ) & 0xFF; + vecbyAdpcm[1] = idelta & 0xFF; + vecbyAdpcm[2] = ( idelta >> 8 ) & 0xFF; + vecbyAdpcm[3] = vecsAudio[1] & 0xFF; + vecbyAdpcm[4] = ( vecsAudio[1] >> 8 ) & 0xFF; + vecbyAdpcm[5] = vecsAudio[0] & 0xFF; + vecbyAdpcm[6] = ( vecsAudio[0] >> 8 ) & 0xFF; /* Encode the samples as 4 bit ------------------------------------------ */ - unsigned int blockindx = 7; - unsigned char byte = 0; + unsigned int blockindx = 7; + unsigned char byte = 0; for ( int k = 2; k < iAudSize; k++ ) - { + { const int predict = ( vecsAudioTemp[k - 1] * ms_AdaptCoeff1[bpred] + 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) { - 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 ) { - 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; - byte = 0; - } - - idelta = ( idelta * ms_AdaptationTable[errordelta] ) >> 8; - - if ( idelta < 16 ) - { - idelta = 16; + byte = 0; } - vecsAudioTemp[k] = newsamp; - } + + idelta = ( idelta * ms_AdaptationTable[errordelta] ) >> 8; + + if ( idelta < 16 ) + { + idelta = 16; + } + vecsAudioTemp[k] = newsamp; + } return vecbyAdpcm; } @@ -430,10 +430,10 @@ CVector CMsAdpcm::Decode ( const CVector& vecbyAdpcm ) 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[0] = vecbyAdpcm[5] | ( vecbyAdpcm[6] << 8 ); + vecsAudio[1] = vecbyAdpcm[3] | ( vecbyAdpcm[4] << 8 ); + vecsAudio[0] = vecbyAdpcm[5] | ( vecbyAdpcm[6] << 8 ); /* ------------------------------------------------------------------------- @@ -448,48 +448,48 @@ CVector CMsAdpcm::Decode ( const CVector& vecbyAdpcm ) /* Decode the encoded 4 bit samples ------------------------------------- */ - for ( int k = 2; k < iAudSize; k ++ ) - { - bytecode = vecsAudio[k] & 0xF; + for ( int k = 2; k < iAudSize; k ++ ) + { + bytecode = vecsAudio[k] & 0xF; - // compute next Adaptive Scale Factor (ASF) - int idelta = chan_idelta; + // compute next Adaptive Scale Factor (ASF) + int idelta = chan_idelta; // => / 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 - 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; - 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 ) { - current = -32768; + current = -32768; } } - vecsAudio[k] = current; - } + vecsAudio[k] = current; + } - return vecsAudio; + return vecsAudio; } void CMsAdpcm::ChoosePredictor ( const CVector& vecsAudio, @@ -516,39 +516,39 @@ void CMsAdpcm::ChoosePredictor ( const CVector& vecsAudio, by using all the samples to choose the predictor. */ 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; - 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 - 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_idelta = idelta_sum; - } + best_idelta = idelta_sum; + } - if ( !idelta_sum ) - { + if ( !idelta_sum ) + { best_bpred = bpred; - best_idelta = 16; - break; - } - } - - if ( best_idelta < 16 ) - { - best_idelta = 16; + best_idelta = 16; + break; + } } - block_pred = best_bpred; - idelta = best_idelta; + if ( best_idelta < 16 ) + { + best_idelta = 16; + } - return; + block_pred = best_bpred; + idelta = best_idelta; + + return; } diff --git a/src/audiocompr.h b/src/audiocompr.h index 73af97ac..26351a03 100755 --- a/src/audiocompr.h +++ b/src/audiocompr.h @@ -1,5 +1,5 @@ /******************************************************************************\ - * Copyright (c) 2004-2008 + * Copyright (c) 2004-2009 * * Author(s): * Volker Fischer, Erik de Castro Lopo @@ -70,7 +70,7 @@ static int ms_AdaptCoeff2[MSADPCM_ADAPT_COEFF_COUNT] = static int ms_AdaptationTable[] = { 230, 230, 230, 230, 307, 409, 512, 614, - 768, 614, 512, 409, 307, 230, 230, 230 + 768, 614, 512, 409, 307, 230, 230, 230 }; diff --git a/src/audiomixerboard.cpp b/src/audiomixerboard.cpp index 6d4cba3a..7fff2ba7 100755 --- a/src/audiomixerboard.cpp +++ b/src/audiomixerboard.cpp @@ -1,5 +1,5 @@ /******************************************************************************\ - * Copyright (c) 2004-2008 + * Copyright (c) 2004-2009 * * Author(s): * Volker Fischer diff --git a/src/audiomixerboard.h b/src/audiomixerboard.h index 48d696bf..a61c99f4 100755 --- a/src/audiomixerboard.h +++ b/src/audiomixerboard.h @@ -1,5 +1,5 @@ /******************************************************************************\ - * Copyright (c) 2004-2008 + * Copyright (c) 2004-2009 * * Author(s): * Volker Fischer diff --git a/src/buffer.cpp b/src/buffer.cpp index 562bd9dd..ee4dcd0d 100755 --- a/src/buffer.cpp +++ b/src/buffer.cpp @@ -1,5 +1,5 @@ /******************************************************************************\ - * Copyright (c) 2004-2008 + * Copyright (c) 2004-2009 * * Author(s): * Volker Fischer @@ -46,22 +46,22 @@ void CNetBuf::Init ( const int iNewBlockSize, const int iNewNumBlocks ) // initialize number of samples for fading effect if ( FADE_IN_OUT_NUM_SAM < iBlockSize ) - { + { iNumSamFading = iBlockSize; - } + } else - { + { iNumSamFading = FADE_IN_OUT_NUM_SAM; - } + } if ( FADE_IN_OUT_NUM_SAM_EXTRA > iBlockSize ) - { + { iNumSamFadingExtra = iBlockSize; - } + } else - { + { iNumSamFadingExtra = FADE_IN_OUT_NUM_SAM_EXTRA; - } + } // init variables for extrapolation (in case a fade out is needed) dExPDiff = 0.0; @@ -96,9 +96,9 @@ fflush(pFileBI); // fade in new block if required if ( bFadeInNewPutData ) - { + { FadeInAudioDataBlock ( vecdData ); - } + } // copy new data in internal buffer int iCurPos = 0; @@ -109,34 +109,34 @@ fflush(pFileBI); // data must be written in two steps because of wrap around while ( iPutPos < iMemSize ) - { + { vecdMemory[iPutPos++] = vecdData[iCurPos++]; - } + } for ( iPutPos = 0; iPutPos < iRemSpace; iPutPos++ ) - { + { vecdMemory[iPutPos] = vecdData[iCurPos++]; - } + } } else { // data can be written in one step const int iEnd = iPutPos + iInSize; while ( iPutPos < iEnd ) - { + { vecdMemory[iPutPos++] = vecdData[iCurPos++]; - } + } } // set buffer state flag if ( iPutPos == iGetPos ) - { + { eBufState = CNetBuf::BS_FULL; - } + } else - { + { eBufState = CNetBuf::BS_OK; - } + } return bPutOK; } @@ -173,34 +173,34 @@ bool CNetBuf::Get ( CVector& vecdData ) // data must be read in two steps because of wrap around while ( iGetPos < iMemSize ) - { + { vecdData[iCurPos++] = vecdMemory[iGetPos++]; - } + } for ( iGetPos = 0; iGetPos < iRemData; iGetPos++ ) - { + { vecdData[iCurPos++] = vecdMemory[iGetPos]; - } + } } else { // data can be read in one step const int iEnd = iGetPos + iInSize; while ( iGetPos < iEnd ) - { + { vecdData[iCurPos++] = vecdMemory[iGetPos++]; - } + } } // set buffer state flag if ( iPutPos == iGetPos ) - { + { eBufState = CNetBuf::BS_EMPTY; - } + } else - { + { eBufState = CNetBuf::BS_OK; - } + } /* extrapolate data from old block to avoid "clicks" @@ -208,9 +208,9 @@ bool CNetBuf::Get ( CVector& vecdData ) anymore since it is already gone (processed or send through the network) */ if ( bFadeOutExtrap ) - { + { FadeOutExtrapolateAudioDataBlock ( vecdData, dExPDiff, dExPLastV ); - } + } /* 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 @@ -229,16 +229,16 @@ int CNetBuf::GetAvailSpace() const // check for special case and wrap around if ( iAvSpace < 0 ) - { + { iAvSpace += iMemSize; // wrap around - } + } else - { - if ( ( iAvSpace == 0 ) && ( eBufState == BS_EMPTY ) ) - { - iAvSpace = iMemSize; - } - } + { + if ( ( iAvSpace == 0 ) && ( eBufState == BS_EMPTY ) ) + { + iAvSpace = iMemSize; + } + } return iAvSpace; } @@ -250,16 +250,16 @@ int CNetBuf::GetAvailData() const // check for special case and wrap around if ( iAvData < 0 ) - { + { iAvData += iMemSize; // wrap around - } + } else - { - if ( ( iAvData == 0 ) && ( eBufState == BS_FULL ) ) - { - iAvData = iMemSize; - } - } + { + if ( ( iAvData == 0 ) && ( eBufState == BS_FULL ) ) + { + iAvData = iMemSize; + } + } return iAvData; } @@ -298,13 +298,13 @@ void CNetBuf::Clear ( const EClearType eClearType ) /* check for special case */ if ( iPutPos == iGetPos ) - { + { eBufState = CNetBuf::BS_FULL; - } + } else - { + { eBufState = CNetBuf::BS_OK; - } + } } else { @@ -316,9 +316,9 @@ void CNetBuf::Clear ( const EClearType eClearType ) // wrap around iPutPos += iGetPos; if ( iPutPos > iMemSize ) - { + { iPutPos -= iMemSize; - } + } // fade out old data right before new put pointer int iCurPos = iPutPos - iNumSamFading; diff --git a/src/buffer.h b/src/buffer.h index f26ca4aa..291ea4f5 100755 --- a/src/buffer.h +++ b/src/buffer.h @@ -1,5 +1,5 @@ /******************************************************************************\ - * Copyright (c) 2004-2008 + * Copyright (c) 2004-2009 * * Author(s): * Volker Fischer diff --git a/src/channel.cpp b/src/channel.cpp index a431712d..eee236ee 100755 --- a/src/channel.cpp +++ b/src/channel.cpp @@ -1,5 +1,5 @@ /******************************************************************************\ - * Copyright (c) 2004-2008 + * Copyright (c) 2004-2009 * * Author(s): * Volker Fischer diff --git a/src/channel.h b/src/channel.h index b885e8c3..c1fd97a0 100755 --- a/src/channel.h +++ b/src/channel.h @@ -1,5 +1,5 @@ /******************************************************************************\ - * Copyright (c) 2004-2008 + * Copyright (c) 2004-2009 * * Author(s): * Volker Fischer diff --git a/src/chatdlg.cpp b/src/chatdlg.cpp index 5943ff31..0e365748 100755 --- a/src/chatdlg.cpp +++ b/src/chatdlg.cpp @@ -1,5 +1,5 @@ /******************************************************************************\ - * Copyright (c) 2004-2008 + * Copyright (c) 2004-2009 * * Author(s): * Volker Fischer diff --git a/src/chatdlg.h b/src/chatdlg.h index 1627ebdd..0f2d6f14 100755 --- a/src/chatdlg.h +++ b/src/chatdlg.h @@ -1,5 +1,5 @@ /******************************************************************************\ - * Copyright (c) 2004-2008 + * Copyright (c) 2004-2009 * * Author(s): * Volker Fischer diff --git a/src/client.cpp b/src/client.cpp index 7918fe8c..37567ab8 100755 --- a/src/client.cpp +++ b/src/client.cpp @@ -1,5 +1,5 @@ /******************************************************************************\ - * Copyright (c) 2004-2008 + * Copyright (c) 2004-2009 * * Author(s): * Volker Fischer diff --git a/src/client.h b/src/client.h index e5a2a178..1ccdad51 100755 --- a/src/client.h +++ b/src/client.h @@ -1,5 +1,5 @@ /******************************************************************************\ - * Copyright (c) 2004-2008 + * Copyright (c) 2004-2009 * * Author(s): * Volker Fischer @@ -95,7 +95,7 @@ public: } void SetDoAutoSockBufSize ( const bool bValue ) { bDoAutoSockBufSize = bValue; } - bool GetDoAutoSockBufSize() { return bDoAutoSockBufSize; } + bool GetDoAutoSockBufSize() { return bDoAutoSockBufSize; } void SetSockBufSize ( const int iNumBlocks ) { if ( Channel.GetSockBufSize() != iNumBlocks ) diff --git a/src/clientsettingsdlg.cpp b/src/clientsettingsdlg.cpp index 7e1ec426..a9903579 100755 --- a/src/clientsettingsdlg.cpp +++ b/src/clientsettingsdlg.cpp @@ -1,5 +1,5 @@ /******************************************************************************\ - * Copyright (c) 2004-2008 + * Copyright (c) 2004-2009 * * Author(s): * Volker Fischer @@ -185,15 +185,15 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent, void CClientSettingsDlg::UpdateJitterBufferFrame() { - // update slider value and text - const int iCurNumNetBuf = pClient->GetSockBufSize(); + // update slider value and text + const int iCurNumNetBuf = pClient->GetSockBufSize(); SliderNetBuf->setValue ( iCurNumNetBuf ); TextNetBuf->setText ( "Size: " + QString().setNum ( iCurNumNetBuf ) ); - // if auto setting is enabled, disable slider control - cbAutoJitBuf->setChecked ( pClient->GetDoAutoSockBufSize() ); - SliderNetBuf->setEnabled ( !pClient->GetDoAutoSockBufSize() ); - TextNetBuf->setEnabled ( !pClient->GetDoAutoSockBufSize() ); + // if auto setting is enabled, disable slider control + cbAutoJitBuf->setChecked ( pClient->GetDoAutoSockBufSize() ); + SliderNetBuf->setEnabled ( !pClient->GetDoAutoSockBufSize() ); + TextNetBuf->setEnabled ( !pClient->GetDoAutoSockBufSize() ); } void CClientSettingsDlg::UpdateSndBufInSlider ( const int iCurNumInBuf ) @@ -280,8 +280,8 @@ void CClientSettingsDlg::OnSoundCrdSelection ( int iSndDevIdx ) void CClientSettingsDlg::OnAutoJitBuf ( int value ) { - pClient->SetDoAutoSockBufSize ( value == Qt::Checked ); - UpdateJitterBufferFrame(); + pClient->SetDoAutoSockBufSize ( value == Qt::Checked ); + UpdateJitterBufferFrame(); } void CClientSettingsDlg::OnOpenChatOnNewMessageStateChanged ( int value ) diff --git a/src/clientsettingsdlg.h b/src/clientsettingsdlg.h index 60c2f963..d2d3d17a 100755 --- a/src/clientsettingsdlg.h +++ b/src/clientsettingsdlg.h @@ -1,5 +1,5 @@ /******************************************************************************\ - * Copyright (c) 2004-2008 + * Copyright (c) 2004-2009 * * Author(s): * Volker Fischer @@ -84,7 +84,7 @@ public slots: void OnSliderNetBuf ( int value ); void OnSliderNetBufSiFactIn ( int value ); void OnSliderNetBufSiFactOut ( int value ); - void OnAutoJitBuf ( int value ); + void OnAutoJitBuf ( int value ); void OnOpenChatOnNewMessageStateChanged ( int value ); void OnAudioCompressionButtonGroupClicked ( QAbstractButton* button ); void OnPingTimeResult ( int iPingTime ); diff --git a/src/llconclientdlg.cpp b/src/llconclientdlg.cpp index 9197d305..a2ea3e04 100755 --- a/src/llconclientdlg.cpp +++ b/src/llconclientdlg.cpp @@ -1,5 +1,5 @@ /******************************************************************************\ - * Copyright (c) 2004-2008 + * Copyright (c) 2004-2009 * * Author(s): * Volker Fischer diff --git a/src/llconclientdlg.h b/src/llconclientdlg.h index 1953bab8..dfb44c69 100755 --- a/src/llconclientdlg.h +++ b/src/llconclientdlg.h @@ -1,5 +1,5 @@ /******************************************************************************\ - * Copyright (c) 2004-2008 + * Copyright (c) 2004-2009 * * Author(s): * Volker Fischer diff --git a/src/llconserverdlg.cpp b/src/llconserverdlg.cpp index 7e8fd199..ce9ef6ca 100755 --- a/src/llconserverdlg.cpp +++ b/src/llconserverdlg.cpp @@ -1,5 +1,5 @@ /******************************************************************************\ - * Copyright (c) 2004-2008 + * Copyright (c) 2004-2009 * * Author(s): * Volker Fischer diff --git a/src/llconserverdlg.h b/src/llconserverdlg.h index 73aec7d0..2e46391b 100755 --- a/src/llconserverdlg.h +++ b/src/llconserverdlg.h @@ -1,5 +1,5 @@ /******************************************************************************\ - * Copyright (c) 2004-2008 + * Copyright (c) 2004-2009 * * Author(s): * Volker Fischer diff --git a/src/main.cpp b/src/main.cpp index 54214ce2..c9ed351c 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,5 @@ /******************************************************************************\ - * Copyright (c) 2004-2008 + * Copyright (c) 2004-2009 * * Author(s): * Volker Fischer @@ -39,7 +39,7 @@ QDialog* pMainWindow = NULL; int main ( int argc, char** argv ) { - std::string strArgument; + std::string strArgument; double rDbleArgument; /* check if server or client application shall be started */ @@ -47,96 +47,96 @@ int main ( int argc, char** argv ) bool bUseGUI = true; bool bForceLowUploadRate = false; quint16 iPortNumber = LLCON_PORT_NUMBER; - std::string strIniFileName = ""; + std::string strIniFileName = ""; std::string strHTMLStatusFileName = ""; std::string strServerName = ""; std::string strLoggingFileName = ""; - /* QT docu: argv()[0] is the program name, argv()[1] is the first - argument and argv()[argc()-1] is the last argument. - Start with first argument, therefore "i = 1" */ - for ( int i = 1; i < argc; i++ ) - { - // server mode flag ---------------------------------------------------------- - if ( GetFlagArgument ( argc, argv, i, "-s", "--server" ) ) - { - bIsClient = false; + /* QT docu: argv()[0] is the program name, argv()[1] is the first + argument and argv()[argc()-1] is the last argument. + Start with first argument, therefore "i = 1" */ + for ( int i = 1; i < argc; i++ ) + { + // server mode flag ---------------------------------------------------------- + if ( GetFlagArgument ( argc, argv, i, "-s", "--server" ) ) + { + bIsClient = false; cerr << "server mode chosen" << std::endl; - continue; - } + continue; + } - // use GUI flag -------------------------------------------------------------- - if ( GetFlagArgument ( argc, argv, i, "-n", "--nogui" ) ) - { - bUseGUI = false; + // use GUI flag -------------------------------------------------------------- + if ( GetFlagArgument ( argc, argv, i, "-n", "--nogui" ) ) + { + bUseGUI = false; cerr << "no GUI mode chosen" << std::endl; - continue; - } + continue; + } - // use logging --------------------------------------------------------------- - if ( GetStringArgument ( argc, argv, i, "-l", "--log", strArgument ) ) - { - strLoggingFileName = strArgument; + // use logging --------------------------------------------------------------- + if ( GetStringArgument ( argc, argv, i, "-l", "--log", strArgument ) ) + { + strLoggingFileName = strArgument; 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" ) ) { - bForceLowUploadRate = true; + bForceLowUploadRate = true; cerr << "force low upload rate" << std::endl; - continue; + continue; } // port number --------------------------------------------------------------- - if ( GetNumericArgument ( argc, argv, i, "-p", "--port", + if ( GetNumericArgument ( argc, argv, i, "-p", "--port", 0, 65535, rDbleArgument ) ) - { - iPortNumber = static_cast ( rDbleArgument ); + { + iPortNumber = static_cast ( rDbleArgument ); cerr << "selected port number: " << iPortNumber << std::endl; - continue; - } + continue; + } - // HTML status file ---------------------------------------------------------- - if ( GetStringArgument ( argc, argv, i, "-m", "--htmlstatus", strArgument ) ) - { - strHTMLStatusFileName = strArgument; + // HTML status file ---------------------------------------------------------- + if ( GetStringArgument ( argc, argv, i, "-m", "--htmlstatus", strArgument ) ) + { + strHTMLStatusFileName = strArgument; cerr << "HTML status file name: " << strHTMLStatusFileName << std::endl; - continue; - } + continue; + } - if ( GetStringArgument ( argc, argv, i, "-a", "--servername", strArgument ) ) - { - strServerName = strArgument; + if ( GetStringArgument ( argc, argv, i, "-a", "--servername", strArgument ) ) + { + strServerName = strArgument; cerr << "server name for HTML status file: " << strServerName << std::endl; - continue; - } + continue; + } - // initialization file ------------------------------------------------------- - if ( GetStringArgument ( argc, argv, i, "-i", "--inifile", strArgument ) ) - { - strIniFileName = strArgument; + // initialization file ------------------------------------------------------- + if ( GetStringArgument ( argc, argv, i, "-i", "--inifile", strArgument ) ) + { + strIniFileName = strArgument; cerr << "initialization file name: " << strIniFileName << std::endl; - continue; - } + continue; + } - // help (usage) flag --------------------------------------------------------- - if ( ( !strcmp ( argv[i], "--help" ) ) || - ( !strcmp ( argv[i], "-h" ) ) || ( !strcmp ( argv[i], "-?" ) ) ) - { + // help (usage) flag --------------------------------------------------------- + if ( ( !strcmp ( argv[i], "--help" ) ) || + ( !strcmp ( argv[i], "-h" ) ) || ( !strcmp ( argv[i], "-?" ) ) ) + { const std::string strHelp = UsageArguments(argv); cerr << strHelp; - exit ( 1 ); - } + exit ( 1 ); + } - // unknown option ------------------------------------------------------------ - cerr << argv[0] << ": "; - cerr << "Unknown option '" << argv[i] << "' -- use '--help' for help" - << endl; + // unknown option ------------------------------------------------------------ + cerr << argv[0] << ": "; + cerr << "Unknown option '" << argv[i] << "' -- use '--help' for help" + << endl; - exit ( 1 ); - } + exit ( 1 ); + } #ifdef _WIN32 // Set application priority class -> high priority @@ -240,54 +240,54 @@ int main ( int argc, char** argv ) \******************************************************************************/ std::string UsageArguments ( char **argv ) { - return - "Usage: " + std::string ( argv[0] ) + " [option] [argument]\n" - "Recognized options:\n" - " -s, --server start server\n" - " -n, --nogui disable GUI (only avaiable for server)\n" - " -l, --log enable logging, set file name\n" - " -i, --inifile initialization file name (only available for client)\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" - " -u, --lowuploadrate force low upload rate (only avaiable for server)\n" - " -h, -?, --help this help text\n" - "Example: " + std::string ( argv[0] ) + " -l -inifile myinifile.ini\n"; + return + "Usage: " + std::string ( argv[0] ) + " [option] [argument]\n" + "Recognized options:\n" + " -s, --server start server\n" + " -n, --nogui disable GUI (only avaiable for server)\n" + " -l, --log enable logging, set file name\n" + " -i, --inifile initialization file name (only available for client)\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" + " -u, --lowuploadrate force low upload rate (only avaiable for server)\n" + " -h, -?, --help this help text\n" + "Example: " + std::string ( argv[0] ) + " -l -inifile myinifile.ini\n"; } bool GetFlagArgument ( int, char **argv, int &i, std::string strShortOpt, std::string strLongOpt ) { - if ( ( !strShortOpt.compare ( argv[i] ) ) || ( !strLongOpt.compare ( argv[i] ) ) ) - { - return true; - } - else - { - return false; - } + if ( ( !strShortOpt.compare ( argv[i] ) ) || ( !strLongOpt.compare ( argv[i] ) ) ) + { + return true; + } + else + { + return false; + } } bool GetStringArgument ( int argc, char **argv, int &i, std::string strShortOpt, std::string strLongOpt, std::string & strArg ) { - if ( ( !strShortOpt.compare ( argv[i] ) ) || ( !strLongOpt.compare ( argv[i] ) ) ) - { - if ( ++i >= argc ) - { - cerr << argv[0] << ": "; - cerr << "'" << strLongOpt << "' needs a string argument" << endl; - exit ( 1 ); - } + if ( ( !strShortOpt.compare ( argv[i] ) ) || ( !strLongOpt.compare ( argv[i] ) ) ) + { + if ( ++i >= argc ) + { + cerr << argv[0] << ": "; + cerr << "'" << strLongOpt << "' needs a string argument" << endl; + exit ( 1 ); + } - strArg = argv[i]; + strArg = argv[i]; - return true; - } - else - { - return false; - } + return true; + } + else + { + return false; + } } 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 & rValue) { - if ( ( !strShortOpt.compare ( argv[i] ) ) || ( !strLongOpt.compare ( argv[i] ) ) ) - { - if ( ++i >= argc ) - { - cerr << argv[0] << ": "; - cerr << "'" << strLongOpt << "' needs a numeric argument between " - << rRangeStart << " and " << rRangeStop << endl; - exit ( 1 ); - } + if ( ( !strShortOpt.compare ( argv[i] ) ) || ( !strLongOpt.compare ( argv[i] ) ) ) + { + if ( ++i >= argc ) + { + cerr << argv[0] << ": "; + cerr << "'" << strLongOpt << "' needs a numeric argument between " + << rRangeStart << " and " << rRangeStop << endl; + exit ( 1 ); + } - char *p; - rValue = strtod ( argv[i], &p ); - if ( *p || rValue < rRangeStart || rValue > rRangeStop ) - { - cerr << argv[0] << ": "; - cerr << "'" << strLongOpt << "' needs a numeric argument between " - << rRangeStart << " and " << rRangeStop << endl; - exit ( 1 ); - } + char *p; + rValue = strtod ( argv[i], &p ); + if ( *p || rValue < rRangeStart || rValue > rRangeStop ) + { + cerr << argv[0] << ": "; + cerr << "'" << strLongOpt << "' needs a numeric argument between " + << rRangeStart << " and " << rRangeStop << endl; + exit ( 1 ); + } - return true; - } - else - { - return false; - } + return true; + } + else + { + return false; + } } diff --git a/src/multicolorled.cpp b/src/multicolorled.cpp index dadf12f7..9df203c9 100755 --- a/src/multicolorled.cpp +++ b/src/multicolorled.cpp @@ -1,5 +1,5 @@ /******************************************************************************\ - * Copyright (c) 2004-2008 + * Copyright (c) 2004-2009 * * Author(s): * Volker Fischer diff --git a/src/multicolorled.h b/src/multicolorled.h index a0566f2a..ed9bf692 100755 --- a/src/multicolorled.h +++ b/src/multicolorled.h @@ -1,5 +1,5 @@ /******************************************************************************\ - * Copyright (c) 2004-2008 + * Copyright (c) 2004-2009 * * Author(s): * Volker Fischer diff --git a/src/protocol.cpp b/src/protocol.cpp index ab9c7c8b..d88072ae 100755 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -1,5 +1,5 @@ /******************************************************************************\ - * Copyright (c) 2004-2008 + * Copyright (c) 2004-2009 * * Author(s): * Volker Fischer diff --git a/src/protocol.h b/src/protocol.h index 91906590..948ba792 100755 --- a/src/protocol.h +++ b/src/protocol.h @@ -1,5 +1,5 @@ /******************************************************************************\ - * Copyright (c) 2004-2008 + * Copyright (c) 2004-2009 * * Author(s): * Volker Fischer diff --git a/src/resample.cpp b/src/resample.cpp index 40fac8a3..2af49f9b 100755 --- a/src/resample.cpp +++ b/src/resample.cpp @@ -1,5 +1,5 @@ /******************************************************************************\ - * Copyright (c) 2004-2008 + * Copyright (c) 2004-2009 * * Author(s): * Volker Fischer diff --git a/src/resample.h b/src/resample.h index 317db96e..beb3f191 100755 --- a/src/resample.h +++ b/src/resample.h @@ -1,5 +1,5 @@ /******************************************************************************\ - * Copyright (c) 2004-2008 + * Copyright (c) 2004-2009 * * Author(s): * Volker Fischer diff --git a/src/server.cpp b/src/server.cpp index eb44ce3e..1b5a0c34 100755 --- a/src/server.cpp +++ b/src/server.cpp @@ -1,5 +1,5 @@ /******************************************************************************\ - * Copyright (c) 2004-2008 + * Copyright (c) 2004-2009 * * Author(s): * Volker Fischer diff --git a/src/server.h b/src/server.h index 98a2aadd..ee06c3ee 100755 --- a/src/server.h +++ b/src/server.h @@ -1,5 +1,5 @@ /******************************************************************************\ - * Copyright (c) 2004-2008 + * Copyright (c) 2004-2009 * * Author(s): * Volker Fischer diff --git a/src/settings.cpp b/src/settings.cpp index 8be4cbfc..616b8e8b 100755 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -1,5 +1,5 @@ /******************************************************************************\ - * Copyright (c) 2004-2008 + * Copyright (c) 2004-2009 * * Author(s): * Volker Fischer diff --git a/src/settings.h b/src/settings.h index 1529d97c..e8fde635 100755 --- a/src/settings.h +++ b/src/settings.h @@ -48,8 +48,8 @@ public: void Save ( const QString& sFileName = "" ) { WriteIniFile ( sFileName ); } protected: - void ReadIniFile ( const QString& sFileName ); - void WriteIniFile ( const QString& sFileName ); + void ReadIniFile ( const QString& sFileName ); + void WriteIniFile ( const QString& sFileName ); // init file access function for read/write void SetNumericIniSet ( QDomDocument& xmlFile, const QString& strSection, diff --git a/src/socket.cpp b/src/socket.cpp index 86b1e9e0..a23dc25e 100755 --- a/src/socket.cpp +++ b/src/socket.cpp @@ -1,5 +1,5 @@ /******************************************************************************\ - * Copyright (c) 2004-2008 + * Copyright (c) 2004-2009 * * Author(s): * Volker Fischer @@ -76,59 +76,59 @@ void CSocket::SendPacket ( const CVector& vecbySendBuf, void CSocket::OnDataReceived() { while ( SocketDevice.hasPendingDatagrams() ) - { - QHostAddress SenderAddress; - quint16 SenderPort; + { + QHostAddress SenderAddress; + quint16 SenderPort; - // read block from network interface and query address of sender - int iNumBytesRead = SocketDevice.readDatagram ( (char*) &vecbyRecBuf[0], - MAX_SIZE_BYTES_NETW_BUF, &SenderAddress, &SenderPort ); + // read block from network interface and query address of sender + int iNumBytesRead = SocketDevice.readDatagram ( (char*) &vecbyRecBuf[0], + MAX_SIZE_BYTES_NETW_BUF, &SenderAddress, &SenderPort ); - // check if an error occurred - if ( iNumBytesRead < 0 ) - { - return; - } + // check if an error occurred + if ( iNumBytesRead < 0 ) + { + return; + } - // convert address of client - const CHostAddress RecHostAddr ( SenderAddress, SenderPort ); + // convert address of client + const CHostAddress RecHostAddr ( SenderAddress, SenderPort ); if ( bIsClient ) - { - // client - // check if packet comes from the server we want to connect - if ( ! ( pChannel->GetAddress() == RecHostAddr ) ) - { - return; - } + { + // client + // check if packet comes from the server we want to connect + if ( ! ( pChannel->GetAddress() == RecHostAddr ) ) + { + return; + } - switch ( pChannel->PutData ( vecbyRecBuf, iNumBytesRead ) ) - { - case PS_AUDIO_OK: - PostWinMessage ( MS_JIT_BUF_PUT, MUL_COL_LED_GREEN ); - break; + switch ( pChannel->PutData ( vecbyRecBuf, iNumBytesRead ) ) + { + case PS_AUDIO_OK: + PostWinMessage ( MS_JIT_BUF_PUT, MUL_COL_LED_GREEN ); + break; - case PS_AUDIO_ERR: - case PS_GEN_ERROR: - PostWinMessage ( MS_JIT_BUF_PUT, MUL_COL_LED_RED ); - break; + case PS_AUDIO_ERR: + case PS_GEN_ERROR: + PostWinMessage ( MS_JIT_BUF_PUT, MUL_COL_LED_RED ); + break; - case PS_PROT_ERR: - PostWinMessage ( MS_JIT_BUF_PUT, MUL_COL_LED_YELLOW ); - break; - } - } - else - { - // server - if ( pChannelSet->PutData ( vecbyRecBuf, iNumBytesRead, RecHostAddr ) ) - { - // this was an audio packet, start server - // tell the server object to wake up if it - // is in sleep mode (Qt will delete the event object when done) - QCoreApplication::postEvent ( pServer, - new CLlconEvent ( MS_PACKET_RECEIVED, 0, 0 ) ); - } - } - } + case PS_PROT_ERR: + PostWinMessage ( MS_JIT_BUF_PUT, MUL_COL_LED_YELLOW ); + break; + } + } + else + { + // server + if ( pChannelSet->PutData ( vecbyRecBuf, iNumBytesRead, RecHostAddr ) ) + { + // this was an audio packet, start server + // tell the server object to wake up if it + // is in sleep mode (Qt will delete the event object when done) + QCoreApplication::postEvent ( pServer, + new CLlconEvent ( MS_PACKET_RECEIVED, 0, 0 ) ); + } + } + } } diff --git a/src/socket.h b/src/socket.h index 902cd44c..8e21e64a 100755 --- a/src/socket.h +++ b/src/socket.h @@ -1,5 +1,5 @@ /******************************************************************************\ - * Copyright (c) 2004-2008 + * Copyright (c) 2004-2009 * * Author(s): * Volker Fischer diff --git a/src/util.cpp b/src/util.cpp index 34bc6aae..70838567 100755 --- a/src/util.cpp +++ b/src/util.cpp @@ -1,5 +1,5 @@ /******************************************************************************\ - * Copyright (c) 2004-2008 + * Copyright (c) 2004-2009 * * Author(s): * Volker Fischer diff --git a/src/util.h b/src/util.h index dcc320a9..e1f67f3c 100755 --- a/src/util.h +++ b/src/util.h @@ -1,5 +1,5 @@ /******************************************************************************\ - * Copyright (c) 2004-2008 + * Copyright (c) 2004-2009 * * Author(s): * Volker Fischer @@ -54,15 +54,15 @@ inline short Double2Short ( const double dInput ) { // lower bound if ( dInput < _MINSHORT ) - { + { return _MINSHORT; - } + } // upper bound if ( dInput > _MAXSHORT ) - { + { return _MAXSHORT; - } + } return (short) dInput; } @@ -187,9 +187,9 @@ template void CVector::Reset ( const TData tResetVal ) { // set all values to reset value for ( int i = 0; i < iVectorSize; i++ ) - { + { pData[i] = tResetVal; - } + } } @@ -234,9 +234,9 @@ template void CFIFO::Add ( const TData tNewD ) // increment index iCurIdx++; if ( iCurIdx >= this->iVectorSize ) - { + { iCurIdx = 0; - } + } } diff --git a/windows/MocQT.bat b/windows/MocQT.bat index 0e091423..37ebee90 100755 --- a/windows/MocQT.bat +++ b/windows/MocQT.bat @@ -1,5 +1,5 @@ rem/******************************************************************************\ -rem * Copyright (c) 2004-2008 +rem * Copyright (c) 2004-2009 rem * rem * Author(s): rem * Volker Fischer diff --git a/windows/sound.cpp b/windows/sound.cpp index bbc08d1a..3d2e040f 100755 --- a/windows/sound.cpp +++ b/windows/sound.cpp @@ -100,7 +100,7 @@ bool CSound::Read ( CVector& psData ) while ( iBufferPosCapture < iBufferSizeStereo ) { if ( bBlockingRec ) - { + { if ( !bCaptureBufferOverrun ) { // regular case @@ -121,11 +121,11 @@ bool CSound::Read ( CVector& psData ) return true; } } - } + } else - { + { return true; - } + } } ASIOMutex.lock(); // get mutex lock @@ -140,9 +140,9 @@ bool CSound::Read ( CVector& psData ) // copy data from sound card capture buffer in function output buffer for ( i = 0; i < iBufferSizeStereo; i++ ) - { + { psData[i] = psCaptureBuffer[i]; - } + } // move all other data in buffer const int iLenCopyRegion = iBufferPosCapture - iBufferSizeStereo; @@ -166,7 +166,7 @@ void CSound::SetInNumBuf ( int iNewNum ) { // check new parameter if ( ( iNewNum < MAX_SND_BUF_IN ) && ( iNewNum >= iMinNumSndBuf ) ) - { + { // change only if parameter is different if ( iNewNum != iNewNumSndBufIn ) { @@ -232,7 +232,7 @@ void CSound::SetOutNumBuf ( int iNewNum ) { // check new parameter if ( ( iNewNum < MAX_SND_BUF_OUT ) && ( iNewNum >= iMinNumSndBuf ) ) - { + { // change only if parameter is different if ( iNewNum != iNewNumSndBufOut ) { @@ -262,9 +262,9 @@ void CSound::SetDev ( const int iNewDev ) // set event to ensure that thread leaves the waiting function if ( m_ASIOEvent != NULL ) - { + { SetEvent ( m_ASIOEvent ); - } + } // wait for the thread to terminate Sleep ( 500 ); @@ -568,31 +568,31 @@ if ( iASIOBufferSizeMono == 256 ) // prepare input channels for ( i = 0; i < NUM_IN_OUT_CHANNELS; i++ ) { - bufferInfos[i].isInput = ASIOTrue; - bufferInfos[i].channelNum = i; - bufferInfos[i].buffers[0] = 0; + bufferInfos[i].isInput = ASIOTrue; + bufferInfos[i].channelNum = i; + bufferInfos[i].buffers[0] = 0; bufferInfos[i].buffers[1] = 0; } // prepare output channels for ( i = 0; i < NUM_IN_OUT_CHANNELS; i++ ) { - bufferInfos[NUM_IN_OUT_CHANNELS + i].isInput = ASIOFalse; - bufferInfos[NUM_IN_OUT_CHANNELS + i].channelNum = i; - bufferInfos[NUM_IN_OUT_CHANNELS + i].buffers[0] = 0; + bufferInfos[NUM_IN_OUT_CHANNELS + i].isInput = ASIOFalse; + bufferInfos[NUM_IN_OUT_CHANNELS + i].channelNum = i; + bufferInfos[NUM_IN_OUT_CHANNELS + i].buffers[0] = 0; bufferInfos[NUM_IN_OUT_CHANNELS + i].buffers[1] = 0; } // create and activate ASIO buffers (buffer size in samples) ASIOCreateBuffers ( bufferInfos, 2 /* in/out */ * NUM_IN_OUT_CHANNELS /* stereo */, - iASIOBufferSizeMono, &asioCallbacks ); + iASIOBufferSizeMono, &asioCallbacks ); // now get some buffer details for ( i = 0; i < 2 * NUM_IN_OUT_CHANNELS; i++ ) { - channelInfos[i].channel = bufferInfos[i].channelNum; - channelInfos[i].isInput = bufferInfos[i].isInput; - ASIOGetChannelInfo ( &channelInfos[i] ); + channelInfos[i].channel = bufferInfos[i].channelNum; + channelInfos[i].isInput = bufferInfos[i].isInput; + ASIOGetChannelInfo ( &channelInfos[i] ); // only 16/24/32 LSB is supported if ( ( channelInfos[i].type != ASIOSTInt16LSB ) && @@ -631,9 +631,9 @@ void CSound::InitRecordingAndPlayback() // create memory for capture buffer if ( psCaptureBuffer != NULL ) - { + { delete[] psCaptureBuffer; - } + } psCaptureBuffer = new short[iCurNumSndBufIn * iBufferSizeStereo]; // initialize write block pointer out and underrun flag @@ -642,16 +642,16 @@ void CSound::InitRecordingAndPlayback() // create memory for play buffer if ( psPlayBuffer != NULL ) - { + { delete[] psPlayBuffer; - } + } psPlayBuffer = new short[iCurNumSndBufOut * iBufferSizeStereo]; // clear new buffer for ( int i = 0; i < iCurNumSndBufOut * iBufferSizeStereo; i++ ) - { + { psPlayBuffer[i] = 0; - } + } // reset event ResetEvent ( m_ASIOEvent ); @@ -669,9 +669,9 @@ void CSound::Close() // set event to ensure that thread leaves the waiting function if ( m_ASIOEvent != NULL ) - { + { SetEvent ( m_ASIOEvent ); - } + } // wait for the thread to terminate Sleep ( 500 ); @@ -698,7 +698,7 @@ CSound::CSound ( const int iNewBufferSizeStereo ) m_ASIOEvent = NULL; // 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]; } @@ -717,11 +717,11 @@ CSound::CSound ( const int iNewBufferSizeStereo ) // init device index with illegal value to show that driver is not initialized lCurDev = -1; - // set up the asioCallback structure - asioCallbacks.bufferSwitch = &bufferSwitch; - asioCallbacks.sampleRateDidChange = &sampleRateChanged; - asioCallbacks.asioMessage = &asioMessages; - asioCallbacks.bufferSwitchTimeInfo = &bufferSwitchTimeInfo; + // set up the asioCallback structure + asioCallbacks.bufferSwitch = &bufferSwitch; + asioCallbacks.sampleRateDidChange = &sampleRateChanged; + asioCallbacks.asioMessage = &asioMessages; + asioCallbacks.bufferSwitchTimeInfo = &bufferSwitchTimeInfo; // init buffer pointer to zero psCaptureBuffer = NULL; @@ -747,19 +747,19 @@ CSound::~CSound() // delete allocated memory if ( psCaptureBuffer != NULL ) - { + { delete[] psCaptureBuffer; - } + } if ( psPlayBuffer != NULL ) - { + { delete[] psPlayBuffer; - } + } // close the handle for the event if ( m_ASIOEvent != NULL ) - { + { CloseHandle ( m_ASIOEvent ); - } + } } // ASIO callbacks ------------------------------------------------------------- @@ -767,8 +767,8 @@ ASIOTime* CSound::bufferSwitchTimeInfo ( ASIOTime *timeInfo, long index, ASIOBool processNow ) { - bufferSwitch ( index, processNow ); - return 0L; + bufferSwitch ( index, processNow ); + return 0L; } void CSound::bufferSwitch ( long index, ASIOBool processNow ) @@ -786,28 +786,28 @@ void CSound::bufferSwitch ( long index, ASIOBool processNow ) bPlayBufferUnderrun = ( 2 * iASIOBufferSizeMono > iBufferPosPlay ); // 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 ) - { + { // CAPTURE ----------------------------------------------------- // first check if space in buffer is available if ( !bCaptureBufferOverrun ) { // copy new captured block in thread transfer buffer (copy // mono data interleaved in stereo buffer) - switch ( channelInfos[i].type ) - { - case ASIOSTInt16LSB: + switch ( channelInfos[i].type ) + { + case ASIOSTInt16LSB: for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) { psCaptureBuffer[iBufferPosCapture + 2 * iCurSample + bufferInfos[i].channelNum] = ( (short*) bufferInfos[i].buffers[index] )[iCurSample]; } - break; + break; - case ASIOSTInt24LSB: + case ASIOSTInt24LSB: // not yet tested, horrible things might happen with the following code ;-) @@ -821,9 +821,9 @@ void CSound::bufferSwitch ( long index, ASIOBool processNow ) psCaptureBuffer[iBufferPosCapture + 2 * iCurSample + bufferInfos[i].channelNum] = static_cast ( iCurSam ); } - break; + break; - case ASIOSTInt32LSB: + case ASIOSTInt32LSB: for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) { // convert to 16 bit @@ -831,10 +831,10 @@ void CSound::bufferSwitch ( long index, ASIOBool processNow ) 2 * iCurSample + bufferInfos[i].channelNum] = (((int*) bufferInfos[i].buffers[index])[iCurSample] >> 16); } - break; + break; } } - } + } else { // PLAYBACK ---------------------------------------------------- @@ -842,42 +842,42 @@ void CSound::bufferSwitch ( long index, ASIOBool processNow ) { // copy data from sound card in output buffer (copy // interleaved stereo data in mono sound card buffer) - switch ( channelInfos[i].type ) - { - case ASIOSTInt16LSB: + switch ( channelInfos[i].type ) + { + case ASIOSTInt16LSB: for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) - { + { ( (short*) bufferInfos[i].buffers[index] )[iCurSample] = psPlayBuffer[2 * iCurSample + bufferInfos[i].channelNum]; } - break; + break; - case ASIOSTInt24LSB: + case ASIOSTInt24LSB: // not yet tested, horrible things might happen with the following code ;-) for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) - { + { // convert current sample in 24 bit format int iCurSam = static_cast ( psPlayBuffer[2 * iCurSample + bufferInfos[i].channelNum] ); iCurSam <<= 8; memcpy ( ( (char*) bufferInfos[i].buffers[index] ) + iCurSample * 3, &iCurSam, 3 ); } - break; + break; - case ASIOSTInt32LSB: - for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) - { + case ASIOSTInt32LSB: + for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) + { // convert to 32 bit int iCurSam = static_cast ( psPlayBuffer[2 * iCurSample + bufferInfos[i].channelNum] ); ( (int*) bufferInfos[i].buffers[index] )[iCurSample] = ( iCurSam << 16 ); } break; - } + } } } - } + } // 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 ----------------------------------- if ( bASIOPostOutput ) { - ASIOOutputReady(); + ASIOOutputReady(); } // 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 ret = 0; - switch(selector) - { - case kAsioEngineVersion: - // return the supported ASIO version of the host application - ret = 2L; - break; - } - return ret; + long ret = 0; + switch(selector) + { + case kAsioEngineVersion: + // return the supported ASIO version of the host application + ret = 2L; + break; + } + return ret; } diff --git a/windows/sound.h b/windows/sound.h index 7e9b7bb9..10f1af8c 100755 --- a/windows/sound.h +++ b/windows/sound.h @@ -92,10 +92,10 @@ protected: // audio hardware buffer info struct sHWBufferInfo { - long lMinSize; - long lMaxSize; - long lPreferredSize; - long lGranularity; + long lMinSize; + long lMaxSize; + long lPreferredSize; + long lGranularity; } HWBufferInfo; // callbacks