am 7d4acc53: am 69e2ef47: Merge change I9f93ce61 into eclair

Merge commit '7d4acc5316c080d8e9787d2a7c84e2a2500b85f8' into eclair-mr2-plus-aosp

* commit '7d4acc5316c080d8e9787d2a7c84e2a2500b85f8':
  Throttle camera preview frames to the app. Bug 2180302.
This commit is contained in:
Dave Sparks
2009-10-13 10:03:33 -07:00
committed by Android Git Automerger

View File

@@ -229,7 +229,9 @@ public class Camera {
public final void setPreviewCallback(PreviewCallback cb) {
mPreviewCallback = cb;
mOneShot = false;
setHasPreviewCallback(cb != null, false);
// Always use one-shot mode. We fake camera preview mode by
// doing one-shot preview continuously.
setHasPreviewCallback(cb != null, true);
}
/**
@@ -280,10 +282,19 @@ public class Camera {
case CAMERA_MSG_PREVIEW_FRAME:
if (mPreviewCallback != null) {
mPreviewCallback.onPreviewFrame((byte[])msg.obj, mCamera);
PreviewCallback cb = mPreviewCallback;
if (mOneShot) {
// Clear the callback variable before the callback
// in case the app calls setPreviewCallback from
// the callback function
mPreviewCallback = null;
} else {
// We're faking the camera preview mode to prevent
// the app from being flooded with preview frames.
// Set to oneshot mode again.
setHasPreviewCallback(true, true);
}
cb.onPreviewFrame((byte[])msg.obj, mCamera);
}
return;