summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/VideoCamera.java
diff options
context:
space:
mode:
authorWu-cheng Li <wuchengli@google.com>2009-09-15 18:52:25 +0800
committerWu-cheng Li <wuchengli@google.com>2009-09-15 19:57:15 +0800
commitffde05cfdec09c6d04fe923b40e4a5436714ddca (patch)
treebf1e05165858fd4ac4bb0c97bda87480e66dbb0f /src/com/android/camera/VideoCamera.java
parent2dabc27c42bbfeb65cd1e8b5ee1248a8bf10ee0a (diff)
downloadLegacyCamera-ffde05cfdec09c6d04fe923b40e4a5436714ddca.zip
LegacyCamera-ffde05cfdec09c6d04fe923b40e4a5436714ddca.tar.gz
LegacyCamera-ffde05cfdec09c6d04fe923b40e4a5436714ddca.tar.bz2
Restart preview if preview size is changed in camcorder.
Diffstat (limited to 'src/com/android/camera/VideoCamera.java')
-rw-r--r--src/com/android/camera/VideoCamera.java26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/com/android/camera/VideoCamera.java b/src/com/android/camera/VideoCamera.java
index 74effc2..7bdc302 100644
--- a/src/com/android/camera/VideoCamera.java
+++ b/src/com/android/camera/VideoCamera.java
@@ -29,6 +29,7 @@ import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
+import android.hardware.Camera.Size;
import android.hardware.Camera.Parameters;
import android.media.MediaRecorder;
import android.net.Uri;
@@ -1363,6 +1364,7 @@ public class VideoCamera extends Activity implements View.OnClickListener,
getString(R.string.pref_camera_coloreffect_default));
mParameters.setColorEffect(colorEffect);
}
+
mCameraDevice.setParameters(mParameters);
}
@@ -1388,12 +1390,26 @@ public class VideoCamera extends Activity implements View.OnClickListener,
// startPreview().
if (mCameraDevice == null) return;
- // we need lock the camera device before writing parameters
- if (mCameraDevice.lock() == 0) {
- setCameraParameters();
- mCameraDevice.unlock();
+ // We need to restart the preview if preview size is changed.
+ Size size = mParameters.getPreviewSize();
+ if (size.width != mProfile.mVideoWidth
+ || size.height != mProfile.mVideoHeight) {
+ // It is assumed media recorder is released before
+ // onSharedPreferenceChanged, so we can close the camera here.
+ closeCamera();
+ try {
+ startPreview(); // Parameters will be set in startPreview().
+ } catch (CameraHardwareException e) {
+ showCameraBusyAndFinish();
+ }
} else {
- Log.e(TAG, "unable to lock camera to set parameters");
+ // we need lock the camera device before writing parameters
+ if (mCameraDevice.lock() == 0) {
+ setCameraParameters();
+ mCameraDevice.unlock();
+ } else {
+ Log.e(TAG, "unable to lock camera to set parameters");
+ }
}
}
}