From 904d5069547dcb6a90175558ba3c608f0465d1eb Mon Sep 17 00:00:00 2001 From: Byunghun Jeon Date: Tue, 26 Jul 2016 16:05:33 -0700 Subject: SnapdragonCamera: Add shutter sound to camera2 Add shutter sound menu to settings and allow user to turn on/off shutter sound in camera2 mode CRs-Fixed: 1050117 Change-Id: I624f28428415b8dde7da6e4908c26dd59bb3fbdb --- src/com/android/camera/CaptureModule.java | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/com/android/camera/CaptureModule.java') diff --git a/src/com/android/camera/CaptureModule.java b/src/com/android/camera/CaptureModule.java index b33cb361f..1a7811000 100644 --- a/src/com/android/camera/CaptureModule.java +++ b/src/com/android/camera/CaptureModule.java @@ -52,6 +52,7 @@ import android.media.CamcorderProfile; import android.media.CameraProfile; import android.media.Image; import android.media.ImageReader; +import android.media.MediaActionSound; import android.media.MediaMetadataRetriever; import android.media.MediaRecorder; import android.net.Uri; @@ -278,6 +279,8 @@ public class CaptureModule implements CameraModule, PhotoController, private static final int SELFIE_FLASH_DURATION = 680; + private MediaActionSound mSound; + private class SelfieThread extends Thread { public void run() { try { @@ -1061,6 +1064,7 @@ public class CaptureModule implements CameraModule, PhotoController, warningToast("Camera is not ready yet to take a picture."); return; } + checkAndPlayShutterSound(id); final boolean csEnabled = isClearSightOn(); CaptureRequest.Builder captureBuilder; @@ -1187,6 +1191,7 @@ public class CaptureModule implements CameraModule, PhotoController, warningToast("Camera is not ready yet to take a video snapshot."); return; } + checkAndPlayShutterSound(id); CaptureRequest.Builder captureBuilder = mCameraDevice[id].createCaptureRequest(CameraDevice.TEMPLATE_VIDEO_SNAPSHOT); @@ -1623,6 +1628,10 @@ public class CaptureModule implements CameraModule, PhotoController, if (mIsRecordingVideo) { stopRecordingVideo(getMainCameraId()); } + if (mSound != null) { + mSound.release(); + mSound = null; + } if (selfieThread != null) { selfieThread.interrupt(); } @@ -1754,6 +1763,11 @@ public class CaptureModule implements CameraModule, PhotoController, mUI.showSurfaceView(); mUI.setSwitcherIndex(); mCameraIdList = new ArrayList<>(); + + if (mSound == null) { + mSound = new MediaActionSound(); + } + if(mPostProcessor != null) { String scene = mSettingsManager.getValue(SettingsManager.KEY_SCENE_MODE); if (scene != null) { @@ -3011,6 +3025,15 @@ public class CaptureModule implements CameraModule, PhotoController, } } + private void checkAndPlayShutterSound(int id) { + if (id == getMainCameraId()) { + String value = mSettingsManager.getValue(SettingsManager.KEY_SHUTTER_SOUND); + if (value != null && value.equals("on")) { + mSound.play(MediaActionSound.SHUTTER_CLICK); + } + } + } + private Surface getPreviewSurfaceForSession(int id) { if (isBackCamera()) { if (getCameraMode() == DUAL_MODE && id == MONO_ID) { -- cgit v1.2.3