diff options
author | Jason Sams <> | 2009-03-24 20:21:36 -0700 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-24 20:21:36 -0700 |
commit | b18b6910b827356136b91ddc7550b2b6cbdeb2db (patch) | |
tree | bce9a8dc8917ad91ed3789e54fb19d00fc7fdbac /camera | |
parent | 0818aca466719cedcdb7c12bf92dece07f4765c7 (diff) | |
download | frameworks_base-b18b6910b827356136b91ddc7550b2b6cbdeb2db.zip frameworks_base-b18b6910b827356136b91ddc7550b2b6cbdeb2db.tar.gz frameworks_base-b18b6910b827356136b91ddc7550b2b6cbdeb2db.tar.bz2 |
Automated import from //branches/donutburger/...@141469,141469
Diffstat (limited to 'camera')
-rw-r--r-- | camera/libcameraservice/Android.mk | 3 | ||||
-rw-r--r-- | camera/libcameraservice/CameraService.cpp | 30 | ||||
-rw-r--r-- | camera/libcameraservice/CameraService.h | 5 |
3 files changed, 37 insertions, 1 deletions
diff --git a/camera/libcameraservice/Android.mk b/camera/libcameraservice/Android.mk index 2dfe659..96cc512 100644 --- a/camera/libcameraservice/Android.mk +++ b/camera/libcameraservice/Android.mk @@ -42,7 +42,8 @@ LOCAL_SRC_FILES:= \ LOCAL_SHARED_LIBRARIES:= \ libui \ libutils \ - libcutils + libcutils \ + libmedia LOCAL_MODULE:= libcameraservice diff --git a/camera/libcameraservice/CameraService.cpp b/camera/libcameraservice/CameraService.cpp index 15e3b21..851b213 100644 --- a/camera/libcameraservice/CameraService.cpp +++ b/camera/libcameraservice/CameraService.cpp @@ -28,6 +28,8 @@ #include <utils/MemoryHeapBase.h> #include <ui/ICameraService.h> +#include <media/mediaplayer.h> +#include <media/AudioSystem.h> #include "CameraService.h" namespace android { @@ -151,6 +153,19 @@ void CameraService::removeClient(const sp<ICameraClient>& cameraClient) } } +static sp<MediaPlayer> newMediaPlayer(const char *file) +{ + sp<MediaPlayer> mp = new MediaPlayer(); + if (mp->setDataSource(file) == NO_ERROR) { + mp->setAudioStreamType(AudioSystem::ALARM); + mp->prepare(); + } else { + mp.clear(); + LOGE("Failed to load CameraService sounds."); + } + return mp; +} + CameraService::Client::Client(const sp<CameraService>& cameraService, const sp<ICameraClient>& cameraClient, pid_t clientPid) { @@ -161,6 +176,9 @@ CameraService::Client::Client(const sp<CameraService>& cameraService, mHardware = openCameraHardware(); mUseOverlay = mHardware->useOverlay(); + mMediaPlayerClick = newMediaPlayer("/system/media/audio/ui/camera_click.ogg"); + mMediaPlayerBeep = newMediaPlayer("/system/media/audio/ui/VideoRecord.ogg"); + // Callback is disabled by default mPreviewCallbackFlag = FRAME_CALLBACK_FLAG_NOOP; LOGD("Client X constructor"); @@ -265,6 +283,9 @@ CameraService::Client::~Client() #endif } + mMediaPlayerBeep.clear(); + mMediaPlayerClick.clear(); + // make sure we tear down the hardware mClientPid = IPCThreadState::self()->getCallingPid(); disconnect(); @@ -464,6 +485,9 @@ status_t CameraService::Client::startPreview() status_t CameraService::Client::startRecording() { + if (mMediaPlayerBeep.get() != NULL) { + mMediaPlayerBeep->start(); + } return startCameraMode(CAMERA_RECORDING_MODE); } @@ -502,6 +526,9 @@ void CameraService::Client::stopRecording() return; } + if (mMediaPlayerBeep.get() != NULL) { + mMediaPlayerBeep->start(); + } mHardware->stopRecording(); LOGV("stopRecording(), hardware stopped OK"); mPreviewBuffer.clear(); @@ -684,6 +711,9 @@ status_t CameraService::Client::takePicture() return INVALID_OPERATION; } + if (mMediaPlayerClick.get() != NULL) { + mMediaPlayerClick->start(); + } return mHardware->takePicture(shutterCallback, yuvPictureCallback, jpegPictureCallback, diff --git a/camera/libcameraservice/CameraService.h b/camera/libcameraservice/CameraService.h index d9b7927..6752f26 100644 --- a/camera/libcameraservice/CameraService.h +++ b/camera/libcameraservice/CameraService.h @@ -27,6 +27,8 @@ class android::MemoryHeapBase; namespace android { +class MediaPlayer; + // ---------------------------------------------------------------------------- #define LIKELY( exp ) (__builtin_expect( (exp) != 0, true )) @@ -178,6 +180,9 @@ private: sp<MemoryHeapBase> mPreviewBuffer; int mPreviewCallbackFlag; + sp<MediaPlayer> mMediaPlayerClick; + sp<MediaPlayer> mMediaPlayerBeep; + // these are immutable once the object is created, // they don't need to be protected by a lock sp<ICameraClient> mCameraClient; |