diff --git a/src/global.h b/src/global.h index 57d10f2e..ccf1fced 100755 --- a/src/global.h +++ b/src/global.h @@ -79,7 +79,7 @@ #define DEF_NET_BUF_SIZE_NUM_BL 5 // number of blocks // number of ticks of audio in/out buffer sliders -# define AUD_SLIDER_LENGTH 6 +# define AUD_SLIDER_LENGTH 8 // maximum number of internet connections (channels) // if you want to change this paramter, there has to be done code modifications diff --git a/windows/sound.cpp b/windows/sound.cpp index f93fa94d..f392594a 100755 --- a/windows/sound.cpp +++ b/windows/sound.cpp @@ -95,11 +95,31 @@ bool CSound::Read ( CVector& psData ) } // wait until enough data is available + int iWaitCount = 0; while ( iBufferPosCapture < iBufferSizeStereo ) { - if ( bBlockingRec && !bCaptureBufferOverrun ) + if ( bBlockingRec ) { - WaitForSingleObject ( m_ASIOEvent, INFINITE ); + if ( !bCaptureBufferOverrun ) + { + // regular case + WaitForSingleObject ( m_ASIOEvent, INFINITE ); + } + else + { + // it seems that the buffers are too small, wait + // just one time to avoid CPU to go up to 100% and + // then leave this function + if ( iWaitCount == 0 ) + { + WaitForSingleObject ( m_ASIOEvent, INFINITE ); + iWaitCount++; + } + else + { + return true; + } + } } else { @@ -125,7 +145,7 @@ bool CSound::Read ( CVector& psData ) // move all other data in buffer const int iLenCopyRegion = iBufferPosCapture - iBufferSizeStereo; - for ( i = 0; i < iBufferSizeStereo; i++ ) + for ( i = 0; i < iLenCopyRegion; i++ ) { psCaptureBuffer[i] = psCaptureBuffer[iBufferSizeStereo + i]; } @@ -306,18 +326,6 @@ void CSound::InitRecordingAndPlayback ( int iNewBufferSize ) } } - -// TEST test if requested buffer size is supported by the audio hardware, if not, fire error -if ( iASIOBufferSizeMono != iBufferSizeMono ) -{ - throw CGenErr ( QString ( "Required sound card buffer size of %1 samples " - "not supported by the audio hardware." ).arg(iBufferSizeMono) ); -} - -// TEST -//iASIOBufferSizeMono = 256; - - // prepare input channels for ( i = 0; i < NUM_IN_OUT_CHANNELS; i++ ) { diff --git a/windows/sound.h b/windows/sound.h index 95fadf3d..5911fe6e 100755 --- a/windows/sound.h +++ b/windows/sound.h @@ -47,8 +47,8 @@ #define MAX_SND_BUF_IN 100 #define MAX_SND_BUF_OUT 100 -#define NUM_SOUND_BUFFERS_IN 1 -#define NUM_SOUND_BUFFERS_OUT 1 +#define NUM_SOUND_BUFFERS_IN 4 +#define NUM_SOUND_BUFFERS_OUT 4 // maximum number of recognized sound cards installed in the system #define MAX_NUMBER_SOUND_CARDS 10