Fix for issue 3431967 : Memory leak from video editor engine
Change-Id: I36e1cae53c91217804bc8243d9eb47820fb2114e
diff --git a/libvideoeditor/lvpp/VideoEditorPreviewController.cpp b/libvideoeditor/lvpp/VideoEditorPreviewController.cpp
index 78f0cda..e7a767a 100755
--- a/libvideoeditor/lvpp/VideoEditorPreviewController.cpp
+++ b/libvideoeditor/lvpp/VideoEditorPreviewController.cpp
@@ -128,6 +128,11 @@
mAudioMixPCMFileHandle = M4OSA_NULL;
}
+ if (mBackgroundAudioSetting != NULL) {
+ M4OSA_free((M4OSA_MemAddr32)mBackgroundAudioSetting);
+ mBackgroundAudioSetting = NULL;
+ }
+
if(mTarget != NULL) {
delete mTarget;
mTarget = NULL;
diff --git a/libvideoeditor/vss/src/VideoEditorResampler.cpp b/libvideoeditor/vss/src/VideoEditorResampler.cpp
index c4d1a8a..47c9579 100755
--- a/libvideoeditor/vss/src/VideoEditorResampler.cpp
+++ b/libvideoeditor/vss/src/VideoEditorResampler.cpp
@@ -48,6 +48,7 @@
M4OSA_Int32 outSamplingRate;
M4OSA_Int32 inSamplingRate;
+ int16_t *mTmpInBuffer;
};
#define MAX_SAMPLEDURATION_FOR_CONVERTION 40 //ms
@@ -55,9 +56,9 @@
status_t VideoEditorResampler::getNextBuffer(AudioBufferProvider::Buffer *pBuffer) {
uint32_t dataSize = pBuffer->frameCount * this->nbChannels * sizeof(int16_t);
- int16_t *pTmpInBuffer = (int16_t*)malloc(dataSize);
- memcpy(pTmpInBuffer, this->mInput, dataSize);
- pBuffer->raw = (void*)pTmpInBuffer;
+ mTmpInBuffer = (int16_t*)malloc(dataSize);
+ memcpy(mTmpInBuffer, this->mInput, dataSize);
+ pBuffer->raw = (void*)mTmpInBuffer;
return OK;
}
@@ -119,6 +120,11 @@
VideoEditorResampler *context =
(VideoEditorResampler *)resamplerContext;
+ if (context->mTmpInBuffer != NULL) {
+ free(context->mTmpInBuffer);
+ context->mTmpInBuffer = NULL;
+ }
+
if (context->mInput != NULL) {
free(context->mInput);
context->mInput = NULL;