Clean up custom Opus objects in ~CClient/~CServer.

This avoids a harmless memory leak for each.
This commit is contained in:
Adam Sampson 2020-06-21 13:55:08 +01:00
parent 075933ef4c
commit 7ee8f6264a
4 changed files with 41 additions and 0 deletions

View file

@ -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<uint8_t> vecMessage ) void CClient::OnSendProtMessage ( CVector<uint8_t> vecMessage )
{ {
// the protocol queries me to call the function to send the message // the protocol queries me to call the function to send the message

View file

@ -110,6 +110,8 @@ public:
const bool bNoAutoJackConnect, const bool bNoAutoJackConnect,
const QString& strNClientName ); const QString& strNClientName );
virtual ~CClient();
void Start(); void Start();
void Stop(); void Stop();
bool IsRunning() { return Sound.IsRunning(); } bool IsRunning() { return Sound.IsRunning(); }

View file

@ -550,6 +550,26 @@ void CServer::CreateAndSendJitBufMessage ( const int iCurChanID,
vecChannels[iCurChanID].CreateJitBufMes ( iNNumFra ); 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<uint8_t> vecMessage ) void CServer::SendProtMessage ( int iChID, CVector<uint8_t> vecMessage )
{ {
// the protocol queries me to call the function to send the message // the protocol queries me to call the function to send the message

View file

@ -183,6 +183,8 @@ public:
const bool bNUseDoubleSystemFrameSize, const bool bNUseDoubleSystemFrameSize,
const ELicenceType eNLicenceType ); const ELicenceType eNLicenceType );
virtual ~CServer();
void Start(); void Start();
void Stop(); void Stop();
bool IsRunning() { return HighPrecisionTimer.isActive(); } bool IsRunning() { return HighPrecisionTimer.isActive(); }