bug fix, finished ASIO implementation

This commit is contained in:
Volker Fischer 2008-07-17 18:39:24 +00:00
parent 2516cf62f9
commit d8d34e6c5a
3 changed files with 26 additions and 18 deletions

View File

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

View File

@ -95,11 +95,31 @@ bool CSound::Read ( CVector<short>& 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<short>& 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++ )
{

View File

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