OSDN Git Service

Fix for issue 3366265 : Native crash exporting movie
authorSantosh Madhava <smadhava@google.com>
Wed, 26 Jan 2011 00:58:20 +0000 (16:58 -0800)
committerSantosh Madhava <smadhava@google.com>
Wed, 26 Jan 2011 04:41:55 +0000 (20:41 -0800)
Change-Id: I04195198031eeb7d34d4249b49a1092321a2eb0a

media/java/android/media/videoeditor/VideoEditorImpl.java

index c19725c..672ce19 100755 (executable)
@@ -60,6 +60,11 @@ public class VideoEditorImpl implements VideoEditor {
     final Semaphore mPreviewSemaphore = new Semaphore(1, true);
 
     /*
+     *  Semaphore to control export calls
+     */
+    final Semaphore mExportSemaphore = new Semaphore(1, true);
+
+    /*
      *  XML tags
      */
     private static final String TAG_PROJECT = "project";
@@ -401,8 +406,15 @@ public class VideoEditorImpl implements VideoEditor {
                 throw new IllegalArgumentException("Argument Bitrate incorrect");
         }
 
-        mMANativeHelper.export(filename, mProjectPath, height,bitrate,audioCodec,
+        try {
+            mExportSemaphore.acquire();
+            mMANativeHelper.export(filename, mProjectPath, height,bitrate,audioCodec,
                 videoCodec,mMediaItems, mTransitions, mAudioTracks,listener);
+        } catch (InterruptedException  ex) {
+            Log.e("VideoEditorImpl", "Sem acquire NOT successful in export");
+        } finally {
+            mExportSemaphore.release();
+        }
     }
 
     /*
@@ -466,9 +478,16 @@ public class VideoEditorImpl implements VideoEditor {
                 throw new IllegalArgumentException("Argument Bitrate incorrect");
         }
 
-        mMANativeHelper.export(filename, mProjectPath, height,bitrate,
+        try {
+            mExportSemaphore.acquire();
+            mMANativeHelper.export(filename, mProjectPath, height,bitrate,
                                mMediaItems, mTransitions, mAudioTracks,
                                listener);
+        } catch (InterruptedException  ex) {
+            Log.e("VideoEditorImpl", "Sem acquire NOT successful in export");
+        } finally {
+            mExportSemaphore.release();
+        }
     }
 
     /*
@@ -476,7 +495,7 @@ public class VideoEditorImpl implements VideoEditor {
      */
     public void generatePreview(MediaProcessingProgressListener listener) {
         boolean semAcquireDone = false;
-        try{
+        try {
             mPreviewSemaphore.acquire();
             semAcquireDone = true;
             mMANativeHelper.setGeneratePreview(true);