summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWu-cheng Li <wuchengli@google.com>2012-03-14 17:25:57 +0800
committerWu-cheng Li <wuchengli@google.com>2012-03-19 13:54:15 +0800
commitc59d1a8f0ccbf8d95c8f29cfe9d955d081807fc9 (patch)
tree0071f65341c4093d4a969f74ee2bf170d42085d9
parentd85d590ed3624531493d874cdabf4d34a3db922f (diff)
downloadframeworks_base-c59d1a8f0ccbf8d95c8f29cfe9d955d081807fc9.zip
frameworks_base-c59d1a8f0ccbf8d95c8f29cfe9d955d081807fc9.tar.gz
frameworks_base-c59d1a8f0ccbf8d95c8f29cfe9d955d081807fc9.tar.bz2
Do not set camera preview display if the surface is null.
MediaRecorder.setPreviewDisplay() is not required if applications use MediaRecorder.setCamera(). Besides, this causes a problem when apps use Camera.setPreviewTexture. Camera service thinks the surface texture from Camera.setPreviewTexture and the surface from MediaRecorder.setPreviewDisplay are different. bug:5988937 Change-Id: Ia345705b6679ef349db6e354feaa3cc0fe8bcd8c
-rw-r--r--media/java/android/media/MediaRecorder.java8
-rwxr-xr-xmedia/libstagefright/CameraSource.cpp10
2 files changed, 14 insertions, 4 deletions
diff --git a/media/java/android/media/MediaRecorder.java b/media/java/android/media/MediaRecorder.java
index 6319630..31b9143 100644
--- a/media/java/android/media/MediaRecorder.java
+++ b/media/java/android/media/MediaRecorder.java
@@ -124,9 +124,15 @@ public class MediaRecorder
/**
* Sets a Surface to show a preview of recorded media (video). Calls this
* before prepare() to make sure that the desirable preview display is
- * set.
+ * set. If {@link #setCamera(Camera)} is used and the surface has been
+ * already set to the camera, application do not need to call this. If
+ * this is called with non-null surface, the preview surface of the camera
+ * will be replaced by the new surface. If this method is called with null
+ * surface or not called at all, media recorder will not change the preview
+ * surface of the camera.
*
* @param sv the Surface to use for the preview
+ * @see android.hardware.Camera#setPreviewDisplay(android.view.SurfaceHolder)
*/
public void setPreviewDisplay(Surface sv) {
mSurface = sv;
diff --git a/media/libstagefright/CameraSource.cpp b/media/libstagefright/CameraSource.cpp
index 2df5528..3ddad93 100755
--- a/media/libstagefright/CameraSource.cpp
+++ b/media/libstagefright/CameraSource.cpp
@@ -515,9 +515,13 @@ status_t CameraSource::initWithCameraAccess(
return err;
}
- // This CHECK is good, since we just passed the lock/unlock
- // check earlier by calling mCamera->setParameters().
- CHECK_EQ((status_t)OK, mCamera->setPreviewDisplay(mSurface));
+ // Set the preview display. Skip this if mSurface is null because
+ // applications may already set a surface to the camera.
+ if (mSurface != NULL) {
+ // This CHECK is good, since we just passed the lock/unlock
+ // check earlier by calling mCamera->setParameters().
+ CHECK_EQ((status_t)OK, mCamera->setPreviewDisplay(mSurface));
+ }
// By default, do not store metadata in video buffers
mIsMetaDataStoredInVideoBuffers = false;