summaryrefslogtreecommitdiffstats
path: root/libvideoeditor/lvpp
diff options
context:
space:
mode:
authorRajneesh Chowdury <rajneeshc@google.com>2011-03-02 14:23:24 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-03-02 14:23:24 -0800
commit0a8f12903f52c4f2b718123bf7e1232acfa19c20 (patch)
tree53d787e4f024d56938bcc2920be870173cd14399 /libvideoeditor/lvpp
parent5787a5e59ca06eaecbe57b015846f3d01337c5eb (diff)
parent1e2469c689feeb2e90a38900151e2ef1e6117d07 (diff)
downloadframeworks_av-0a8f12903f52c4f2b718123bf7e1232acfa19c20.zip
frameworks_av-0a8f12903f52c4f2b718123bf7e1232acfa19c20.tar.gz
frameworks_av-0a8f12903f52c4f2b718123bf7e1232acfa19c20.tar.bz2
Merge "Fix for issue 3427268 Crash when stopping playback"
Diffstat (limited to 'libvideoeditor/lvpp')
-rwxr-xr-xlibvideoeditor/lvpp/VideoEditorPreviewController.cpp44
-rwxr-xr-xlibvideoeditor/lvpp/VideoEditorPreviewController.h1
2 files changed, 35 insertions, 10 deletions
diff --git a/libvideoeditor/lvpp/VideoEditorPreviewController.cpp b/libvideoeditor/lvpp/VideoEditorPreviewController.cpp
index 180f75e..8ad92da 100755
--- a/libvideoeditor/lvpp/VideoEditorPreviewController.cpp
+++ b/libvideoeditor/lvpp/VideoEditorPreviewController.cpp
@@ -639,7 +639,12 @@ M4OSA_UInt32 VideoEditorPreviewController::stopPreview() {
// Stop the thread
if(mThreadContext != NULL) {
bStopThreadInProgress = true;
- err = M4OSA_semaphorePost(mSemThreadWait);
+ {
+ Mutex::Autolock autoLock(mLockSem);
+ if (mSemThreadWait != NULL) {
+ err = M4OSA_semaphorePost(mSemThreadWait);
+ }
+ }
err = M4OSA_threadSyncStop(mThreadContext);
if(err != M4NO_ERROR) {
@@ -657,9 +662,13 @@ M4OSA_UInt32 VideoEditorPreviewController::stopPreview() {
}
// Close the semaphore first
- if(mSemThreadWait != NULL) {
- err = M4OSA_semaphoreClose(mSemThreadWait);
- LOGV("stopPreview: close semaphore returns 0x%x", err);
+ {
+ Mutex::Autolock autoLock(mLockSem);
+ if(mSemThreadWait != NULL) {
+ err = M4OSA_semaphoreClose(mSemThreadWait);
+ LOGV("stopPreview: close semaphore returns 0x%x", err);
+ mSemThreadWait = NULL;
+ }
}
for (int playerInst=0; playerInst<NBPLAYER_INSTANCES; playerInst++) {
@@ -1102,13 +1111,17 @@ M4OSA_ERR VideoEditorPreviewController::threadProc(M4OSA_Void* param) {
pController->mPrepareReqest = M4OSA_FALSE;
preparePlayer((void*)pController, pController->mCurrentPlayer,
pController->mCurrentClipNumber+1);
- err = M4OSA_semaphoreWait(pController->mSemThreadWait,
- M4OSA_WAIT_FOREVER);
+ if (pController->mSemThreadWait != NULL) {
+ err = M4OSA_semaphoreWait(pController->mSemThreadWait,
+ M4OSA_WAIT_FOREVER);
+ }
} else {
if (!pController->bStopThreadInProgress) {
LOGV("threadProc: state busy...wait for sem");
- err = M4OSA_semaphoreWait(pController->mSemThreadWait,
- M4OSA_WAIT_FOREVER);
+ if (pController->mSemThreadWait != NULL) {
+ err = M4OSA_semaphoreWait(pController->mSemThreadWait,
+ M4OSA_WAIT_FOREVER);
+ }
}
LOGV("threadProc: sem wait returned err = 0x%x", err);
}
@@ -1170,7 +1183,13 @@ void VideoEditorPreviewController::notify(
}
M4OSA_free((M4OSA_MemAddr32)pEditInfo);
}
- M4OSA_semaphorePost(pController->mSemThreadWait);
+ {
+ Mutex::Autolock autoLock(pController->mLockSem);
+ if (pController->mSemThreadWait != NULL) {
+ M4OSA_semaphorePost(pController->mSemThreadWait);
+ }
+ }
+
break;
}
case MEDIA_ERROR:
@@ -1219,7 +1238,12 @@ void VideoEditorPreviewController::notify(
pController->mCurrentPlayer = 0;
}
// Prepare the first clip to be played
- M4OSA_semaphorePost(pController->mSemThreadWait);
+ {
+ Mutex::Autolock autoLock(pController->mLockSem);
+ if (pController->mSemThreadWait != NULL) {
+ M4OSA_semaphorePost(pController->mSemThreadWait);
+ }
+ }
}
break;
case 0xBBBBBBBB:
diff --git a/libvideoeditor/lvpp/VideoEditorPreviewController.h b/libvideoeditor/lvpp/VideoEditorPreviewController.h
index e9e4e84..c9d7de0 100755
--- a/libvideoeditor/lvpp/VideoEditorPreviewController.h
+++ b/libvideoeditor/lvpp/VideoEditorPreviewController.h
@@ -137,6 +137,7 @@ private:
M4VIFI_UInt8* mFrameRGBBuffer;
M4VIFI_UInt8* mFrameYUVBuffer;
+ mutable Mutex mLockSem;
static M4OSA_ERR preparePlayer(void* param, int playerInstance, int index);
static M4OSA_ERR threadProc(M4OSA_Void* param);
static void notify(void* cookie, int msg, int ext1, int ext2);