Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b4ce81da authored by Santosh Madhava's avatar Santosh Madhava
Browse files

Fix for issue 3431967 : Memory leak from video editor engine

Change-Id: I36e1cae53c91217804bc8243d9eb47820fb2114e
parent 9785cdf8
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -128,6 +128,11 @@ VideoEditorPreviewController::~VideoEditorPreviewController() {
        mAudioMixPCMFileHandle = M4OSA_NULL;
    }

    if (mBackgroundAudioSetting != NULL) {
        M4OSA_free((M4OSA_MemAddr32)mBackgroundAudioSetting);
        mBackgroundAudioSetting = NULL;
    }

    if(mTarget != NULL) {
        delete mTarget;
        mTarget = NULL;
+9 −3
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ struct VideoEditorResampler : public AudioBufferProvider {
    M4OSA_Int32 outSamplingRate;
    M4OSA_Int32 inSamplingRate;

    int16_t *mTmpInBuffer;
};

#define MAX_SAMPLEDURATION_FOR_CONVERTION 40 //ms
@@ -55,9 +56,9 @@ struct VideoEditorResampler : public AudioBufferProvider {
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 @@ void LVDestroy(M4OSA_Int32 resamplerContext) {
    VideoEditorResampler *context =
       (VideoEditorResampler *)resamplerContext;

    if (context->mTmpInBuffer != NULL) {
        free(context->mTmpInBuffer);
        context->mTmpInBuffer = NULL;
    }

    if (context->mInput != NULL) {
        free(context->mInput);
        context->mInput = NULL;