Skip to content
Snippets Groups Projects
Commit 304b693e authored by Tristan Matthews's avatar Tristan Matthews
Browse files

* #8968: fix potential memory leak in audiorecord

parent f692ee91
No related branches found
No related tags found
No related merge requests found
......@@ -57,24 +57,16 @@ AudioRecord::AudioRecord() : fileHandle_(NULL)
, sndSmplRate_(8000)
, nbSamplesMic_(0)
, nbSamplesSpk_(0)
, nbSamplesMax_(3000)
, recordingEnabled_(false)
, mixBuffer_(new SFLDataFormat[nbSamplesMax_])
, micBuffer_(new SFLDataFormat[nbSamplesMax_])
, spkBuffer_(new SFLDataFormat[nbSamplesMax_])
, mixBuffer_()
, micBuffer_()
, spkBuffer_()
, filename_()
, savePath_()
{
createFilename();
}
AudioRecord::~AudioRecord()
{
delete [] mixBuffer_;
delete [] micBuffer_;
delete [] spkBuffer_;
}
void AudioRecord::setSndSamplingRate(int smplRate)
{
sndSmplRate_ = smplRate;
......
......@@ -33,6 +33,7 @@
#include <string>
#include <cstdlib>
#include <memory>
#include "global.h"
#include "noncopyable.h"
......@@ -44,8 +45,6 @@ class AudioRecord {
AudioRecord();
~AudioRecord();
void setSndSamplingRate(int smplRate);
/**
* Get the recrding sampling rate
......@@ -206,7 +205,7 @@ class AudioRecord {
/**
* Maximum number of samples
*/
int nbSamplesMax_;
static const int NB_SAMPLES_MAX = 3000;
/**
* Recording flage
......@@ -216,17 +215,17 @@ class AudioRecord {
/**
* Buffer used for mixing two channels
*/
SFLDataFormat* mixBuffer_;
SFLDataFormat mixBuffer_[NB_SAMPLES_MAX];
/**
* Buffer used to copy mic info
*/
SFLDataFormat* micBuffer_;
SFLDataFormat micBuffer_[NB_SAMPLES_MAX];
/**
* Buffer used to copy spkr info
*/
SFLDataFormat* spkBuffer_;
SFLDataFormat spkBuffer_[NB_SAMPLES_MAX];
/**
* Filename for this recording
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment