some fixes
This commit is contained in:
parent
ccc664a084
commit
a8ef2fabef
7 changed files with 117 additions and 116 deletions
|
@ -211,7 +211,7 @@ void CClient::run()
|
|||
|
||||
// TEST
|
||||
//Sleep(300);
|
||||
|
||||
//wait(3000);
|
||||
|
||||
// copy data from one stereo buffer in two separate buffers
|
||||
iInCnt = 0;
|
||||
|
|
|
@ -44,8 +44,8 @@
|
|||
<widget class="QLabel" name="PixmapLabelCorrados" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy>
|
||||
<hsizetype>0</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<hsizetype>5</hsizetype>
|
||||
<vsizetype>5</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
|
|
|
@ -52,7 +52,7 @@ int main ( int argc, char** argv )
|
|||
for ( int i = 1; i < argc; i++ )
|
||||
{
|
||||
/* Server mode flag ------------------------------------------------------- */
|
||||
if ( GetFlagArgument ( argc, argv, i, "-s", "--server" ) == TRUE )
|
||||
if ( GetFlagArgument ( argc, argv, i, "-s", "--server" ) )
|
||||
{
|
||||
bIsClient = false;
|
||||
|
||||
|
@ -62,7 +62,7 @@ cerr << "server ";
|
|||
}
|
||||
|
||||
/* Use GUI flag ----------------------------------------------------------- */
|
||||
if ( GetFlagArgument ( argc, argv, i, "-n", "--nogui" ) == TRUE )
|
||||
if ( GetFlagArgument ( argc, argv, i, "-n", "--nogui" ) )
|
||||
{
|
||||
bUseGUI = false;
|
||||
|
||||
|
@ -72,7 +72,7 @@ cerr << "nogui ";
|
|||
}
|
||||
|
||||
/* Use logging flag ------------------------------------------------------- */
|
||||
if ( GetFlagArgument ( argc, argv, i, "-l", "--log" ) == TRUE )
|
||||
if ( GetFlagArgument ( argc, argv, i, "-l", "--log" ) )
|
||||
{
|
||||
bUseServerLogging = true;
|
||||
|
||||
|
@ -82,7 +82,7 @@ cerr << "logging ";
|
|||
}
|
||||
|
||||
/* Initialization file ---------------------------------------------------- */
|
||||
if ( GetStringArgument ( argc, argv, i, "-i", "--inifile", strArgument ) == TRUE )
|
||||
if ( GetStringArgument ( argc, argv, i, "-i", "--inifile", strArgument ) )
|
||||
{
|
||||
strIniFileName = strArgument;
|
||||
continue;
|
||||
|
|
|
@ -188,7 +188,7 @@ bool CSettings::GetNumericIniSet ( const QDomDocument& xmlFile, const QString& s
|
|||
// check range
|
||||
if ( ( iValue >= iRangeStart ) && ( iValue <= iRangeStop ) )
|
||||
{
|
||||
bReturn = TRUE;
|
||||
bReturn = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,8 +33,7 @@ void CSocket::Init()
|
|||
|
||||
// initialize the listening socket
|
||||
bool bSuccess = SocketDevice.bind (
|
||||
QHostAddress ( (quint32) 0 ), // INADDR_ANY
|
||||
LLCON_PORT_NUMBER );
|
||||
QHostAddress ( QHostAddress::Any ), LLCON_PORT_NUMBER );
|
||||
|
||||
if ( bIsClient )
|
||||
{
|
||||
|
@ -44,8 +43,7 @@ void CSocket::Init()
|
|||
// if server and client is on same machine, decrease port number by
|
||||
// one by definition
|
||||
bSuccess = SocketDevice.bind (
|
||||
QHostAddress( (quint32) 0 ), // INADDR_ANY
|
||||
LLCON_PORT_NUMBER - 1 );
|
||||
QHostAddress( QHostAddress::Any ), LLCON_PORT_NUMBER - 1 );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,6 +80,8 @@ void CSocket::SendPacket ( const CVector<unsigned char>& vecbySendBuf,
|
|||
}
|
||||
|
||||
void CSocket::OnDataReceived()
|
||||
{
|
||||
while ( SocketDevice.hasPendingDatagrams() )
|
||||
{
|
||||
QHostAddress SenderAddress;
|
||||
quint16 SenderPort;
|
||||
|
@ -137,3 +137,4 @@ void CSocket::OnDataReceived()
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,13 +45,13 @@ bool CSound::Read ( CVector<short>& psData )
|
|||
bool bError = false;
|
||||
|
||||
// check if device must be opened or reinitialized
|
||||
if ( bChangParamIn == TRUE )
|
||||
if ( bChangParamIn )
|
||||
{
|
||||
// Reinit sound interface
|
||||
InitRecordingAndPlayback ( iBufferSize );
|
||||
|
||||
// Reset flag
|
||||
bChangParamIn = FALSE;
|
||||
bChangParamIn = false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -59,13 +59,13 @@ bool CSound::Read ( CVector<short>& psData )
|
|||
// wait until data is available
|
||||
if ( ! ( m_WaveInHeader[iWhichBufferIn].dwFlags & WHDR_DONE ) )
|
||||
{
|
||||
if ( bBlockingRec == TRUE )
|
||||
if ( bBlockingRec )
|
||||
{
|
||||
WaitForSingleObject ( m_WaveInEvent, INFINITE );
|
||||
}
|
||||
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
|
||||
if ( iNumInBufDone == iCurNumSndBufIn )
|
||||
{
|
||||
bError = TRUE;
|
||||
bError = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
bError = FALSE;
|
||||
bError = false;
|
||||
}
|
||||
*/
|
||||
|
||||
|
@ -160,7 +160,7 @@ void CSound::SetInNumBuf ( int iNewNum )
|
|||
if ( iNewNum != iCurNumSndBufIn )
|
||||
{
|
||||
iCurNumSndBufIn = iNewNum;
|
||||
bChangParamIn = TRUE;
|
||||
bChangParamIn = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -176,13 +176,13 @@ bool CSound::Write ( CVector<short>& psData )
|
|||
bool bError;
|
||||
|
||||
// check if device must be opened or reinitialized
|
||||
if ( bChangParamOut == TRUE )
|
||||
if ( bChangParamOut )
|
||||
{
|
||||
// reinit sound interface
|
||||
InitRecordingAndPlayback ( iBufferSize );
|
||||
|
||||
// reset flag
|
||||
bChangParamOut = FALSE;
|
||||
bChangParamOut = false;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -225,11 +225,11 @@ bool CSound::Write ( CVector<short>& psData )
|
|||
// set index for done buffer
|
||||
iIndexDoneBuf = iCurNumSndBufOut / 2;
|
||||
|
||||
bError = TRUE;
|
||||
bError = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
bError = FALSE;
|
||||
bError = false;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
@ -312,7 +312,7 @@ void CSound::SetOutNumBuf ( int iNewNum )
|
|||
if ( iNewNum != iCurNumSndBufOut )
|
||||
{
|
||||
iCurNumSndBufOut = iNewNum;
|
||||
bChangParamOut = TRUE;
|
||||
bChangParamOut = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -452,8 +452,8 @@ void CSound::Close()
|
|||
Sleep ( 500 );
|
||||
|
||||
// set flag to open devices the next time it is initialized
|
||||
bChangParamIn = TRUE;
|
||||
bChangParamOut = TRUE;
|
||||
bChangParamIn = true;
|
||||
bChangParamOut = true;
|
||||
}
|
||||
|
||||
CSound::CSound()
|
||||
|
@ -589,8 +589,8 @@ pstrDevices[0] = driverInfo.name;
|
|||
m_WaveOutEvent = CreateEvent ( NULL, FALSE, FALSE, NULL );
|
||||
|
||||
// set flag to open devices
|
||||
bChangParamIn = TRUE;
|
||||
bChangParamOut = TRUE;
|
||||
bChangParamIn = true;
|
||||
bChangParamOut = true;
|
||||
}
|
||||
|
||||
CSound::~CSound()
|
||||
|
@ -783,7 +783,7 @@ bool CSound::Read ( CVector<short>& psData )
|
|||
bool bError;
|
||||
|
||||
// check if device must be opened or reinitialized
|
||||
if ( bChangParamIn == TRUE )
|
||||
if ( bChangParamIn )
|
||||
{
|
||||
OpenInDevice();
|
||||
|
||||
|
@ -791,19 +791,19 @@ bool CSound::Read ( CVector<short>& psData )
|
|||
InitRecording ( iBufferSizeIn, bBlockingRec );
|
||||
|
||||
// Reset flag
|
||||
bChangParamIn = FALSE;
|
||||
bChangParamIn = false;
|
||||
}
|
||||
|
||||
// wait until data is available
|
||||
if ( ! ( m_WaveInHeader[iWhichBufferIn].dwFlags & WHDR_DONE ) )
|
||||
{
|
||||
if ( bBlockingRec == TRUE )
|
||||
if ( bBlockingRec )
|
||||
{
|
||||
WaitForSingleObject ( m_WaveInEvent, INFINITE );
|
||||
}
|
||||
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 */
|
||||
if ( iNumInBufDone == iCurNumSndBufIn )
|
||||
{
|
||||
bError = TRUE;
|
||||
bError = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
bError = FALSE;
|
||||
bError = false;
|
||||
}
|
||||
|
||||
// copy data from sound card in output buffer
|
||||
|
@ -877,12 +877,12 @@ void CSound::PrepareInBuffer ( int iBufNum )
|
|||
void CSound::InitRecording ( int iNewBufferSize, bool bNewBlocking )
|
||||
{
|
||||
// check if device must be opened or reinitialized
|
||||
if ( bChangParamIn == TRUE )
|
||||
if ( bChangParamIn )
|
||||
{
|
||||
OpenInDevice();
|
||||
|
||||
// reset flag
|
||||
bChangParamIn = FALSE;
|
||||
bChangParamIn = false;
|
||||
}
|
||||
|
||||
// set internal parameter
|
||||
|
@ -960,7 +960,7 @@ void CSound::SetInDev ( int iNewDev )
|
|||
if ( iNewDev != iCurInDev )
|
||||
{
|
||||
iCurInDev = iNewDev;
|
||||
bChangParamIn = TRUE;
|
||||
bChangParamIn = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -976,7 +976,7 @@ void CSound::SetInNumBuf ( int iNewNum )
|
|||
if ( iNewNum != iCurNumSndBufIn )
|
||||
{
|
||||
iCurNumSndBufIn = iNewNum;
|
||||
bChangParamIn = TRUE;
|
||||
bChangParamIn = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -992,7 +992,7 @@ bool CSound::Write ( CVector<short>& psData )
|
|||
bool bError;
|
||||
|
||||
// check if device must be opened or reinitialized
|
||||
if ( bChangParamOut == TRUE )
|
||||
if ( bChangParamOut )
|
||||
{
|
||||
OpenOutDevice();
|
||||
|
||||
|
@ -1000,7 +1000,7 @@ bool CSound::Write ( CVector<short>& psData )
|
|||
InitPlayback ( iBufferSizeOut, bBlockingPlay );
|
||||
|
||||
// reset flag
|
||||
bChangParamOut = FALSE;
|
||||
bChangParamOut = false;
|
||||
}
|
||||
|
||||
// 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)
|
||||
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
|
||||
underruns */
|
||||
while ( iCntPrepBuf == 0 )
|
||||
|
@ -1026,7 +1026,7 @@ bool CSound::Write ( CVector<short>& psData )
|
|||
// All buffers are filled, dump new block --------------------------
|
||||
// It would be better to kill half of the buffer blocks to set the start
|
||||
// back to the middle: TODO
|
||||
return TRUE; // an error occurred
|
||||
return true; // an error occurred
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1052,11 +1052,11 @@ bool CSound::Write ( CVector<short>& psData )
|
|||
// set index for done buffer
|
||||
iIndexDoneBuf = iCurNumSndBufOut / 2;
|
||||
|
||||
bError = TRUE;
|
||||
bError = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
bError = FALSE;
|
||||
bError = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1115,12 +1115,12 @@ void CSound::InitPlayback ( int iNewBufferSize, bool bNewBlocking )
|
|||
int i, j;
|
||||
|
||||
// check if device must be opened or reinitialized
|
||||
if ( bChangParamOut == TRUE )
|
||||
if ( bChangParamOut )
|
||||
{
|
||||
OpenOutDevice();
|
||||
|
||||
// reset flag
|
||||
bChangParamOut = FALSE;
|
||||
bChangParamOut = false;
|
||||
}
|
||||
|
||||
// set internal parameters
|
||||
|
@ -1187,7 +1187,7 @@ void CSound::SetOutDev ( int iNewDev )
|
|||
if ( iNewDev != iCurOutDev )
|
||||
{
|
||||
iCurOutDev = iNewDev;
|
||||
bChangParamOut = TRUE;
|
||||
bChangParamOut = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1203,7 +1203,7 @@ void CSound::SetOutNumBuf ( int iNewNum )
|
|||
if ( iNewNum != iCurNumSndBufOut )
|
||||
{
|
||||
iCurNumSndBufOut = iNewNum;
|
||||
bChangParamOut = TRUE;
|
||||
bChangParamOut = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1292,8 +1292,8 @@ void CSound::Close()
|
|||
}
|
||||
|
||||
// set flag to open devices the next time it is initialized
|
||||
bChangParamIn = TRUE;
|
||||
bChangParamOut = TRUE;
|
||||
bChangParamIn = true;
|
||||
bChangParamOut = true;
|
||||
}
|
||||
|
||||
CSound::CSound()
|
||||
|
@ -1363,18 +1363,18 @@ CSound::CSound()
|
|||
m_WaveOutEvent = CreateEvent ( NULL, FALSE, FALSE, NULL );
|
||||
|
||||
// set flag to open devices
|
||||
bChangParamIn = TRUE;
|
||||
bChangParamOut = TRUE;
|
||||
bChangParamIn = true;
|
||||
bChangParamOut = true;
|
||||
|
||||
// default device number, "wave mapper"
|
||||
iCurInDev = WAVE_MAPPER;
|
||||
iCurOutDev = WAVE_MAPPER;
|
||||
|
||||
// non-blocking wave out is default
|
||||
bBlockingPlay = FALSE;
|
||||
bBlockingPlay = false;
|
||||
|
||||
// blocking wave in is default
|
||||
bBlockingRec = TRUE;
|
||||
bBlockingRec = true;
|
||||
}
|
||||
|
||||
CSound::~CSound()
|
||||
|
|
|
@ -71,8 +71,8 @@ public:
|
|||
CSound();
|
||||
virtual ~CSound();
|
||||
|
||||
void InitRecording ( int iNewBufferSize, bool bNewBlocking = TRUE ) { InitRecordingAndPlayback ( iNewBufferSize ); }
|
||||
void InitPlayback ( int iNewBufferSize, bool bNewBlocking = FALSE ) { InitRecordingAndPlayback ( iNewBufferSize ); }
|
||||
void InitRecording ( int iNewBufferSize, bool bNewBlocking = true ) { InitRecordingAndPlayback ( iNewBufferSize ); }
|
||||
void InitPlayback ( int iNewBufferSize, bool bNewBlocking = false ) { InitRecordingAndPlayback ( iNewBufferSize ); }
|
||||
bool Read ( CVector<short>& psData );
|
||||
bool Write ( CVector<short>& psData );
|
||||
|
||||
|
@ -137,8 +137,8 @@ public:
|
|||
CSound();
|
||||
virtual ~CSound();
|
||||
|
||||
void InitRecording ( int iNewBufferSize, bool bNewBlocking = TRUE );
|
||||
void InitPlayback ( int iNewBufferSize, bool bNewBlocking = FALSE );
|
||||
void InitRecording ( int iNewBufferSize, bool bNewBlocking = true );
|
||||
void InitPlayback ( int iNewBufferSize, bool bNewBlocking = false );
|
||||
bool Read ( CVector<short>& psData );
|
||||
bool Write ( CVector<short>& psData );
|
||||
|
||||
|
|
Loading…
Reference in a new issue