Skip to content

Commit

Permalink
Merge pull request #2600 from pgScorpio/todo-comments
Browse files Browse the repository at this point in the history
Code style change: Replace clang-format off/on with TODO/TEST comments.
  • Loading branch information
hoffie authored May 21, 2022
2 parents 154f18a + d0d6f16 commit dbd34cd
Show file tree
Hide file tree
Showing 16 changed files with 192 additions and 184 deletions.
34 changes: 17 additions & 17 deletions src/buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -639,23 +639,23 @@ void CNetBufWithStats::UpdateAutoSetting()
// apply non-linear IIR filter
MathUtils().UpDownIIR1 ( dCurIIRFilterResult, static_cast<double> ( iCurDecision ), dWeightUp, dWeightDown );

// clang-format off
/*
// TEST store important detection parameters in file for debugging
static FILE* pFile = fopen ( "test.dat", "w" );
static int icnt = 0;
if ( icnt == 50 )
{
fprintf ( pFile, "%d %e\n", iCurDecision, dCurIIRFilterResult );
fflush ( pFile );
icnt = 0;
}
else
{
icnt++;
}
*/
// clang-format on
//### TEST: BEGIN ###//
// TEST store important detection parameters in file for debugging
/*
static FILE* pFile = fopen ( "test.dat", "w" );
static int icnt = 0;
if ( icnt == 50 )
{
fprintf ( pFile, "%d %e\n", iCurDecision, dCurIIRFilterResult );
fflush ( pFile );
icnt = 0;
}
else
{
icnt++;
}
*/
//### TEST: END ###//

// apply a hysteresis
iCurAutoBufferSizeSetting = MathUtils().DecideWithHysteresis ( dCurIIRFilterResult, iCurDecidedResult, dHysteresisValue );
Expand Down
10 changes: 5 additions & 5 deletions src/channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ CChannel::CChannel ( const bool bNIsServer ) :

// Connections -------------------------------------------------------------

// clang-format off
// TODO if we later do not fire vectors in the emits, we can remove this again
qRegisterMetaType<CVector<uint8_t> > ( "CVector<uint8_t>" );
qRegisterMetaType<CHostAddress> ( "CHostAddress" );
// clang-format on
//### TODO: BEGIN ###//
// if we later do not fire vectors in the emits, we can remove this again
qRegisterMetaType<CVector<uint8_t>> ( "CVector<uint8_t>" );
qRegisterMetaType<CHostAddress> ( "CHostAddress" );
//### TODO: END ###//

QObject::connect ( &Protocol, &CProtocol::MessReadyForSending, this, &CChannel::OnSendProtMessage );

Expand Down
8 changes: 4 additions & 4 deletions src/channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,10 @@ class CChannel : public QObject
void CreateChatTextMes ( const QString& strChatText ) { Protocol.CreateChatTextMes ( strChatText ); }
void CreateLicReqMes ( const ELicenceType eLicenceType ) { Protocol.CreateLicenceRequiredMes ( eLicenceType ); }

// clang-format off
// TODO needed for compatibility to old servers >= 3.4.6 and <= 3.5.12
void CreateReqChannelLevelListMes() { Protocol.CreateReqChannelLevelListMes(); }
// clang-format on
//### TODO: BEGIN ###//
// needed for compatibility to old servers >= 3.4.6 and <= 3.5.12
void CreateReqChannelLevelListMes() { Protocol.CreateReqChannelLevelListMes(); }
//### TODO: END ###//

void CreateConClientListMes ( const CVector<CChannelInfo>& vecChanInfo ) { Protocol.CreateConClientListMes ( vecChanInfo ); }

Expand Down
22 changes: 11 additions & 11 deletions src/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,10 @@ void CClient::OnNewConnection()
Channel.CreateReqConnClientsList();
CreateServerJitterBufferMessage();

// clang-format off
// TODO needed for compatibility to old servers >= 3.4.6 and <= 3.5.12
Channel.CreateReqChannelLevelListMes();
// clang-format on
//### TODO: BEGIN ###//
// needed for compatibility to old servers >= 3.4.6 and <= 3.5.12
Channel.CreateReqChannelLevelListMes();
//### TODO: END ###//
}

void CClient::CreateServerJitterBufferMessage()
Expand Down Expand Up @@ -1088,13 +1088,13 @@ void CClient::AudioCallback ( CVector<int16_t>& psData, void* arg )
// process audio data
pMyClientObj->ProcessSndCrdAudioData ( psData );

// clang-format off
/*
// TEST do a soundcard jitter measurement
static CTimingMeas JitterMeas ( 1000, "test2.dat" );
JitterMeas.Measure();
*/
// clang-format on
//### TEST: BEGIN ###//
// do a soundcard jitter measurement
/*
static CTimingMeas JitterMeas ( 1000, "test2.dat" );
JitterMeas.Measure();
*/
//### TEST: END ###//
}

void CClient::ProcessSndCrdAudioData ( CVector<int16_t>& vecsStereoSndCrd )
Expand Down
10 changes: 5 additions & 5 deletions src/clientdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1266,11 +1266,11 @@ void CClientDlg::Disconnect()
TimerDetectFeedback.stop();
bDetectFeedback = false;

// clang-format off
// TODO is this still required???
// immediately update status bar
OnTimerStatus();
// clang-format on
//### TODO: BEGIN ###//
// is this still required???
// immediately update status bar
OnTimerStatus();
//### TODO: END ###//

// reset LEDs
ledBuffers->Reset();
Expand Down
8 changes: 4 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -812,10 +812,10 @@ int main ( int argc, char** argv )
Q_INIT_RESOURCE ( resources );

#ifndef SERVER_ONLY
// clang-format off
// TEST -> activate the following line to activate the test bench,
//CTestbench Testbench ( "127.0.0.1", DEFAULT_PORT_NUMBER );
// clang-format on
//### TEST: BEGIN ###//
// activate the following line to activate the test bench,
// CTestbench Testbench ( "127.0.0.1", DEFAULT_PORT_NUMBER );
//### TEST: END ###//
#endif

CRpcServer* pRpcServer = nullptr;
Expand Down
30 changes: 13 additions & 17 deletions src/protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -619,12 +619,10 @@ void CProtocol::CreateAndImmSendConLessMessage ( const int iID, const CVector<ui

void CProtocol::ParseMessageBody ( const CVector<uint8_t>& vecbyMesBodyData, const int iRecCounter, const int iRecID )
{
// clang-format off
/*
// TEST channel implementation: randomly delete protocol messages (50 % loss)
if ( rand() < ( RAND_MAX / 2 ) ) return false;
*/
// clang-format on
//### TEST: BEGIN ###//
// channel implementation: randomly delete protocol messages (50 % loss)
// if ( rand() < ( RAND_MAX / 2 ) ) return false;
//### TEST: END ###//

// In case we received a message and returned an answer but our answer
// did not make it to the receiver, he will resend his message. We check
Expand Down Expand Up @@ -842,12 +840,11 @@ if ( rand() < ( RAND_MAX / 2 ) ) return false;

void CProtocol::ParseConnectionLessMessageBody ( const CVector<uint8_t>& vecbyMesBodyData, const int iRecID, const CHostAddress& InetAddr )
{
// clang-format off
/*
// TEST channel implementation: randomly delete protocol messages (50 % loss)
if ( rand() < ( RAND_MAX / 2 ) ) return false;
*/
// clang-format on
//### TEST: BEGIN ###//
// Test channel implementation: randomly delete protocol messages (50 % loss)

// if ( rand() < ( RAND_MAX / 2 ) ) return false;
//### TEST: END ###//

// check which type of message we received and do action
switch ( iRecID )
Expand Down Expand Up @@ -2646,12 +2643,11 @@ bool CProtocol::ParseMessageFrame ( const CVector<uint8_t>& vecbyData,

// Extract actual data -----------------------------------------------------

// clang-format off
// TODO this memory allocation is done in the real time thread but should be
// done in the low priority protocol management thread
// clang-format on

//### TODO: BEGIN ###//
// this memory allocation is done in the real time thread but should be
// done in the low priority protocol management thread
vecbyMesBodyData.Init ( iLenBy );
//### TODO: END ###//

iCurPos = MESS_HEADER_LENGTH_BYTE; // start from beginning of data

Expand Down
8 changes: 4 additions & 4 deletions src/protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,10 @@ class CProtocol : public QObject
void CreateLicenceRequiredMes ( const ELicenceType eLicenceType );
void CreateOpusSupportedMes();

// clang-format off
// TODO needed for compatibility to old servers >= 3.4.6 and <= 3.5.12
void CreateReqChannelLevelListMes();
// clang-format on
//### TODO: BEGIN ###//
// needed for compatibility to old servers >= 3.4.6 and <= 3.5.12
void CreateReqChannelLevelListMes();
//### TODO: END ###//

void CreateVersionAndOSMes();
void CreateRecorderStateMes ( const ERecorderState eRecorderState );
Expand Down
32 changes: 16 additions & 16 deletions src/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,12 @@ void CHighPrecisionTimer::run()
{
// call processing routine by fireing signal

// clang-format off
// TODO by emit a signal we leave the high priority thread -> maybe use some
// other connection type to have something like a true callback, e.g.
// "Qt::DirectConnection" -> Can this work?
// clang-format on

//### TODO: BEGIN ###//
// by emit a signal we leave the high priority thread -> maybe use some
// other connection type to have something like a true callback, e.g.
// "Qt::DirectConnection" -> Can this work?
emit timeout();
//### TODO: END ###//

// now wait until the next buffer shall be processed (we
// use the "increment method" to make sure we do not introduce
Expand Down Expand Up @@ -756,11 +755,11 @@ void CServer::Stop()

void CServer::OnTimer()
{
// clang-format off
/*
static CTimingMeas JitterMeas ( 1000, "test2.dat" ); JitterMeas.Measure(); // TEST do a timer jitter measurement
*/
// clang-format on
//### TEST: BEGIN ###//
// uncomment next line to do a timer Jitter measurement
// static CTimingMeas JitterMeas ( 1000, "test2.dat" ); JitterMeas.Measure();
//### TEST: END ###//

// Get data from all connected clients -------------------------------------
// some inits
int iNumClients = 0; // init connected client counter
Expand Down Expand Up @@ -1344,11 +1343,12 @@ void CServer::MixEncodeTransmitData ( const int iChanCnt, const int iNumClients
// OPUS encoding
if ( pCurOpusEncoder != nullptr )
{
// clang-format off
// TODO find a better place than this: the setting does not change all the time so for speed
// optimization it would be better to set it only if the network frame size is changed
opus_custom_encoder_ctl ( pCurOpusEncoder, OPUS_SET_BITRATE ( CalcBitRateBitsPerSecFromCodedBytes ( iCeltNumCodedBytes, iClientFrameSizeSamples ) ) );
// clang-format on
//### TODO: BEGIN ###//
// find a better place than this: the setting does not change all the time so for speed
// optimization it would be better to set it only if the network frame size is changed
opus_custom_encoder_ctl ( pCurOpusEncoder,
OPUS_SET_BITRATE ( CalcBitRateBitsPerSecFromCodedBytes ( iCeltNumCodedBytes, iClientFrameSizeSamples ) ) );
//### TODO: END ###//

for ( int iB = 0; iB < vecNumFrameSizeConvBlocks[iChanCnt]; iB++ )
{
Expand Down
10 changes: 5 additions & 5 deletions src/serverdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,11 @@ CServerDlg::CServerDlg ( CServer* pNServP, CServerSettings* pNSetP, const bool b
lvwClients->setColumnWidth ( 3, 50 ); // Channels
lvwClients->clear();

// clang-format off
// TEST workaround for resize problem of window after iconize in task bar
lvwClients->setMinimumWidth ( 170 + 130 + 60 + 205 );
lvwClients->setMinimumHeight ( 140 );
// clang-format on
//### TODO: BEGIN ###//
// workaround for resize problem of window after iconize in task bar
lvwClients->setMinimumWidth ( 170 + 130 + 60 + 205 );
lvwClients->setMinimumHeight ( 140 );
//### TODO: END ###//

// insert items in reverse order because in Windows all of them are
// always visible -> put first item on the top
Expand Down
Loading

0 comments on commit dbd34cd

Please sign in to comment.