Loading include/camera/Camera.h +5 −0 Original line number Diff line number Diff line Loading @@ -82,6 +82,11 @@ enum { CAMERA_CMD_START_SMOOTH_ZOOM = 1, CAMERA_CMD_STOP_SMOOTH_ZOOM = 2, CAMERA_CMD_SET_DISPLAY_ORIENTATION = 3, // cmdType to disable/enable shutter sound. // In sendCommand passing arg1 = 0 will disable, // while passing arg1 = 1 will enable the shutter sound. CAMERA_CMD_ENABLE_SHUTTER_SOUND = 4, }; // camera fatal errors Loading services/camera/libcameraservice/CameraService.cpp +46 −1 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ #include <binder/MemoryBase.h> #include <binder/MemoryHeapBase.h> #include <cutils/atomic.h> #include <cutils/properties.h> #include <hardware/hardware.h> #include <media/AudioSystem.h> #include <media/mediaplayer.h> Loading Loading @@ -319,6 +320,7 @@ CameraService::Client::Client(const sp<CameraService>& cameraService, // Callback is disabled by default mPreviewCallbackFlag = FRAME_CALLBACK_FLAG_NOOP; mOrientation = 0; mPlayShutterSound = true; cameraService->setCameraBusy(cameraId); cameraService->loadSound(); LOG1("Client::Client X (pid %d)", callingPid); Loading Loading @@ -769,6 +771,35 @@ String8 CameraService::Client::getParameters() const { return params; } // enable shutter sound status_t CameraService::Client::enableShutterSound(bool enable) { LOG1("enableShutterSound (pid %d)", getCallingPid()); status_t result = checkPidAndHardware(); if (result != NO_ERROR) return result; if (enable) { mPlayShutterSound = true; return OK; } // Disabling shutter sound may not be allowed. In that case only // allow the mediaserver process to disable the sound. char value[PROPERTY_VALUE_MAX]; property_get("ro.camera.sound.forced", value, "0"); if (strcmp(value, "0") != 0) { // Disabling shutter sound is not allowed. Deny if the current // process is not mediaserver. if (getCallingPid() != getpid()) { LOGE("Failed to disable shutter sound. Permission denied (pid %d)", getCallingPid()); return PERMISSION_DENIED; } } mPlayShutterSound = false; return OK; } status_t CameraService::Client::sendCommand(int32_t cmd, int32_t arg1, int32_t arg2) { LOG1("sendCommand (pid %d)", getCallingPid()); Mutex::Autolock lock(mLock); Loading Loading @@ -797,6 +828,18 @@ status_t CameraService::Client::sendCommand(int32_t cmd, int32_t arg1, int32_t a return BAD_VALUE; } return OK; } else if (cmd == CAMERA_CMD_ENABLE_SHUTTER_SOUND) { switch (arg1) { case 0: enableShutterSound(false); break; case 1: enableShutterSound(true); break; default: return BAD_VALUE; } return OK; } return mHardware->sendCommand(cmd, arg1, arg2); Loading Loading @@ -957,7 +1000,9 @@ void CameraService::Client::dataCallbackTimestamp(nsecs_t timestamp, // "size" is the width and height of yuv picture for registerBuffer. // If it is NULL, use the picture size from parameters. void CameraService::Client::handleShutter(image_rect_type *size) { if (mPlayShutterSound) { mCameraService->playSound(SOUND_SHUTTER); } sp<ICameraClient> c = mCameraClient; if (c != 0) { Loading services/camera/libcameraservice/CameraService.h +4 −0 Original line number Diff line number Diff line Loading @@ -138,6 +138,9 @@ private: status_t startPreviewMode(); status_t startRecordingMode(); // internal function used by sendCommand to enable/disable shutter sound. status_t enableShutterSound(bool enable); // these are static callback functions static void notifyCallback(int32_t msgType, int32_t ext1, int32_t ext2, void* user); static void dataCallback(int32_t msgType, const sp<IMemory>& dataPtr, void* user); Loading Loading @@ -171,6 +174,7 @@ private: int mOverlayH; int mPreviewCallbackFlag; int mOrientation; bool mPlayShutterSound; // Ensures atomicity among the public methods mutable Mutex mLock; Loading Loading
include/camera/Camera.h +5 −0 Original line number Diff line number Diff line Loading @@ -82,6 +82,11 @@ enum { CAMERA_CMD_START_SMOOTH_ZOOM = 1, CAMERA_CMD_STOP_SMOOTH_ZOOM = 2, CAMERA_CMD_SET_DISPLAY_ORIENTATION = 3, // cmdType to disable/enable shutter sound. // In sendCommand passing arg1 = 0 will disable, // while passing arg1 = 1 will enable the shutter sound. CAMERA_CMD_ENABLE_SHUTTER_SOUND = 4, }; // camera fatal errors Loading
services/camera/libcameraservice/CameraService.cpp +46 −1 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ #include <binder/MemoryBase.h> #include <binder/MemoryHeapBase.h> #include <cutils/atomic.h> #include <cutils/properties.h> #include <hardware/hardware.h> #include <media/AudioSystem.h> #include <media/mediaplayer.h> Loading Loading @@ -319,6 +320,7 @@ CameraService::Client::Client(const sp<CameraService>& cameraService, // Callback is disabled by default mPreviewCallbackFlag = FRAME_CALLBACK_FLAG_NOOP; mOrientation = 0; mPlayShutterSound = true; cameraService->setCameraBusy(cameraId); cameraService->loadSound(); LOG1("Client::Client X (pid %d)", callingPid); Loading Loading @@ -769,6 +771,35 @@ String8 CameraService::Client::getParameters() const { return params; } // enable shutter sound status_t CameraService::Client::enableShutterSound(bool enable) { LOG1("enableShutterSound (pid %d)", getCallingPid()); status_t result = checkPidAndHardware(); if (result != NO_ERROR) return result; if (enable) { mPlayShutterSound = true; return OK; } // Disabling shutter sound may not be allowed. In that case only // allow the mediaserver process to disable the sound. char value[PROPERTY_VALUE_MAX]; property_get("ro.camera.sound.forced", value, "0"); if (strcmp(value, "0") != 0) { // Disabling shutter sound is not allowed. Deny if the current // process is not mediaserver. if (getCallingPid() != getpid()) { LOGE("Failed to disable shutter sound. Permission denied (pid %d)", getCallingPid()); return PERMISSION_DENIED; } } mPlayShutterSound = false; return OK; } status_t CameraService::Client::sendCommand(int32_t cmd, int32_t arg1, int32_t arg2) { LOG1("sendCommand (pid %d)", getCallingPid()); Mutex::Autolock lock(mLock); Loading Loading @@ -797,6 +828,18 @@ status_t CameraService::Client::sendCommand(int32_t cmd, int32_t arg1, int32_t a return BAD_VALUE; } return OK; } else if (cmd == CAMERA_CMD_ENABLE_SHUTTER_SOUND) { switch (arg1) { case 0: enableShutterSound(false); break; case 1: enableShutterSound(true); break; default: return BAD_VALUE; } return OK; } return mHardware->sendCommand(cmd, arg1, arg2); Loading Loading @@ -957,7 +1000,9 @@ void CameraService::Client::dataCallbackTimestamp(nsecs_t timestamp, // "size" is the width and height of yuv picture for registerBuffer. // If it is NULL, use the picture size from parameters. void CameraService::Client::handleShutter(image_rect_type *size) { if (mPlayShutterSound) { mCameraService->playSound(SOUND_SHUTTER); } sp<ICameraClient> c = mCameraClient; if (c != 0) { Loading
services/camera/libcameraservice/CameraService.h +4 −0 Original line number Diff line number Diff line Loading @@ -138,6 +138,9 @@ private: status_t startPreviewMode(); status_t startRecordingMode(); // internal function used by sendCommand to enable/disable shutter sound. status_t enableShutterSound(bool enable); // these are static callback functions static void notifyCallback(int32_t msgType, int32_t ext1, int32_t ext2, void* user); static void dataCallback(int32_t msgType, const sp<IMemory>& dataPtr, void* user); Loading Loading @@ -171,6 +174,7 @@ private: int mOverlayH; int mPreviewCallbackFlag; int mOrientation; bool mPlayShutterSound; // Ensures atomicity among the public methods mutable Mutex mLock; Loading