am 271c1bfd
: Merge "Handle the camera open failure better." into gingerbread
Merge commit '271c1bfd60eaa20c3f37e685864d992e0770ac00' into gingerbread-plus-aosp * commit '271c1bfd60eaa20c3f37e685864d992e0770ac00': Handle the camera open failure better.
This commit is contained in:
@ -221,6 +221,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
extern "C" int HAL_getNumberOfCameras();
|
extern "C" int HAL_getNumberOfCameras();
|
||||||
extern "C" void HAL_getCameraInfo(int cameraId, struct CameraInfo* cameraInfo);
|
extern "C" void HAL_getCameraInfo(int cameraId, struct CameraInfo* cameraInfo);
|
||||||
|
/* HAL should return NULL if it fails to open camera hardware. */
|
||||||
extern "C" sp<CameraHardwareInterface> HAL_openCameraHardware(int cameraId);
|
extern "C" sp<CameraHardwareInterface> HAL_openCameraHardware(int cameraId);
|
||||||
|
|
||||||
}; // namespace android
|
}; // namespace android
|
||||||
|
@ -145,7 +145,12 @@ sp<ICamera> CameraService::connect(
|
|||||||
return NULL;
|
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;
|
mClient[cameraId] = client;
|
||||||
LOG1("CameraService::connect X");
|
LOG1("CameraService::connect X");
|
||||||
return client;
|
return client;
|
||||||
@ -285,16 +290,17 @@ void CameraService::playSound(sound_kind kind) {
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
CameraService::Client::Client(const sp<CameraService>& cameraService,
|
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();
|
int callingPid = getCallingPid();
|
||||||
LOG1("Client::Client E (pid %d)", callingPid);
|
LOG1("Client::Client E (pid %d)", callingPid);
|
||||||
|
|
||||||
mCameraService = cameraService;
|
mCameraService = cameraService;
|
||||||
mCameraClient = cameraClient;
|
mCameraClient = cameraClient;
|
||||||
|
mHardware = hardware;
|
||||||
mCameraId = cameraId;
|
mCameraId = cameraId;
|
||||||
mClientPid = clientPid;
|
mClientPid = clientPid;
|
||||||
|
|
||||||
mHardware = HAL_openCameraHardware(cameraId);
|
|
||||||
mUseOverlay = mHardware->useOverlay();
|
mUseOverlay = mHardware->useOverlay();
|
||||||
mMsgEnabled = 0;
|
mMsgEnabled = 0;
|
||||||
|
|
||||||
|
@ -106,6 +106,7 @@ private:
|
|||||||
friend class CameraService;
|
friend class CameraService;
|
||||||
Client(const sp<CameraService>& cameraService,
|
Client(const sp<CameraService>& cameraService,
|
||||||
const sp<ICameraClient>& cameraClient,
|
const sp<ICameraClient>& cameraClient,
|
||||||
|
const sp<CameraHardwareInterface>& hardware,
|
||||||
int cameraId,
|
int cameraId,
|
||||||
int clientPid);
|
int clientPid);
|
||||||
~Client();
|
~Client();
|
||||||
|
Reference in New Issue
Block a user