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