Skip to content
This repository has been archived by the owner on Nov 15, 2022. It is now read-only.

Commit

Permalink
Merge "Update camera sound API." into ics-mr1
Browse files Browse the repository at this point in the history
  • Loading branch information
Wu-cheng Li authored and Android (Google) Code Review committed Nov 22, 2011
2 parents dd615d6 + 90089f9 commit 27e33de
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
7 changes: 6 additions & 1 deletion src/com/android/camera/Camera.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -1062,7 +1065,7 @@ public void setFocusParameters() {

@Override
public void playSound(int soundId) {
mCameraDevice.playSound(soundId);
mCameraSound.playSound(soundId);
}

private boolean saveDataToFile(String filePath, byte[] data) {
Expand Down Expand Up @@ -1200,6 +1203,7 @@ public void onCreate(Bundle icicle) {
// Do this after starting preview because it depends on camera
// parameters.
initializeIndicatorControl();
mCameraSound = new CameraSound();

// Make sure preview is started.
try {
Expand Down Expand Up @@ -1571,6 +1575,7 @@ protected void onPause() {
stopPreview();
// Close the camera now because other activities may need to use it.
closeCamera();
mCameraSound.release();
resetScreenOn();

// Clear UI.
Expand Down
8 changes: 6 additions & 2 deletions src/com/android/camera/EffectsRecorder.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

import android.graphics.SurfaceTexture;
import android.hardware.Camera;
import android.hardware.CameraSound;
import android.media.MediaRecorder;
import android.media.CamcorderProfile;
import android.os.Handler;
Expand Down Expand Up @@ -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
Expand All @@ -136,6 +138,7 @@ public EffectsRecorder(Context context) {
if (mLogVerbose) Log.v(TAG, "EffectsRecorder created (" + this + ")");
mContext = context;
mHandler = new Handler(Looper.getMainLooper());
mCameraSound = new CameraSound();
}

public void setCamera(Camera cameraDevice) {
Expand Down Expand Up @@ -690,7 +693,7 @@ public synchronized void startRecording() {
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;
}

Expand All @@ -710,7 +713,7 @@ public synchronized void stopRecording() {
}
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;
}

Expand Down Expand Up @@ -740,6 +743,7 @@ public synchronized void stopPreview() {
} catch(IOException e) {
throw new RuntimeException("Unable to connect camera to effect input", e);
}
mCameraSound.release();

mState = STATE_CONFIGURE;
mOldRunner = mRunner;
Expand Down
4 changes: 2 additions & 2 deletions src/com/android/camera/FocusManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
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;
Expand Down Expand Up @@ -224,7 +224,7 @@ public void onAutoFocus(boolean focused) {
// 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;
Expand Down
10 changes: 7 additions & 3 deletions src/com/android/camera/panorama/PanoramaActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -271,6 +273,7 @@ public void onCreate(Bundle icicle) {
mDialogOkString = getResources().getString(R.string.dialog_ok);
mDialogPanoramaFailedString =
getResources().getString(R.string.pano_dialog_panorama_failed);
mCameraSound = new CameraSound();

mMainHandler = new Handler() {
@Override
Expand Down Expand Up @@ -733,11 +736,11 @@ public void onShutterButtonClick() {
// 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);
}
}
Expand Down Expand Up @@ -977,6 +980,7 @@ protected void onPause() {
clearMosaicFrameProcessorIfNeeded();
mOrientationEventListener.disable();
resetScreenOn();
mCameraSound.release();
System.gc();
}

Expand Down

0 comments on commit 27e33de

Please sign in to comment.