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
|
// 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;
|
||||||
|
|
|
@ -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>
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
101
src/socket.cpp
101
src/socket.cpp
|
@ -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 );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,57 +81,60 @@ void CSocket::SendPacket ( const CVector<unsigned char>& vecbySendBuf,
|
||||||
|
|
||||||
void CSocket::OnDataReceived()
|
void CSocket::OnDataReceived()
|
||||||
{
|
{
|
||||||
QHostAddress SenderAddress;
|
while ( SocketDevice.hasPendingDatagrams() )
|
||||||
quint16 SenderPort;
|
{
|
||||||
|
QHostAddress SenderAddress;
|
||||||
|
quint16 SenderPort;
|
||||||
|
|
||||||
// read block from network interface and query address of sender
|
// read block from network interface and query address of sender
|
||||||
const int iNumBytesRead = SocketDevice.readDatagram ( (char*) &vecbyRecBuf[0],
|
const int iNumBytesRead = SocketDevice.readDatagram ( (char*) &vecbyRecBuf[0],
|
||||||
MAX_SIZE_BYTES_NETW_BUF, &SenderAddress, &SenderPort );
|
MAX_SIZE_BYTES_NETW_BUF, &SenderAddress, &SenderPort );
|
||||||
|
|
||||||
// convert address of client
|
// convert address of client
|
||||||
CHostAddress RecHostAddr ( SenderAddress, SenderPort );
|
CHostAddress RecHostAddr ( SenderAddress, SenderPort );
|
||||||
|
|
||||||
// check if an error occurred
|
// check if an error occurred
|
||||||
if ( iNumBytesRead < 0 )
|
if ( iNumBytesRead < 0 )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( bIsClient )
|
if ( bIsClient )
|
||||||
{
|
{
|
||||||
// client
|
// client
|
||||||
// check if packet comes from the server we want to connect
|
// check if packet comes from the server we want to connect
|
||||||
if ( ! ( pChannel->GetAddress() == RecHostAddr ) )
|
if ( ! ( pChannel->GetAddress() == RecHostAddr ) )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ( pChannel->PutData ( vecbyRecBuf, iNumBytesRead ) )
|
switch ( pChannel->PutData ( vecbyRecBuf, iNumBytesRead ) )
|
||||||
{
|
{
|
||||||
case PS_AUDIO_OK:
|
case PS_AUDIO_OK:
|
||||||
PostWinMessage ( MS_JIT_BUF_PUT, MUL_COL_LED_GREEN );
|
PostWinMessage ( MS_JIT_BUF_PUT, MUL_COL_LED_GREEN );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PS_AUDIO_ERR:
|
case PS_AUDIO_ERR:
|
||||||
case PS_GEN_ERROR:
|
case PS_GEN_ERROR:
|
||||||
PostWinMessage ( MS_JIT_BUF_PUT, MUL_COL_LED_RED );
|
PostWinMessage ( MS_JIT_BUF_PUT, MUL_COL_LED_RED );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PS_PROT_ERR:
|
case PS_PROT_ERR:
|
||||||
PostWinMessage ( MS_JIT_BUF_PUT, MUL_COL_LED_YELLOW );
|
PostWinMessage ( MS_JIT_BUF_PUT, MUL_COL_LED_YELLOW );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// server
|
// server
|
||||||
if ( pChannelSet->PutData ( vecbyRecBuf, iNumBytesRead, RecHostAddr ) )
|
if ( pChannelSet->PutData ( vecbyRecBuf, iNumBytesRead, RecHostAddr ) )
|
||||||
{
|
{
|
||||||
// this was an audio packet, start server
|
// this was an audio packet, start server
|
||||||
// tell the server object to wake up if it
|
// tell the server object to wake up if it
|
||||||
// is in sleep mode (Qt will delete the event object when done)
|
// is in sleep mode (Qt will delete the event object when done)
|
||||||
QCoreApplication::postEvent ( pServer,
|
QCoreApplication::postEvent ( pServer,
|
||||||
new CLlconEvent ( MS_PACKET_RECEIVED, 0, 0 ) );
|
new CLlconEvent ( MS_PACKET_RECEIVED, 0, 0 ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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()
|
||||||
|
@ -779,11 +779,11 @@ long CSound::asioMessages ( long selector, long value, void* message, double* op
|
||||||
\******************************************************************************/
|
\******************************************************************************/
|
||||||
bool CSound::Read ( CVector<short>& psData )
|
bool CSound::Read ( CVector<short>& psData )
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1213,8 +1213,8 @@ void CSound::SetOutNumBuf ( int iNewNum )
|
||||||
\******************************************************************************/
|
\******************************************************************************/
|
||||||
void CSound::Close()
|
void CSound::Close()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
MMRESULT result;
|
MMRESULT result;
|
||||||
|
|
||||||
// reset audio driver
|
// reset audio driver
|
||||||
if ( m_WaveOut != NULL )
|
if ( m_WaveOut != NULL )
|
||||||
|
@ -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()
|
||||||
|
@ -1324,15 +1324,15 @@ CSound::CSound()
|
||||||
}
|
}
|
||||||
|
|
||||||
// init wave-format structure
|
// init wave-format structure
|
||||||
sWaveFormatEx.wFormatTag = WAVE_FORMAT_PCM;
|
sWaveFormatEx.wFormatTag = WAVE_FORMAT_PCM;
|
||||||
sWaveFormatEx.nChannels = NUM_IN_OUT_CHANNELS;
|
sWaveFormatEx.nChannels = NUM_IN_OUT_CHANNELS;
|
||||||
sWaveFormatEx.wBitsPerSample = BITS_PER_SAMPLE;
|
sWaveFormatEx.wBitsPerSample = BITS_PER_SAMPLE;
|
||||||
sWaveFormatEx.nSamplesPerSec = SND_CRD_SAMPLE_RATE;
|
sWaveFormatEx.nSamplesPerSec = SND_CRD_SAMPLE_RATE;
|
||||||
sWaveFormatEx.nBlockAlign = sWaveFormatEx.nChannels *
|
sWaveFormatEx.nBlockAlign = sWaveFormatEx.nChannels *
|
||||||
sWaveFormatEx.wBitsPerSample / 8;
|
sWaveFormatEx.wBitsPerSample / 8;
|
||||||
sWaveFormatEx.nAvgBytesPerSec = sWaveFormatEx.nBlockAlign *
|
sWaveFormatEx.nAvgBytesPerSec = sWaveFormatEx.nBlockAlign *
|
||||||
sWaveFormatEx.nSamplesPerSec;
|
sWaveFormatEx.nSamplesPerSec;
|
||||||
sWaveFormatEx.cbSize = 0;
|
sWaveFormatEx.cbSize = 0;
|
||||||
|
|
||||||
// get the number of digital audio devices in this computer, check range
|
// get the number of digital audio devices in this computer, check range
|
||||||
iNumDevs = waveInGetNumDevs();
|
iNumDevs = waveInGetNumDevs();
|
||||||
|
@ -1359,22 +1359,22 @@ CSound::CSound()
|
||||||
|
|
||||||
// we use an event controlled wave-in (wave-out) structure
|
// we use an event controlled wave-in (wave-out) structure
|
||||||
// create events
|
// create events
|
||||||
m_WaveInEvent = CreateEvent ( NULL, FALSE, FALSE, NULL );
|
m_WaveInEvent = CreateEvent ( NULL, FALSE, FALSE, NULL );
|
||||||
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()
|
||||||
|
|
|
@ -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 );
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue