summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/VideoModule.java
diff options
context:
space:
mode:
authorSpike Sprague <spikuru@google.com>2014-04-25 17:24:32 -0700
committerSpike Sprague <spikuru@google.com>2014-04-29 17:32:32 -0700
commite6374b76bd10c7e9120b8530b2dae0f4b321ceea (patch)
tree8efe1a159cb65c06c5e14c659455efe5ef9af359 /src/com/android/camera/VideoModule.java
parenteaaf29303c48c2befe216151bf9bedc008a1b616 (diff)
downloadandroid_packages_apps_Camera2-e6374b76bd10c7e9120b8530b2dae0f4b321ceea.tar.gz
android_packages_apps_Camera2-e6374b76bd10c7e9120b8530b2dae0f4b321ceea.tar.bz2
android_packages_apps_Camera2-e6374b76bd10c7e9120b8530b2dae0f4b321ceea.zip
fix free space calculation / querying timing problem
also, be (a little) more agressive about updating available storage space so app generally has the most up-to-date space calculation more often bug: 14275001 Change-Id: I1aa91419be017f1248bb4b3b0aa805bd4e1b05c6
Diffstat (limited to 'src/com/android/camera/VideoModule.java')
-rw-r--r--src/com/android/camera/VideoModule.java113
1 files changed, 62 insertions, 51 deletions
diff --git a/src/com/android/camera/VideoModule.java b/src/com/android/camera/VideoModule.java
index 23a9f5bb6..70cc12ec6 100644
--- a/src/com/android/camera/VideoModule.java
+++ b/src/com/android/camera/VideoModule.java
@@ -329,6 +329,8 @@ public class VideoModule extends CameraModule
SettingsManager settingsManager = mActivity.getSettingsManager();
mCameraId = Integer.parseInt(settingsManager.get(SettingsManager.SETTING_CAMERA_ID));
+ mActivity.updateStorageSpaceAndHint(null);
+
/*
* To reduce startup time, we start the preview in another thread.
* We make sure the preview is started at the end of onCreate.
@@ -352,7 +354,6 @@ public class VideoModule extends CameraModule
mShutterIconId = CameraUtil.getCameraShutterIconId(
mAppController.getCurrentModuleIndex(), mAppController.getAndroidContext());
-
}
@Override
@@ -1192,7 +1193,7 @@ public class VideoModule extends CameraModule
if (what == MediaRecorder.MEDIA_RECORDER_ERROR_UNKNOWN) {
// We may have run out of space on the sdcard.
stopVideoRecording();
- mActivity.updateStorageSpaceAndHint();
+ mActivity.updateStorageSpaceAndHint(null);
}
}
@@ -1235,57 +1236,60 @@ public class VideoModule extends CameraModule
mUI.showFocusUI(false);
mUI.showVideoRecordingHints(false);
- mActivity.updateStorageSpaceAndHint();
- if (mActivity.getStorageSpaceBytes() <= Storage.LOW_STORAGE_THRESHOLD_BYTES) {
- Log.w(TAG, "Storage issue, ignore the start request");
- return;
- }
-
- //??
- //if (!mCameraDevice.waitDone()) return;
- mCurrentVideoUri = null;
-
- initializeRecorder();
- if (mMediaRecorder == null) {
- Log.e(TAG, "Fail to initialize media recorder");
- return;
- }
-
- pauseAudioPlayback();
-
- try {
- mMediaRecorder.start(); // Recording is now started
- } catch (RuntimeException e) {
- Log.e(TAG, "Could not start media recorder. ", e);
- releaseMediaRecorder();
- // If start fails, frameworks will not lock the camera for us.
- mCameraDevice.lock();
- return;
- }
- mAppController.getCameraAppUI().setSwipeEnabled(false);
-
- // The parameters might have been altered by MediaRecorder already.
- // We need to force mCameraDevice to refresh before getting it.
- mCameraDevice.refreshParameters();
- // The parameters may have been changed by MediaRecorder upon starting
- // recording. We need to alter the parameters if we support camcorder
- // zoom. To reduce latency when setting the parameters during zoom, we
- // update mParameters here once.
- mParameters = mCameraDevice.getParameters();
-
- mMediaRecorderRecording = true;
- mActivity.lockOrientation();
- mRecordingStartTime = SystemClock.uptimeMillis();
+ mActivity.updateStorageSpaceAndHint(new CameraActivity.OnStorageUpdateDoneListener() {
+ @Override
+ public void onStorageUpdateDone(long bytes) {
+ if (bytes <= Storage.LOW_STORAGE_THRESHOLD_BYTES) {
+ Log.w(TAG, "Storage issue, ignore the start request");
+ } else {
+ //??
+ //if (!mCameraDevice.waitDone()) return;
+ mCurrentVideoUri = null;
+
+ initializeRecorder();
+ if (mMediaRecorder == null) {
+ Log.e(TAG, "Fail to initialize media recorder");
+ return;
+ }
- // A special case of mode options closing: during capture it should
- // not be possible to change mode state.
- mAppController.getCameraAppUI().hideModeOptions();
- mAppController.getCameraAppUI().animateBottomBarToVideoStop(R.drawable.ic_stop);
- mUI.showRecordingUI(true);
+ pauseAudioPlayback();
- setFocusParameters();
- updateRecordingTime();
- mActivity.enableKeepScreenOn(true);
+ try {
+ mMediaRecorder.start(); // Recording is now started
+ } catch (RuntimeException e) {
+ Log.e(TAG, "Could not start media recorder. ", e);
+ releaseMediaRecorder();
+ // If start fails, frameworks will not lock the camera for us.
+ mCameraDevice.lock();
+ return;
+ }
+ mAppController.getCameraAppUI().setSwipeEnabled(false);
+
+ // The parameters might have been altered by MediaRecorder already.
+ // We need to force mCameraDevice to refresh before getting it.
+ mCameraDevice.refreshParameters();
+ // The parameters may have been changed by MediaRecorder upon starting
+ // recording. We need to alter the parameters if we support camcorder
+ // zoom. To reduce latency when setting the parameters during zoom, we
+ // update mParameters here once.
+ mParameters = mCameraDevice.getParameters();
+
+ mMediaRecorderRecording = true;
+ mActivity.lockOrientation();
+ mRecordingStartTime = SystemClock.uptimeMillis();
+
+ // A special case of mode options closing: during capture it should
+ // not be possible to change mode state.
+ mAppController.getCameraAppUI().hideModeOptions();
+ mAppController.getCameraAppUI().animateBottomBarToVideoStop(R.drawable.ic_stop);
+ mUI.showRecordingUI(true);
+
+ setFocusParameters();
+ updateRecordingTime();
+ mActivity.enableKeepScreenOn(true);
+ }
+ }
+ });
}
private Bitmap getVideoThumbnail() {
@@ -1387,6 +1391,13 @@ public class VideoModule extends CameraModule
// by MediaRecorder.
mParameters = mCameraDevice.getParameters();
}
+
+ // Check this in advance of each shot so we don't add to shutter
+ // latency. It's true that someone else could write to the SD card
+ // in the mean time and fill it, but that could have happened
+ // between the shutter press and saving the file too.
+ mActivity.updateStorageSpaceAndHint(null);
+
return fail;
}