To fix video editor crash issue

BZ: 52577

When the sdcard is short of storage, video editor will
fail to write the encoded data to SDcard. When this error
happens, current error handling code forgets to derease
the encoded buffer reference count. This will cause
buffer's refcount check fails, which lead to video editor
crash.

Change-Id: I175790640a5fbbe226d0e17f3d6a752337e6b124
Signed-off-by: wfeng6 <wei.feng@intel.com>
Reviewed-on: http://android.intel.com:8080/62380
Reviewed-by: Gu, Wangyi <wangyi.gu@intel.com>
Reviewed-by: Ding, Haitao <haitao.ding@intel.com>
Tested-by: Ding, Haitao <haitao.ding@intel.com>
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
diff --git a/frameworks/videoedit/stagefrightshells/IntelVideoEditorUtils.h b/frameworks/videoedit/stagefrightshells/IntelVideoEditorUtils.h
index 81acf17..4e1c929 100644
--- a/frameworks/videoedit/stagefrightshells/IntelVideoEditorUtils.h
+++ b/frameworks/videoedit/stagefrightshells/IntelVideoEditorUtils.h
@@ -44,7 +44,7 @@
 #define VIDEOEDITOR_CHECK(test, errCode) \
 { \
     if( !(test) ) { \
-        ALOGV("!!! %s (L%d) check failed : " #test ", yields error 0x%.8x", \
+        ALOGW("!!! %s (L%d) check failed : " #test ", yields error 0x%.8x", \
             __FILE__, __LINE__, errCode); \
         err = (errCode); \
         goto cleanUp; \
diff --git a/frameworks/videoedit/stagefrightshells/VideoEditorVideoEncoder.cpp b/frameworks/videoedit/stagefrightshells/VideoEditorVideoEncoder.cpp
index e22075e..54bfa7d 100644
--- a/frameworks/videoedit/stagefrightshells/VideoEditorVideoEncoder.cpp
+++ b/frameworks/videoedit/stagefrightshells/VideoEditorVideoEncoder.cpp
@@ -980,9 +980,9 @@
             // Provide the encoded AU to the writer
             err = VideoEditorVideoEncoder_processOutputBuffer(pEncoderContext,
                 outputBuffer);
+            pEncoderContext->mPuller->putBuffer(outputBuffer);
             VIDEOEDITOR_CHECK(M4NO_ERROR == err, err);
 
-            pEncoderContext->mPuller->putBuffer(outputBuffer);
         }
     }
 
@@ -1059,9 +1059,9 @@
 
             err = VideoEditorVideoEncoder_processOutputBuffer(
                 pEncoderContext, outputBuffer);
+            pEncoderContext->mPuller->putBuffer(outputBuffer);
             VIDEOEDITOR_CHECK(M4NO_ERROR == err, err);
 
-            pEncoderContext->mPuller->putBuffer(outputBuffer);
         }
 
         pEncoderContext->mState = STARTED;