diff options
author | Wu-cheng Li <wuchengli@google.com> | 2010-08-17 15:45:37 -0700 |
---|---|---|
committer | Wu-cheng Li <wuchengli@google.com> | 2010-08-19 21:44:06 -0700 |
commit | e7044384b24051c9ac1ceef951beb97bbf8cf0f3 (patch) | |
tree | b91aefc34bc41e167480c6f9cb2c1de3743fafd0 /services/camera/libcameraservice/CameraService.cpp | |
parent | eba1274978911ea188eead128645299669d02f60 (diff) | |
download | frameworks_base-e7044384b24051c9ac1ceef951beb97bbf8cf0f3.zip frameworks_base-e7044384b24051c9ac1ceef951beb97bbf8cf0f3.tar.gz frameworks_base-e7044384b24051c9ac1ceef951beb97bbf8cf0f3.tar.bz2 |
Handle the camera open failure better.
Check if camera hardware is NULL to avoid mediaserver crash.
Change-Id: Ibde0251f30bdb6b36a5d5380222d7be25ec9449c
Diffstat (limited to 'services/camera/libcameraservice/CameraService.cpp')
-rw-r--r-- | services/camera/libcameraservice/CameraService.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp index 3b3904a..ea2c5d4 100644 --- a/services/camera/libcameraservice/CameraService.cpp +++ b/services/camera/libcameraservice/CameraService.cpp @@ -145,7 +145,12 @@ sp<ICamera> CameraService::connect( return NULL; } - client = new Client(this, cameraClient, cameraId, callingPid); + sp<CameraHardwareInterface> hardware = HAL_openCameraHardware(cameraId); + if (hardware == NULL) { + LOGE("Fail to open camera hardware (id=%d)", cameraId); + return NULL; + } + client = new Client(this, cameraClient, hardware, cameraId, callingPid); mClient[cameraId] = client; LOG1("CameraService::connect X"); return client; @@ -285,16 +290,17 @@ void CameraService::playSound(sound_kind kind) { // ---------------------------------------------------------------------------- CameraService::Client::Client(const sp<CameraService>& cameraService, - const sp<ICameraClient>& cameraClient, int cameraId, int clientPid) { + const sp<ICameraClient>& cameraClient, + const sp<CameraHardwareInterface>& hardware, + int cameraId, int clientPid) { int callingPid = getCallingPid(); LOG1("Client::Client E (pid %d)", callingPid); mCameraService = cameraService; mCameraClient = cameraClient; + mHardware = hardware; mCameraId = cameraId; mClientPid = clientPid; - - mHardware = HAL_openCameraHardware(cameraId); mUseOverlay = mHardware->useOverlay(); mMsgEnabled = 0; |