some more conversion buffer work

This commit is contained in:
Volker Fischer 2008-07-15 20:33:41 +00:00
parent 624da195ea
commit 33be3c0812
4 changed files with 27 additions and 6 deletions

View file

@ -188,7 +188,19 @@ void CClient::run()
#endif #endif
// init object // init object
try
{
Init(); Init();
}
catch ( CGenErr generr )
{
// TODO better error management -> should be catched in main thread
// problem: how to catch errors in a different thread...?
// quick hack solution
QMessageBox::critical ( 0, APP_NAME, generr.strError, "Quit", 0 );
exit ( 0 );
}
// runtime phase ------------------------------------------------------------ // runtime phase ------------------------------------------------------------

View file

@ -30,6 +30,7 @@
#include <qhostinfo.h> #include <qhostinfo.h>
#include <qstring.h> #include <qstring.h>
#include <qdatetime.h> #include <qdatetime.h>
#include <qmessagebox.h>
#include "global.h" #include "global.h"
#include "socket.h" #include "socket.h"
#include "resample.h" #include "resample.h"

View file

@ -133,6 +133,7 @@ typedef unsigned int _MESSAGE_IDENT;
#define MS_JIT_BUF_GET 4 #define MS_JIT_BUF_GET 4
#define MS_PACKET_RECEIVED 5 #define MS_PACKET_RECEIVED 5
#define MS_PROTOCOL 6 #define MS_PROTOCOL 6
#define MS_ERROR_IN_THREAD 7
#define MUL_COL_LED_RED 0 #define MUL_COL_LED_RED 0
#define MUL_COL_LED_YELLOW 1 #define MUL_COL_LED_YELLOW 1

View file

@ -60,15 +60,18 @@ HANDLE m_ASIOEvent;
int iInCurBlockToWrite; int iInCurBlockToWrite;
short* psSoundcardBuffer[MAX_SND_BUF_IN]; short* psSoundcardBuffer[MAX_SND_BUF_IN];
bool bBufferOverrun; bool bBufferOverrun;
short* psCaptureConvBuf;
int iCurPosCaptConvBuf;
// wave out // wave out
int iOutCurBlockToWrite; int iOutCurBlockToWrite;
short* psPlaybackBuffer[MAX_SND_BUF_OUT]; short* psPlaybackBuffer[MAX_SND_BUF_OUT];
bool bBufferUnderrun; bool bBufferUnderrun;
// ASIO buffer size conversion buffer
short* psCaptureConvBuf;
int iCurPosCaptConvBuf;
short* psPlayConvBuf; short* psPlayConvBuf;
int iCurPosPlayConvBuf; int iCurPosPlayConvBuf;
int iASIOConfBufSize;
int iCurNumSndBufIn; int iCurNumSndBufIn;
int iCurNumSndBufOut; int iCurNumSndBufOut;
@ -313,7 +316,8 @@ void CSound::InitRecordingAndPlayback ( int iNewBufferSize )
// TEST test if requested buffer size is supported by the audio hardware, if not, fire error // TEST test if requested buffer size is supported by the audio hardware, if not, fire error
if ( iASIOBufferSizeMono != iBufferSizeMono ) if ( iASIOBufferSizeMono != iBufferSizeMono )
{ {
throw CGenErr ( "Required sound card buffer size not allowed by the audio hardware." ); throw CGenErr ( QString ( "Required sound card buffer size of %1 samples "
"not supported by the audio hardware." ).arg(iBufferSizeMono) );
} }
// prepare input channels // prepare input channels
@ -397,12 +401,15 @@ if ( iASIOBufferSizeMono != iBufferSizeMono )
// create memory for ASIO buffer conversion if required // create memory for ASIO buffer conversion if required
if ( iASIOBufferSizeMono != iBufferSizeMono ) if ( iASIOBufferSizeMono != iBufferSizeMono )
{ {
// required size: two times of one stereo buffer of the larger buffer
iASIOConfBufSize = max(4 * iASIOBufferSizeMono, 2 * iBufferSizeStereo);
if ( psCaptureConvBuf != NULL ) if ( psCaptureConvBuf != NULL )
{ {
delete[] psCaptureConvBuf; delete[] psCaptureConvBuf;
} }
psCaptureConvBuf = new short[max(2 * iASIOBufferSizeMono, iBufferSizeStereo)]; psCaptureConvBuf = new short[iASIOConfBufSize];
iCurPosCaptConvBuf = 0; iCurPosCaptConvBuf = 0;
if ( psPlayConvBuf != NULL ) if ( psPlayConvBuf != NULL )
@ -410,7 +417,7 @@ if ( iASIOBufferSizeMono != iBufferSizeMono )
delete[] psPlayConvBuf; delete[] psPlayConvBuf;
} }
psPlayConvBuf = new short[max(2 * iASIOBufferSizeMono, iBufferSizeStereo)]; psPlayConvBuf = new short[iASIOConfBufSize];
iCurPosPlayConvBuf = 0; iCurPosPlayConvBuf = 0;
} }