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

Commit 9785cdf8 authored by Santosh Madhava's avatar Santosh Madhava
Browse files

Fix for issue 3431967 : Movie Studio crashed after pressing the back button

Change-Id: I4b8cb2a54c2a1b7117feae9d8c6ca14e81b1f83d
parent 1ea8583c
Loading
Loading
Loading
Loading
+15 −4
Original line number Original line Diff line number Diff line
@@ -46,6 +46,7 @@ VideoEditorSRC::VideoEditorSRC(
    mSeekTimeUs = -1;
    mSeekTimeUs = -1;
    mLeftover = 0;
    mLeftover = 0;
    mLastReadSize = 0;
    mLastReadSize = 0;
    mReSampledBuffer = NULL;
#ifndef FROYO
#ifndef FROYO
    mSeekMode =  ReadOptions::SEEK_PREVIOUS_SYNC;
    mSeekMode =  ReadOptions::SEEK_PREVIOUS_SYNC;
#endif
#endif
@@ -168,6 +169,10 @@ status_t VideoEditorSRC::stop() {
    mAccuOutBufferSize  = 0;
    mAccuOutBufferSize  = 0;
    mLeftover = 0;
    mLeftover = 0;
    mLastReadSize = 0;
    mLastReadSize = 0;
    if (mReSampledBuffer != NULL) {
        free(mReSampledBuffer);
        mReSampledBuffer = NULL;
    }


    return OK;
    return OK;
}
}
@@ -223,15 +228,21 @@ status_t VideoEditorSRC::read (
        memset(pTmpBuffer, 0x00, outFrameCnt * 2 * sizeof(int32_t));
        memset(pTmpBuffer, 0x00, outFrameCnt * 2 * sizeof(int32_t));
        // Resample to target quality
        // Resample to target quality
        mResampler->resample(pTmpBuffer, outFrameCnt, this);
        mResampler->resample(pTmpBuffer, outFrameCnt, this);
        int16_t *reSampledBuffer = (int16_t*)malloc(outBufferSize);

        memset(reSampledBuffer, 0x00, outBufferSize);
        // Free previous allocation
        if (mReSampledBuffer != NULL) {
            free(mReSampledBuffer);
            mReSampledBuffer = NULL;
        }
        mReSampledBuffer = (int16_t*)malloc(outBufferSize);
        memset(mReSampledBuffer, 0x00, outBufferSize);


        // Convert back to 16 bits
        // Convert back to 16 bits
        AudioMixer::ditherAndClamp((int32_t*)reSampledBuffer, pTmpBuffer, outFrameCnt);
        AudioMixer::ditherAndClamp((int32_t*)mReSampledBuffer, pTmpBuffer, outFrameCnt);
        LOGV("Resampled buffer size %d", outFrameCnt* 2 * sizeof(int16_t));
        LOGV("Resampled buffer size %d", outFrameCnt* 2 * sizeof(int16_t));


        // Create new MediaBuffer
        // Create new MediaBuffer
        mCopyBuffer = new MediaBuffer((void*)reSampledBuffer, outBufferSize);
        mCopyBuffer = new MediaBuffer((void*)mReSampledBuffer, outBufferSize);


        // Compute and set the new timestamp
        // Compute and set the new timestamp
        sp<MetaData> to = mCopyBuffer->meta_data();
        sp<MetaData> to = mCopyBuffer->meta_data();
+1 −0
Original line number Original line Diff line number Diff line
@@ -100,6 +100,7 @@ class VideoEditorSRC : public MediaSource , public AudioBufferProvider {


        int64_t mSeekTimeUs;
        int64_t mSeekTimeUs;
        ReadOptions::SeekMode mSeekMode;
        ReadOptions::SeekMode mSeekMode;
        int16_t *mReSampledBuffer;


};
};


+5 −0
Original line number Original line Diff line number Diff line
@@ -2085,6 +2085,11 @@ M4OSA_ERR applyRenderingMode(M4VIFI_ImagePlane* pPlaneIn, M4VIFI_ImagePlane* pPl
                }
                }
            }
            }
        }
        }

        if (m_air_context != M4OSA_NULL) {
            M4AIR_cleanUp(m_air_context);
            m_air_context = M4OSA_NULL;
        }
    }
    }


    return err;
    return err;