some fixes

This commit is contained in:
Volker Fischer 2008-01-27 10:05:15 +00:00
parent ccc664a084
commit a8ef2fabef
7 changed files with 117 additions and 116 deletions

View file

@ -211,7 +211,7 @@ void CClient::run()
// TEST // TEST
//Sleep(300); //Sleep(300);
//wait(3000);
// copy data from one stereo buffer in two separate buffers // copy data from one stereo buffer in two separate buffers
iInCnt = 0; iInCnt = 0;

View file

@ -44,8 +44,8 @@
<widget class="QLabel" name="PixmapLabelCorrados" > <widget class="QLabel" name="PixmapLabelCorrados" >
<property name="sizePolicy" > <property name="sizePolicy" >
<sizepolicy> <sizepolicy>
<hsizetype>0</hsizetype> <hsizetype>5</hsizetype>
<vsizetype>0</vsizetype> <vsizetype>5</vsizetype>
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>

View file

@ -52,7 +52,7 @@ int main ( int argc, char** argv )
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" ) == TRUE ) if ( GetFlagArgument ( argc, argv, i, "-s", "--server" ) )
{ {
bIsClient = false; bIsClient = false;
@ -62,7 +62,7 @@ cerr << "server ";
} }
/* Use GUI flag ----------------------------------------------------------- */ /* Use GUI flag ----------------------------------------------------------- */
if ( GetFlagArgument ( argc, argv, i, "-n", "--nogui" ) == TRUE ) if ( GetFlagArgument ( argc, argv, i, "-n", "--nogui" ) )
{ {
bUseGUI = false; bUseGUI = false;
@ -72,7 +72,7 @@ cerr << "nogui ";
} }
/* Use logging flag ------------------------------------------------------- */ /* Use logging flag ------------------------------------------------------- */
if ( GetFlagArgument ( argc, argv, i, "-l", "--log" ) == TRUE ) if ( GetFlagArgument ( argc, argv, i, "-l", "--log" ) )
{ {
bUseServerLogging = true; bUseServerLogging = true;
@ -82,7 +82,7 @@ cerr << "logging ";
} }
/* Initialization file ---------------------------------------------------- */ /* Initialization file ---------------------------------------------------- */
if ( GetStringArgument ( argc, argv, i, "-i", "--inifile", strArgument ) == TRUE ) if ( GetStringArgument ( argc, argv, i, "-i", "--inifile", strArgument ) )
{ {
strIniFileName = strArgument; strIniFileName = strArgument;
continue; continue;

View file

@ -188,7 +188,7 @@ bool CSettings::GetNumericIniSet ( const QDomDocument& xmlFile, const QString& s
// check range // check range
if ( ( iValue >= iRangeStart ) && ( iValue <= iRangeStop ) ) if ( ( iValue >= iRangeStart ) && ( iValue <= iRangeStop ) )
{ {
bReturn = TRUE; bReturn = true;
} }
} }

View file

@ -33,8 +33,7 @@ void CSocket::Init()
// initialize the listening socket // initialize the listening socket
bool bSuccess = SocketDevice.bind ( bool bSuccess = SocketDevice.bind (
QHostAddress ( (quint32) 0 ), // INADDR_ANY QHostAddress ( QHostAddress::Any ), LLCON_PORT_NUMBER );
LLCON_PORT_NUMBER );
if ( bIsClient ) if ( bIsClient )
{ {
@ -44,8 +43,7 @@ void CSocket::Init()
// if server and client is on same machine, decrease port number by // if server and client is on same machine, decrease port number by
// one by definition // one by definition
bSuccess = SocketDevice.bind ( bSuccess = SocketDevice.bind (
QHostAddress( (quint32) 0 ), // INADDR_ANY QHostAddress( QHostAddress::Any ), LLCON_PORT_NUMBER - 1 );
LLCON_PORT_NUMBER - 1 );
} }
} }
@ -82,6 +80,8 @@ void CSocket::SendPacket ( const CVector<unsigned char>& vecbySendBuf,
} }
void CSocket::OnDataReceived() void CSocket::OnDataReceived()
{
while ( SocketDevice.hasPendingDatagrams() )
{ {
QHostAddress SenderAddress; QHostAddress SenderAddress;
quint16 SenderPort; quint16 SenderPort;
@ -137,3 +137,4 @@ void CSocket::OnDataReceived()
} }
} }
} }
}

View file

@ -45,13 +45,13 @@ bool CSound::Read ( CVector<short>& psData )
bool bError = false; bool bError = false;
// check if device must be opened or reinitialized // check if device must be opened or reinitialized
if ( bChangParamIn == TRUE ) if ( bChangParamIn )
{ {
// Reinit sound interface // Reinit sound interface
InitRecordingAndPlayback ( iBufferSize ); InitRecordingAndPlayback ( iBufferSize );
// Reset flag // Reset flag
bChangParamIn = FALSE; bChangParamIn = false;
} }
@ -59,13 +59,13 @@ bool CSound::Read ( CVector<short>& psData )
// wait until data is available // wait until data is available
if ( ! ( m_WaveInHeader[iWhichBufferIn].dwFlags & WHDR_DONE ) ) if ( ! ( m_WaveInHeader[iWhichBufferIn].dwFlags & WHDR_DONE ) )
{ {
if ( bBlockingRec == TRUE ) if ( bBlockingRec )
{ {
WaitForSingleObject ( m_WaveInEvent, INFINITE ); WaitForSingleObject ( m_WaveInEvent, INFINITE );
} }
else else
{ {
return FALSE; return false;
} }
} }
*/ */
@ -87,11 +87,11 @@ bool CSound::Read ( CVector<short>& psData )
// very likely that a buffer got lost -> set error flag // very likely that a buffer got lost -> set error flag
if ( iNumInBufDone == iCurNumSndBufIn ) if ( iNumInBufDone == iCurNumSndBufIn )
{ {
bError = TRUE; bError = true;
} }
else else
{ {
bError = FALSE; bError = false;
} }
*/ */
@ -160,7 +160,7 @@ void CSound::SetInNumBuf ( int iNewNum )
if ( iNewNum != iCurNumSndBufIn ) if ( iNewNum != iCurNumSndBufIn )
{ {
iCurNumSndBufIn = iNewNum; iCurNumSndBufIn = iNewNum;
bChangParamIn = TRUE; bChangParamIn = true;
} }
} }
@ -176,13 +176,13 @@ bool CSound::Write ( CVector<short>& psData )
bool bError; bool bError;
// check if device must be opened or reinitialized // check if device must be opened or reinitialized
if ( bChangParamOut == TRUE ) if ( bChangParamOut )
{ {
// reinit sound interface // reinit sound interface
InitRecordingAndPlayback ( iBufferSize ); InitRecordingAndPlayback ( iBufferSize );
// reset flag // reset flag
bChangParamOut = FALSE; bChangParamOut = false;
} }
/* /*
@ -225,11 +225,11 @@ bool CSound::Write ( CVector<short>& psData )
// set index for done buffer // set index for done buffer
iIndexDoneBuf = iCurNumSndBufOut / 2; iIndexDoneBuf = iCurNumSndBufOut / 2;
bError = TRUE; bError = true;
} }
else else
{ {
bError = FALSE; bError = false;
} }
} }
*/ */
@ -312,7 +312,7 @@ void CSound::SetOutNumBuf ( int iNewNum )
if ( iNewNum != iCurNumSndBufOut ) if ( iNewNum != iCurNumSndBufOut )
{ {
iCurNumSndBufOut = iNewNum; iCurNumSndBufOut = iNewNum;
bChangParamOut = TRUE; bChangParamOut = true;
} }
} }
@ -452,8 +452,8 @@ void CSound::Close()
Sleep ( 500 ); Sleep ( 500 );
// set flag to open devices the next time it is initialized // set flag to open devices the next time it is initialized
bChangParamIn = TRUE; bChangParamIn = true;
bChangParamOut = TRUE; bChangParamOut = true;
} }
CSound::CSound() CSound::CSound()
@ -589,8 +589,8 @@ pstrDevices[0] = driverInfo.name;
m_WaveOutEvent = CreateEvent ( NULL, FALSE, FALSE, NULL ); m_WaveOutEvent = CreateEvent ( NULL, FALSE, FALSE, NULL );
// set flag to open devices // set flag to open devices
bChangParamIn = TRUE; bChangParamIn = true;
bChangParamOut = TRUE; bChangParamOut = true;
} }
CSound::~CSound() CSound::~CSound()
@ -783,7 +783,7 @@ bool CSound::Read ( CVector<short>& psData )
bool bError; bool bError;
// check if device must be opened or reinitialized // check if device must be opened or reinitialized
if ( bChangParamIn == TRUE ) if ( bChangParamIn )
{ {
OpenInDevice(); OpenInDevice();
@ -791,19 +791,19 @@ bool CSound::Read ( CVector<short>& psData )
InitRecording ( iBufferSizeIn, bBlockingRec ); InitRecording ( iBufferSizeIn, bBlockingRec );
// Reset flag // Reset flag
bChangParamIn = FALSE; bChangParamIn = false;
} }
// wait until data is available // wait until data is available
if ( ! ( m_WaveInHeader[iWhichBufferIn].dwFlags & WHDR_DONE ) ) if ( ! ( m_WaveInHeader[iWhichBufferIn].dwFlags & WHDR_DONE ) )
{ {
if ( bBlockingRec == TRUE ) if ( bBlockingRec )
{ {
WaitForSingleObject ( m_WaveInEvent, INFINITE ); WaitForSingleObject ( m_WaveInEvent, INFINITE );
} }
else else
{ {
return FALSE; return false;
} }
} }
@ -821,11 +821,11 @@ bool CSound::Read ( CVector<short>& psData )
very likely that a buffer got lost -> set error flag */ very likely that a buffer got lost -> set error flag */
if ( iNumInBufDone == iCurNumSndBufIn ) if ( iNumInBufDone == iCurNumSndBufIn )
{ {
bError = TRUE; bError = true;
} }
else else
{ {
bError = FALSE; bError = false;
} }
// copy data from sound card in output buffer // copy data from sound card in output buffer
@ -877,12 +877,12 @@ void CSound::PrepareInBuffer ( int iBufNum )
void CSound::InitRecording ( int iNewBufferSize, bool bNewBlocking ) void CSound::InitRecording ( int iNewBufferSize, bool bNewBlocking )
{ {
// check if device must be opened or reinitialized // check if device must be opened or reinitialized
if ( bChangParamIn == TRUE ) if ( bChangParamIn )
{ {
OpenInDevice(); OpenInDevice();
// reset flag // reset flag
bChangParamIn = FALSE; bChangParamIn = false;
} }
// set internal parameter // set internal parameter
@ -960,7 +960,7 @@ void CSound::SetInDev ( int iNewDev )
if ( iNewDev != iCurInDev ) if ( iNewDev != iCurInDev )
{ {
iCurInDev = iNewDev; iCurInDev = iNewDev;
bChangParamIn = TRUE; bChangParamIn = true;
} }
} }
@ -976,7 +976,7 @@ void CSound::SetInNumBuf ( int iNewNum )
if ( iNewNum != iCurNumSndBufIn ) if ( iNewNum != iCurNumSndBufIn )
{ {
iCurNumSndBufIn = iNewNum; iCurNumSndBufIn = iNewNum;
bChangParamIn = TRUE; bChangParamIn = true;
} }
} }
@ -992,7 +992,7 @@ bool CSound::Write ( CVector<short>& psData )
bool bError; bool bError;
// check if device must be opened or reinitialized // check if device must be opened or reinitialized
if ( bChangParamOut == TRUE ) if ( bChangParamOut )
{ {
OpenOutDevice(); OpenOutDevice();
@ -1000,7 +1000,7 @@ bool CSound::Write ( CVector<short>& psData )
InitPlayback ( iBufferSizeOut, bBlockingPlay ); InitPlayback ( iBufferSizeOut, bBlockingPlay );
// reset flag // reset flag
bChangParamOut = FALSE; bChangParamOut = false;
} }
// get number of "done"-buffers and position of one of them // get number of "done"-buffers and position of one of them
@ -1009,9 +1009,9 @@ bool CSound::Write ( CVector<short>& psData )
// now check special cases (Buffer is full or empty) // now check special cases (Buffer is full or empty)
if ( iCntPrepBuf == 0 ) if ( iCntPrepBuf == 0 )
{ {
if ( bBlockingPlay == TRUE ) if ( bBlockingPlay )
{ {
/* Blocking wave out routine. Needed for transmitter. Always /* Blocking wave out routine. Always
ensure that the buffer is completely filled to avoid buffer ensure that the buffer is completely filled to avoid buffer
underruns */ underruns */
while ( iCntPrepBuf == 0 ) while ( iCntPrepBuf == 0 )
@ -1026,7 +1026,7 @@ bool CSound::Write ( CVector<short>& psData )
// All buffers are filled, dump new block -------------------------- // All buffers are filled, dump new block --------------------------
// It would be better to kill half of the buffer blocks to set the start // It would be better to kill half of the buffer blocks to set the start
// back to the middle: TODO // back to the middle: TODO
return TRUE; // an error occurred return true; // an error occurred
} }
} }
else else
@ -1052,11 +1052,11 @@ bool CSound::Write ( CVector<short>& psData )
// set index for done buffer // set index for done buffer
iIndexDoneBuf = iCurNumSndBufOut / 2; iIndexDoneBuf = iCurNumSndBufOut / 2;
bError = TRUE; bError = true;
} }
else else
{ {
bError = FALSE; bError = false;
} }
} }
@ -1115,12 +1115,12 @@ void CSound::InitPlayback ( int iNewBufferSize, bool bNewBlocking )
int i, j; int i, j;
// check if device must be opened or reinitialized // check if device must be opened or reinitialized
if ( bChangParamOut == TRUE ) if ( bChangParamOut )
{ {
OpenOutDevice(); OpenOutDevice();
// reset flag // reset flag
bChangParamOut = FALSE; bChangParamOut = false;
} }
// set internal parameters // set internal parameters
@ -1187,7 +1187,7 @@ void CSound::SetOutDev ( int iNewDev )
if ( iNewDev != iCurOutDev ) if ( iNewDev != iCurOutDev )
{ {
iCurOutDev = iNewDev; iCurOutDev = iNewDev;
bChangParamOut = TRUE; bChangParamOut = true;
} }
} }
@ -1203,7 +1203,7 @@ void CSound::SetOutNumBuf ( int iNewNum )
if ( iNewNum != iCurNumSndBufOut ) if ( iNewNum != iCurNumSndBufOut )
{ {
iCurNumSndBufOut = iNewNum; iCurNumSndBufOut = iNewNum;
bChangParamOut = TRUE; bChangParamOut = true;
} }
} }
@ -1292,8 +1292,8 @@ void CSound::Close()
} }
// set flag to open devices the next time it is initialized // set flag to open devices the next time it is initialized
bChangParamIn = TRUE; bChangParamIn = true;
bChangParamOut = TRUE; bChangParamOut = true;
} }
CSound::CSound() CSound::CSound()
@ -1363,18 +1363,18 @@ CSound::CSound()
m_WaveOutEvent = CreateEvent ( NULL, FALSE, FALSE, NULL ); m_WaveOutEvent = CreateEvent ( NULL, FALSE, FALSE, NULL );
// set flag to open devices // set flag to open devices
bChangParamIn = TRUE; bChangParamIn = true;
bChangParamOut = TRUE; bChangParamOut = true;
// default device number, "wave mapper" // default device number, "wave mapper"
iCurInDev = WAVE_MAPPER; iCurInDev = WAVE_MAPPER;
iCurOutDev = WAVE_MAPPER; iCurOutDev = WAVE_MAPPER;
// non-blocking wave out is default // non-blocking wave out is default
bBlockingPlay = FALSE; bBlockingPlay = false;
// blocking wave in is default // blocking wave in is default
bBlockingRec = TRUE; bBlockingRec = true;
} }
CSound::~CSound() CSound::~CSound()

View file

@ -71,8 +71,8 @@ public:
CSound(); CSound();
virtual ~CSound(); virtual ~CSound();
void InitRecording ( int iNewBufferSize, bool bNewBlocking = TRUE ) { InitRecordingAndPlayback ( iNewBufferSize ); } void InitRecording ( int iNewBufferSize, bool bNewBlocking = true ) { InitRecordingAndPlayback ( iNewBufferSize ); }
void InitPlayback ( int iNewBufferSize, bool bNewBlocking = FALSE ) { InitRecordingAndPlayback ( iNewBufferSize ); } void InitPlayback ( int iNewBufferSize, bool bNewBlocking = false ) { InitRecordingAndPlayback ( iNewBufferSize ); }
bool Read ( CVector<short>& psData ); bool Read ( CVector<short>& psData );
bool Write ( CVector<short>& psData ); bool Write ( CVector<short>& psData );
@ -137,8 +137,8 @@ public:
CSound(); CSound();
virtual ~CSound(); virtual ~CSound();
void InitRecording ( int iNewBufferSize, bool bNewBlocking = TRUE ); void InitRecording ( int iNewBufferSize, bool bNewBlocking = true );
void InitPlayback ( int iNewBufferSize, bool bNewBlocking = FALSE ); void InitPlayback ( int iNewBufferSize, bool bNewBlocking = false );
bool Read ( CVector<short>& psData ); bool Read ( CVector<short>& psData );
bool Write ( CVector<short>& psData ); bool Write ( CVector<short>& psData );