Merge "Fix for issue : 3419353 Crash during transition generation" into honeycomb

This commit is contained in:
Dheeraj Sharma
2011-02-03 09:36:02 -08:00
committed by Android (Google) Code Review

View File

@@ -1566,6 +1566,7 @@ public class VideoEditorImpl implements VideoEditor {
} }
boolean semAcquireDone = false; boolean semAcquireDone = false;
if (!mPreviewInProgress) {
try{ try{
semAcquireDone = mMANativeHelper.lock(ENGINE_ACCESS_MAX_TIMEOUT_MS); semAcquireDone = mMANativeHelper.lock(ENGINE_ACCESS_MAX_TIMEOUT_MS);
if (semAcquireDone == false) { if (semAcquireDone == false) {
@@ -1573,11 +1574,11 @@ public class VideoEditorImpl implements VideoEditor {
} }
if (mMediaItems.size() > 0) { if (mMediaItems.size() > 0) {
mPreviewInProgress = true;
mMANativeHelper.previewStoryBoard(mMediaItems, mTransitions, mMANativeHelper.previewStoryBoard(mMediaItems, mTransitions,
mAudioTracks, null); mAudioTracks, null);
mMANativeHelper.doPreview(surface, fromMs, toMs, loop, mMANativeHelper.doPreview(surface, fromMs, toMs, loop,
callbackAfterFrameCount, listener); callbackAfterFrameCount, listener);
mPreviewInProgress = true;
} }
/** /**
* release on complete by calling stopPreview * release on complete by calling stopPreview
@@ -1585,10 +1586,9 @@ public class VideoEditorImpl implements VideoEditor {
} catch (InterruptedException ex) { } catch (InterruptedException ex) {
Log.w(TAG, "The thread was interrupted", new Throwable()); Log.w(TAG, "The thread was interrupted", new Throwable());
throw new IllegalStateException("The thread was interrupted"); throw new IllegalStateException("The thread was interrupted");
} finally {
if (semAcquireDone) {
mMANativeHelper.unlock();
} }
} else {
throw new IllegalStateException("Preview already in progress");
} }
} }
@@ -1596,15 +1596,20 @@ public class VideoEditorImpl implements VideoEditor {
* {@inheritDoc} * {@inheritDoc}
*/ */
public long stopPreview() { public long stopPreview() {
long result = 0;
if (mPreviewInProgress) { if (mPreviewInProgress) {
long result = mMANativeHelper.stopPreview(); try {
mPreviewInProgress = false; result = mMANativeHelper.stopPreview();
/** /**
* release the sem acquired in startPreview * release on complete by calling stopPreview
*/ */
} finally {
mPreviewInProgress = false;
mMANativeHelper.unlock(); mMANativeHelper.unlock();
}
return result; return result;
} else { }
else {
return 0; return 0;
} }
} }