diff options
author | Byunghun Jeon <bjeon@codeaurora.org> | 2016-07-26 16:05:33 -0700 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2016-08-16 16:14:28 -0700 |
commit | 904d5069547dcb6a90175558ba3c608f0465d1eb (patch) | |
tree | d1a93aa193ad8341232e862f97b14f1a4c15c4cf /src/com/android/camera/CaptureModule.java | |
parent | e379705fbf684da08d1ae3ecb0c49db709deb0b3 (diff) | |
download | android_packages_apps_Snap-904d5069547dcb6a90175558ba3c608f0465d1eb.tar.gz android_packages_apps_Snap-904d5069547dcb6a90175558ba3c608f0465d1eb.tar.bz2 android_packages_apps_Snap-904d5069547dcb6a90175558ba3c608f0465d1eb.zip |
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
Diffstat (limited to 'src/com/android/camera/CaptureModule.java')
-rw-r--r-- | src/com/android/camera/CaptureModule.java | 23 |
1 files changed, 23 insertions, 0 deletions
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) { |