From b7ef20b2225f31734a95c0f475a4fef614fec077 Mon Sep 17 00:00:00 2001 From: Adam Sampson Date: Sun, 21 Jun 2020 13:55:08 +0100 Subject: [PATCH 1/5] Initialise CMultiColorLED::eColorFlag earlier. This avoids an uninitialised read when Reset() is called. --- src/multicolorled.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/multicolorled.cpp b/src/multicolorled.cpp index bc864fee..b9134a4c 100755 --- a/src/multicolorled.cpp +++ b/src/multicolorled.cpp @@ -37,12 +37,12 @@ CMultiColorLED::CMultiColorLED ( QWidget* parent, Qt::WindowFlags f ) BitmCubeYellow ( QString::fromUtf8 ( ":/png/LEDs/res/CLEDYellowSmall.png" ) ), BitmCubeRed ( QString::fromUtf8 ( ":/png/LEDs/res/CLEDRedSmall.png" ) ) { - // init color flags - Reset(); - // set init bitmap setPixmap ( BitmCubeGrey ); eColorFlag = RL_GREY; + + // init color flags + Reset(); } void CMultiColorLED::changeEvent ( QEvent* curEvent ) From 075933ef4c998635570ebc2c2acde34f80ca3985 Mon Sep 17 00:00:00 2001 From: Adam Sampson Date: Sun, 21 Jun 2020 13:55:08 +0100 Subject: [PATCH 2/5] Delete faders when destroying CAudioMixerBoard. This avoids a harmless memory leak. --- src/audiomixerboard.cpp | 8 ++++++++ src/audiomixerboard.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/src/audiomixerboard.cpp b/src/audiomixerboard.cpp index d86427b3..2e92884b 100755 --- a/src/audiomixerboard.cpp +++ b/src/audiomixerboard.cpp @@ -704,6 +704,14 @@ CAudioMixerBoard::CAudioMixerBoard ( QWidget* parent, Qt::WindowFlags ) : connectFaderSignalsToMixerBoardSlots(); } +CAudioMixerBoard::~CAudioMixerBoard() +{ + for ( int i = 0; i < MAX_NUM_CHANNELS; i++ ) + { + delete vecpChanFader[i]; + } +} + template inline void CAudioMixerBoard::connectFaderSignalsToMixerBoardSlots() { diff --git a/src/audiomixerboard.h b/src/audiomixerboard.h index 3d10c137..1701e4a0 100755 --- a/src/audiomixerboard.h +++ b/src/audiomixerboard.h @@ -169,6 +169,8 @@ public: CAudioMixerBoard ( QWidget* parent = nullptr, Qt::WindowFlags f = nullptr ); + virtual ~CAudioMixerBoard(); + void HideAll(); void ApplyNewConClientList ( CVector& vecChanInfo ); void SetServerName ( const QString& strNewServerName ); From 7ee8f6264ac90ccf2c207173d7c37fdc78c67ff1 Mon Sep 17 00:00:00 2001 From: Adam Sampson Date: Sun, 21 Jun 2020 13:55:08 +0100 Subject: [PATCH 3/5] Clean up custom Opus objects in ~CClient/~CServer. This avoids a harmless memory leak for each. --- src/client.cpp | 17 +++++++++++++++++ src/client.h | 2 ++ src/server.cpp | 20 ++++++++++++++++++++ src/server.h | 2 ++ 4 files changed, 41 insertions(+) diff --git a/src/client.cpp b/src/client.cpp index b88ace5a..02c880ff 100755 --- a/src/client.cpp +++ b/src/client.cpp @@ -220,6 +220,23 @@ CClient::CClient ( const quint16 iPortNumber, } } +CClient::~CClient() +{ + // free audio encoders and decoders + opus_custom_encoder_destroy ( OpusEncoderMono ); + opus_custom_decoder_destroy ( OpusDecoderMono ); + opus_custom_encoder_destroy ( OpusEncoderStereo ); + opus_custom_decoder_destroy ( OpusDecoderStereo ); + opus_custom_encoder_destroy ( Opus64EncoderMono ); + opus_custom_decoder_destroy ( Opus64DecoderMono ); + opus_custom_encoder_destroy ( Opus64EncoderStereo ); + opus_custom_decoder_destroy ( Opus64DecoderStereo ); + + // free audio modes + opus_custom_mode_destroy ( OpusMode ); + opus_custom_mode_destroy ( Opus64Mode ); +} + void CClient::OnSendProtMessage ( CVector vecMessage ) { // the protocol queries me to call the function to send the message diff --git a/src/client.h b/src/client.h index 24c61750..c73c7fbf 100755 --- a/src/client.h +++ b/src/client.h @@ -110,6 +110,8 @@ public: const bool bNoAutoJackConnect, const QString& strNClientName ); + virtual ~CClient(); + void Start(); void Stop(); bool IsRunning() { return Sound.IsRunning(); } diff --git a/src/server.cpp b/src/server.cpp index 80449d24..612f3426 100755 --- a/src/server.cpp +++ b/src/server.cpp @@ -550,6 +550,26 @@ void CServer::CreateAndSendJitBufMessage ( const int iCurChanID, vecChannels[iCurChanID].CreateJitBufMes ( iNNumFra ); } +CServer::~CServer() +{ + for ( int i = 0; i < iMaxNumChannels; i++ ) + { + // free audio encoders and decoders + opus_custom_encoder_destroy ( OpusEncoderMono[i] ); + opus_custom_decoder_destroy ( OpusDecoderMono[i] ); + opus_custom_encoder_destroy ( OpusEncoderStereo[i] ); + opus_custom_decoder_destroy ( OpusDecoderStereo[i] ); + opus_custom_encoder_destroy ( Opus64EncoderMono[i] ); + opus_custom_decoder_destroy ( Opus64DecoderMono[i] ); + opus_custom_encoder_destroy ( Opus64EncoderStereo[i] ); + opus_custom_decoder_destroy ( Opus64DecoderStereo[i] ); + + // free audio modes + opus_custom_mode_destroy ( OpusMode[i] ); + opus_custom_mode_destroy ( Opus64Mode[i] ); + } +} + void CServer::SendProtMessage ( int iChID, CVector vecMessage ) { // the protocol queries me to call the function to send the message diff --git a/src/server.h b/src/server.h index 4a370ad0..bb58dc2d 100755 --- a/src/server.h +++ b/src/server.h @@ -183,6 +183,8 @@ public: const bool bNUseDoubleSystemFrameSize, const ELicenceType eNLicenceType ); + virtual ~CServer(); + void Start(); void Stop(); bool IsRunning() { return HighPrecisionTimer.isActive(); } From 773e2740986dcf838073c6bc15f4d3d8718e85c8 Mon Sep 17 00:00:00 2001 From: Adam Sampson Date: Sun, 21 Jun 2020 13:55:08 +0100 Subject: [PATCH 4/5] Initialise CServerDlg::bSystemTrayIconAvaialbe earlier. The call to setupUi ends up changing the window title, which invokes changeEvent; this avoids an uninitialised read there. --- src/serverdlg.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/serverdlg.cpp b/src/serverdlg.cpp index 942e8027..9a829dea 100755 --- a/src/serverdlg.cpp +++ b/src/serverdlg.cpp @@ -37,6 +37,9 @@ CServerDlg::CServerDlg ( CServer* pNServP, BitmapSystemTrayInactive ( QString::fromUtf8 ( ":/png/LEDs/res/CLEDGreyArrow.png" ) ), BitmapSystemTrayActive ( QString::fromUtf8 ( ":/png/LEDs/res/CLEDGreenArrow.png" ) ) { + // check if system tray icon can be used + bSystemTrayIconAvaialbe = SystemTrayIcon.isSystemTrayAvailable(); + setupUi ( this ); @@ -143,9 +146,6 @@ CServerDlg::CServerDlg ( CServer* pNServP, + tr ( "During a recording session, the button can be used to start a new recording." ) ); - // check if system tray icon can be used - bSystemTrayIconAvaialbe = SystemTrayIcon.isSystemTrayAvailable(); - // init system tray icon if ( bSystemTrayIconAvaialbe ) { From 0342576d8e72f7a1a2047f1aa6b0cef95f0423c8 Mon Sep 17 00:00:00 2001 From: Adam Sampson Date: Sun, 21 Jun 2020 13:55:08 +0100 Subject: [PATCH 5/5] Always initialise CServer::bRecorderInitialised. Previously it was only set in the constructor if recording was enabled, which resulted in uninitialised reads in CServerDlg. --- src/server.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/server.cpp b/src/server.cpp index 612f3426..267a311f 100755 --- a/src/server.cpp +++ b/src/server.cpp @@ -241,6 +241,7 @@ CServer::CServer ( const int iNewMaxNumChan, Logging ( iMaxDaysHistory ), iFrameCount ( 0 ), JamRecorder ( strRecordingDirName ), + bRecorderInitialised ( false ), bEnableRecording ( false ), bWriteStatusHTMLFile ( false ), HighPrecisionTimer ( bNUseDoubleSystemFrameSize ),