bug fixes

This commit is contained in:
Volker Fischer 2009-08-13 16:48:22 +00:00
parent af0b4816c3
commit d7781e160f
2 changed files with 19 additions and 14 deletions

View file

@ -32,7 +32,7 @@ CChannel::CChannel ( const bool bNIsServer ) :
vecdGains ( USED_NUM_CHANNELS, (double) 1.0 ), vecdGains ( USED_NUM_CHANNELS, (double) 1.0 ),
bIsEnabled ( false ), bIsEnabled ( false ),
iNetwFrameSizeFact ( FRAME_SIZE_FACTOR_DEFAULT ), iNetwFrameSizeFact ( FRAME_SIZE_FACTOR_DEFAULT ),
iNetwFrameSize ( 1 ) // any value > 0 iNetwFrameSize ( 20 ) // must be > 0 and should be close to a valid size
{ {
// initial value for connection time out counter, we calculate the total // initial value for connection time out counter, we calculate the total
// number of samples here and subtract the number of samples of the block // number of samples here and subtract the number of samples of the block

View file

@ -322,6 +322,9 @@ void CServer::OnTimer()
for ( i = 0; i < iNumCurConnChan; i++ ) for ( i = 0; i < iNumCurConnChan; i++ )
{ {
// get actual ID of current channel
const int iCurChanID = vecChanID[i];
// init vectors storing information of all channels // init vectors storing information of all channels
vecvecdGains[i].Init ( iNumCurConnChan ); vecvecdGains[i].Init ( iNumCurConnChan );
vecvecsData[i].Init ( SYSTEM_FRAME_SIZE_SAMPLES ); vecvecsData[i].Init ( SYSTEM_FRAME_SIZE_SAMPLES );
@ -333,18 +336,19 @@ void CServer::OnTimer()
// the channel ID! Therefore we have to use "vecChanID" to // the channel ID! Therefore we have to use "vecChanID" to
// query the IDs of the currently connected channels // query the IDs of the currently connected channels
vecvecdGains[i][j] = vecvecdGains[i][j] =
vecChannels[vecChanID[i]].GetGain( vecChanID[j] ); vecChannels[iCurChanID].GetGain( vecChanID[j] );
} }
// get current number of CELT coded bytes // get current number of CELT coded bytes
const int iCeltNumCodedBytes = const int iCeltNumCodedBytes =
vecChannels[i].GetNetwFrameSize(); vecChannels[iCurChanID].GetNetwFrameSize();
// init temporal data vector and clear input buffers // init temporal data vector and clear input buffers
CVector<uint8_t> vecbyData ( iCeltNumCodedBytes ); CVector<uint8_t> vecbyData ( iCeltNumCodedBytes );
// get data // get data
const EGetDataStat eGetStat = vecChannels[i].GetData ( vecbyData ); const EGetDataStat eGetStat =
vecChannels[iCurChanID].GetData ( vecbyData );
// if channel was just disconnected, set flag that connected // if channel was just disconnected, set flag that connected
// client list is sent to all other clients // client list is sent to all other clients
@ -354,11 +358,9 @@ void CServer::OnTimer()
} }
// CELT decode received data stream // CELT decode received data stream
CVector<int16_t> vecsAudioMono ( SYSTEM_FRAME_SIZE_SAMPLES );
if ( eGetStat == GS_BUFFER_OK ) if ( eGetStat == GS_BUFFER_OK )
{ {
celt_decode ( CeltDecoder[i], celt_decode ( CeltDecoder[iCurChanID],
&vecbyData[0], &vecbyData[0],
iCeltNumCodedBytes, iCeltNumCodedBytes,
&vecvecsData[i][0] ); &vecvecsData[i][0] );
@ -366,7 +368,7 @@ void CServer::OnTimer()
else else
{ {
// lost packet // lost packet
celt_decode ( CeltDecoder[i], celt_decode ( CeltDecoder[iCurChanID],
NULL, NULL,
iCeltNumCodedBytes, iCeltNumCodedBytes,
&vecvecsData[i][0] ); &vecvecsData[i][0] );
@ -375,11 +377,11 @@ void CServer::OnTimer()
// send message for get status (for GUI) // send message for get status (for GUI)
if ( eGetStat == GS_BUFFER_OK ) if ( eGetStat == GS_BUFFER_OK )
{ {
PostWinMessage ( MS_JIT_BUF_GET, MUL_COL_LED_GREEN, i ); PostWinMessage ( MS_JIT_BUF_GET, MUL_COL_LED_GREEN, iCurChanID );
} }
else else
{ {
PostWinMessage ( MS_JIT_BUF_GET, MUL_COL_LED_RED, i ); PostWinMessage ( MS_JIT_BUF_GET, MUL_COL_LED_RED, iCurChanID );
} }
} }
@ -402,18 +404,21 @@ void CServer::OnTimer()
{ {
for ( int i = 0; i < iNumClients; i++ ) for ( int i = 0; i < iNumClients; i++ )
{ {
// get actual ID of current channel
const int iCurChanID = vecChanID[i];
// generate a sparate mix for each channel // generate a sparate mix for each channel
// actual processing of audio data -> mix // actual processing of audio data -> mix
vecsSendData = ProcessData ( vecvecsData, vecvecdGains[i] ); vecsSendData = ProcessData ( vecvecsData, vecvecdGains[i] );
// get current number of CELT coded bytes // get current number of CELT coded bytes
const int iCeltNumCodedBytes = const int iCeltNumCodedBytes =
vecChannels[vecChanID[i]].GetNetwFrameSize(); vecChannels[iCurChanID].GetNetwFrameSize();
// CELT encoding // CELT encoding
CVector<unsigned char> vecCeltData ( iCeltNumCodedBytes ); CVector<unsigned char> vecCeltData ( iCeltNumCodedBytes );
celt_encode ( CeltEncoder[vecChanID[i]], celt_encode ( CeltEncoder[iCurChanID],
&vecsSendData[0], &vecsSendData[0],
NULL, NULL,
&vecCeltData[0], &vecCeltData[0],
@ -421,8 +426,8 @@ void CServer::OnTimer()
// send separate mix to current clients // send separate mix to current clients
Socket.SendPacket ( Socket.SendPacket (
vecChannels[vecChanID[i]].PrepSendPacket ( vecCeltData ), vecChannels[iCurChanID].PrepSendPacket ( vecCeltData ),
vecChannels[vecChanID[i]].GetAddress() ); vecChannels[iCurChanID].GetAddress() );
} }
} }
else else