Fix 5607624: Native crash in movie studio while previewing the movie
Change-Id: I6bc123a3da4fb071a65fe776bcba0268fa58bf29
diff --git a/libvideoeditor/lvpp/VideoEditorSRC.cpp b/libvideoeditor/lvpp/VideoEditorSRC.cpp
index 1ea32ef..364343a 100755
--- a/libvideoeditor/lvpp/VideoEditorSRC.cpp
+++ b/libvideoeditor/lvpp/VideoEditorSRC.cpp
@@ -41,6 +41,7 @@
mBuffer = NULL;
mLeftover = 0;
mFormatChanged = false;
+ mStopPending = false;
mSeekMode = ReadOptions::SEEK_PREVIOUS_SYNC;
// Input Source validation
@@ -127,6 +128,11 @@
// Resample to target quality
mResampler->resample(pTmpBuffer, outFrameCnt, this);
+ if (mStopPending) {
+ stop();
+ mStopPending = false;
+ }
+
// Change resampler and retry if format change happened
if (mFormatChanged) {
mFormatChanged = false;
@@ -220,7 +226,10 @@
// EOS or some other error
if (err != OK) {
LOGV("EOS or some err: %d", err);
- stop();
+ // We cannot call stop() here because stop() will release the
+ // AudioResampler, and we are in a callback of the AudioResampler.
+ // So just remember the fact and let read() call stop().
+ mStopPending = true;
return err;
}