From 26b224dd3b4391dbbb8ee6ed35c40c431bdbec85 Mon Sep 17 00:00:00 2001 From: Alan Newberger Date: Tue, 26 Aug 2014 18:18:48 -0700 Subject: Protect video recording callback from activity/module pauses This CL should eliminate MediaRecorder start exceptions, which appear to be due to ending the camera or switching the module. Storage I/O could take a while during which pauses can occur, so we check for them and avoid starting video in that case. Bug: 16298718 Change-Id: I9abca815400e9ce545fed96f6e31cb792860a1d0 --- src/com/android/camera/CameraActivity.java | 6 +++++- src/com/android/camera/VideoModule.java | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java index af448f498..6772aae12 100644 --- a/src/com/android/camera/CameraActivity.java +++ b/src/com/android/camera/CameraActivity.java @@ -2008,8 +2008,12 @@ public class CameraActivity extends Activity @Override protected void onPostExecute(Long bytes) { updateStorageHint(bytes); - if (callback != null) { + // This callback returns after I/O to check disk, so we could be + // pausing and shutting down. If so, don't bother invoking. + if (callback != null && !mPaused) { callback.onStorageUpdateDone(bytes); + } else { + Log.v(TAG, "ignoring storage callback after activity pause"); } } }).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); diff --git a/src/com/android/camera/VideoModule.java b/src/com/android/camera/VideoModule.java index 27c9cdba7..4e9238598 100644 --- a/src/com/android/camera/VideoModule.java +++ b/src/com/android/camera/VideoModule.java @@ -1311,6 +1311,10 @@ public class VideoModule extends CameraModule } else { //?? //if (!mCameraDevice.waitDone()) return; + if (mPaused == true) { + Log.v(TAG, "in storage callback after module paused"); + return; + } mCurrentVideoUri = null; initializeRecorder(); -- cgit v1.2.3