diff options
author | Wu-cheng Li <wuchengli@google.com> | 2011-11-18 18:28:09 +0800 |
---|---|---|
committer | Wu-cheng Li <wuchengli@google.com> | 2011-11-18 18:55:15 +0800 |
commit | 90089f9eddde732725c43dcad07f4567ed8cb776 (patch) | |
tree | 81e3f318ebbd42199aa9bca72c56dd0276b7b004 /src/com/android | |
parent | 13c101cf7829c98da4341a39ecc142afc024cdb7 (diff) | |
download | LegacyCamera-90089f9eddde732725c43dcad07f4567ed8cb776.zip LegacyCamera-90089f9eddde732725c43dcad07f4567ed8cb776.tar.gz LegacyCamera-90089f9eddde732725c43dcad07f4567ed8cb776.tar.bz2 |
Update camera sound API.
bug:5640219
Change-Id: Ic3af6527f3025ec04ba4be16b621b462f89953f1
Diffstat (limited to 'src/com/android')
-rw-r--r-- | src/com/android/camera/Camera.java | 7 | ||||
-rw-r--r-- | src/com/android/camera/EffectsRecorder.java | 8 | ||||
-rw-r--r-- | src/com/android/camera/FocusManager.java | 4 | ||||
-rwxr-xr-x | src/com/android/camera/panorama/PanoramaActivity.java | 10 |
4 files changed, 21 insertions, 8 deletions
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java index 6bded2c..5a1beb6 100644 --- a/src/com/android/camera/Camera.java +++ b/src/com/android/camera/Camera.java @@ -42,6 +42,7 @@ import android.hardware.Camera.FaceDetectionListener; import android.hardware.Camera.Parameters; import android.hardware.Camera.PictureCallback; import android.hardware.Camera.Size; +import android.hardware.CameraSound; import android.location.Location; import android.media.CameraProfile; import android.net.Uri; @@ -182,6 +183,8 @@ public class Camera extends ActivityBase implements FocusManager.Listener, // generating thumbnails. This reduces the shot-to-shot time. private ImageSaver mImageSaver; + private CameraSound mCameraSound; + private Runnable mDoSnapRunnable = new Runnable() { public void run() { onShutterButtonClick(); @@ -1062,7 +1065,7 @@ public class Camera extends ActivityBase implements FocusManager.Listener, @Override public void playSound(int soundId) { - mCameraDevice.playSound(soundId); + mCameraSound.playSound(soundId); } private boolean saveDataToFile(String filePath, byte[] data) { @@ -1200,6 +1203,7 @@ public class Camera extends ActivityBase implements FocusManager.Listener, // Do this after starting preview because it depends on camera // parameters. initializeIndicatorControl(); + mCameraSound = new CameraSound(); // Make sure preview is started. try { @@ -1571,6 +1575,7 @@ public class Camera extends ActivityBase implements FocusManager.Listener, stopPreview(); // Close the camera now because other activities may need to use it. closeCamera(); + mCameraSound.release(); resetScreenOn(); // Clear UI. diff --git a/src/com/android/camera/EffectsRecorder.java b/src/com/android/camera/EffectsRecorder.java index 3d2aebf..b649bc2 100644 --- a/src/com/android/camera/EffectsRecorder.java +++ b/src/com/android/camera/EffectsRecorder.java @@ -32,6 +32,7 @@ import android.filterpacks.videosrc.SurfaceTextureSource.SurfaceTextureSourceLis import android.graphics.SurfaceTexture; import android.hardware.Camera; +import android.hardware.CameraSound; import android.media.MediaRecorder; import android.media.CamcorderProfile; import android.os.Handler; @@ -117,6 +118,7 @@ public class EffectsRecorder { private boolean mLogVerbose = Log.isLoggable(TAG, Log.VERBOSE); private static final String TAG = "effectsrecorder"; + private CameraSound mCameraSound; /** Determine if a given effect is supported at runtime * Some effects require libraries not available on all devices @@ -136,6 +138,7 @@ public class EffectsRecorder { if (mLogVerbose) Log.v(TAG, "EffectsRecorder created (" + this + ")"); mContext = context; mHandler = new Handler(Looper.getMainLooper()); + mCameraSound = new CameraSound(); } public void setCamera(Camera cameraDevice) { @@ -690,7 +693,7 @@ public class EffectsRecorder { recorder.setInputValue("maxFileSize", mMaxFileSize); recorder.setInputValue("maxDurationMs", mMaxDurationMs); recorder.setInputValue("recording", true); - mCameraDevice.playSound(Camera.Sound.START_VIDEO_RECORDING); + mCameraSound.playSound(CameraSound.START_VIDEO_RECORDING); mState = STATE_RECORD; } @@ -710,7 +713,7 @@ public class EffectsRecorder { } Filter recorder = mRunner.getGraph().getFilter("recorder"); recorder.setInputValue("recording", false); - mCameraDevice.playSound(Camera.Sound.STOP_VIDEO_RECORDING); + mCameraSound.playSound(CameraSound.STOP_VIDEO_RECORDING); mState = STATE_PREVIEW; } @@ -740,6 +743,7 @@ public class EffectsRecorder { } catch(IOException e) { throw new RuntimeException("Unable to connect camera to effect input", e); } + mCameraSound.release(); mState = STATE_CONFIGURE; mOldRunner = mRunner; diff --git a/src/com/android/camera/FocusManager.java b/src/com/android/camera/FocusManager.java index 8c3f14d..72a0919 100644 --- a/src/com/android/camera/FocusManager.java +++ b/src/com/android/camera/FocusManager.java @@ -26,7 +26,7 @@ import android.graphics.Rect; import android.graphics.RectF; import android.hardware.Camera.Area; import android.hardware.Camera.Parameters; -import android.hardware.Camera.Sound; +import android.hardware.CameraSound; import android.os.Handler; import android.os.Message; import android.util.Log; @@ -224,7 +224,7 @@ public class FocusManager { // so the state is always STATE_FOCUSING. if (!Parameters.FOCUS_MODE_CONTINUOUS_PICTURE. equals(mFocusMode)) { - mListener.playSound(Sound.FOCUS_COMPLETE); + mListener.playSound(CameraSound.FOCUS_COMPLETE); } } else { mState = STATE_FAIL; diff --git a/src/com/android/camera/panorama/PanoramaActivity.java b/src/com/android/camera/panorama/PanoramaActivity.java index 69fcc83..d446e41 100755 --- a/src/com/android/camera/panorama/PanoramaActivity.java +++ b/src/com/android/camera/panorama/PanoramaActivity.java @@ -49,7 +49,7 @@ import android.graphics.SurfaceTexture; import android.graphics.YuvImage; import android.hardware.Camera.Parameters; import android.hardware.Camera.Size; -import android.hardware.Camera.Sound; +import android.hardware.CameraSound; import android.hardware.Sensor; import android.hardware.SensorManager; import android.media.ExifInterface; @@ -176,6 +176,8 @@ public class PanoramaActivity extends ActivityBase implements private RotateDialogController mRotateDialog; + private CameraSound mCameraSound; + private class MosaicJpeg { public MosaicJpeg(byte[] data, int width, int height) { this.data = data; @@ -271,6 +273,7 @@ public class PanoramaActivity extends ActivityBase implements mDialogOkString = getResources().getString(R.string.dialog_ok); mDialogPanoramaFailedString = getResources().getString(R.string.pano_dialog_panorama_failed); + mCameraSound = new CameraSound(); mMainHandler = new Handler() { @Override @@ -733,11 +736,11 @@ public class PanoramaActivity extends ActivityBase implements // right now. switch (mCaptureState) { case CAPTURE_STATE_VIEWFINDER: - mCameraDevice.playSound(Sound.START_VIDEO_RECORDING); + mCameraSound.playSound(CameraSound.START_VIDEO_RECORDING); startCapture(); break; case CAPTURE_STATE_MOSAIC: - mCameraDevice.playSound(Sound.STOP_VIDEO_RECORDING); + mCameraSound.playSound(CameraSound.STOP_VIDEO_RECORDING); stopCapture(false); } } @@ -977,6 +980,7 @@ public class PanoramaActivity extends ActivityBase implements clearMosaicFrameProcessorIfNeeded(); mOrientationEventListener.disable(); resetScreenOn(); + mCameraSound.release(); System.gc(); } |