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

Commit 2380aa08 authored by Santosh Madhava's avatar Santosh Madhava Committed by Android (Google) Code Review
Browse files

Merge "Fix for issue 3431967: Memory leak from video editor engine"

parents 6ebc6bde 71771b3b
Loading
Loading
Loading
Loading
+26 −21
Original line number Diff line number Diff line
@@ -453,7 +453,11 @@ static void jniPreviewProgressCallback (void* cookie, M4OSA_UInt32 msgType,

        case MSG_TYPE_OVERLAY_CLEAR:
            isSendProgress = false;
            if (pContext->mOverlayFileName != NULL) {
                M4OSA_free((M4OSA_MemAddr32)pContext->mOverlayFileName);
                pContext->mOverlayFileName = NULL;
            }

            LOGV("MSG_TYPE_OVERLAY_CLEAR");
            //argc is not used
            pContext->mIsUpdateOverlay = true;
@@ -1760,6 +1764,17 @@ videoEditor_populateSettings(
            VIDEOEDIT_LOG_EDIT_SETTINGS(pContext->pEditSettings);
        }
    }
    /* free previous allocations , if any */
    if (pContext->mAudioSettings != M4OSA_NULL) {
        if (pContext->mAudioSettings->pFile != NULL) {
            M4OSA_free((M4OSA_MemAddr32)pContext->mAudioSettings->pFile);
            pContext->mAudioSettings->pFile = M4OSA_NULL;
        }
        if (pContext->mAudioSettings->pPCMFilePath != NULL) {
            M4OSA_free((M4OSA_MemAddr32)pContext->mAudioSettings->pPCMFilePath);
            pContext->mAudioSettings->pPCMFilePath = M4OSA_NULL;
        }
    }

    if (audioSettingObject != M4OSA_NULL) {
        jclass audioSettingClazz = pEnv->FindClass(AUDIO_SETTINGS_CLASS_NAME);
@@ -1823,16 +1838,6 @@ videoEditor_populateSettings(
            = pEnv->GetIntField(audioSettingObject,fid);
        M4OSA_TRACE1_1("fileType = %d",pContext->mAudioSettings->fileType);

        /* free previous allocations , if any */
        if (pContext->mAudioSettings->pFile != NULL) {
            M4OSA_free((M4OSA_MemAddr32)pContext->mAudioSettings->pFile);
            pContext->mAudioSettings->pFile = M4OSA_NULL;
        }
        if (pContext->mAudioSettings->pPCMFilePath != NULL) {
            M4OSA_free((M4OSA_MemAddr32)pContext->mAudioSettings->pPCMFilePath);
            pContext->mAudioSettings->pPCMFilePath = M4OSA_NULL;
        }

        fid = pEnv->GetFieldID(audioSettingClazz,"pFile","Ljava/lang/String;");
        strPath = (jstring)pEnv->GetObjectField(audioSettingObject,fid);
        pTempChar = (M4OSA_Char*)pEnv->GetStringUTFChars(strPath, M4OSA_NULL);
@@ -3044,6 +3049,9 @@ videoEditor_release(
            pContext->mPreviewController = M4OSA_NULL;
        }

        // Free the mAudioSettings context.
        if(pContext->mAudioSettings != M4OSA_NULL)
        {
            if (pContext->mAudioSettings->pFile != NULL) {
                M4OSA_free((M4OSA_MemAddr32)pContext->mAudioSettings->pFile);
                pContext->mAudioSettings->pFile = M4OSA_NULL;
@@ -3053,9 +3061,6 @@ videoEditor_release(
                pContext->mAudioSettings->pPCMFilePath = M4OSA_NULL;
            }

        // Free the context.
        if(pContext->mAudioSettings != M4OSA_NULL)
        {
            M4OSA_free((M4OSA_MemAddr32)pContext->mAudioSettings);
            pContext->mAudioSettings = M4OSA_NULL;
        }