diff options
Diffstat (limited to 'services/camera/libcameraservice/common')
4 files changed, 70 insertions, 11 deletions
diff --git a/services/camera/libcameraservice/common/Camera2ClientBase.cpp b/services/camera/libcameraservice/common/Camera2ClientBase.cpp index ba0b264..5732f80 100644 --- a/services/camera/libcameraservice/common/Camera2ClientBase.cpp +++ b/services/camera/libcameraservice/common/Camera2ClientBase.cpp @@ -55,7 +55,8 @@ Camera2ClientBase<TClientBase>::Camera2ClientBase( TClientBase(cameraService, remoteCallback, clientPackageName, cameraId, cameraFacing, clientPid, clientUid, servicePid), mSharedCameraCallbacks(remoteCallback), - mDeviceVersion(cameraService->getDeviceVersion(cameraId)) + mDeviceVersion(cameraService->getDeviceVersion(cameraId)), + mDeviceActive(false) { ALOGI("Camera %d: Opened. Client: %s (PID %d, UID %d)", cameraId, String8(clientPackageName).string(), clientPid, clientUid); @@ -235,6 +236,13 @@ void Camera2ClientBase<TClientBase>::notifyError( template <typename TClientBase> void Camera2ClientBase<TClientBase>::notifyIdle() { + if (mDeviceActive) { + getCameraService()->updateProxyDeviceState( + ICameraServiceProxy::CAMERA_STATE_IDLE, + String8::format("%d", TClientBase::mCameraId)); + } + mDeviceActive = false; + ALOGV("Camera device is now idle"); } @@ -244,6 +252,13 @@ void Camera2ClientBase<TClientBase>::notifyShutter(const CaptureResultExtras& re (void)resultExtras; (void)timestamp; + if (!mDeviceActive) { + getCameraService()->updateProxyDeviceState( + ICameraServiceProxy::CAMERA_STATE_ACTIVE, + String8::format("%d", TClientBase::mCameraId)); + } + mDeviceActive = true; + ALOGV("%s: Shutter notification for request id %" PRId32 " at time %" PRId64, __FUNCTION__, resultExtras.requestId, timestamp); } diff --git a/services/camera/libcameraservice/common/Camera2ClientBase.h b/services/camera/libcameraservice/common/Camera2ClientBase.h index f1cacdf..220c5ad 100644 --- a/services/camera/libcameraservice/common/Camera2ClientBase.h +++ b/services/camera/libcameraservice/common/Camera2ClientBase.h @@ -136,6 +136,8 @@ protected: status_t checkPid(const char *checkLocation) const; virtual void detachDevice(); + + bool mDeviceActive; }; }; // namespace android diff --git a/services/camera/libcameraservice/common/CameraDeviceBase.h b/services/camera/libcameraservice/common/CameraDeviceBase.h index cd25949..7b083a3 100644 --- a/services/camera/libcameraservice/common/CameraDeviceBase.h +++ b/services/camera/libcameraservice/common/CameraDeviceBase.h @@ -294,6 +294,12 @@ class CameraDeviceBase : public virtual RefBase { virtual status_t tearDown(int streamId) = 0; /** + * Prepare stream by preallocating up to maxCount buffers for it asynchronously. + * Calls notifyPrepared() once allocation is complete. + */ + virtual status_t prepare(int maxCount, int streamId) = 0; + + /** * Get the HAL device version. */ virtual uint32_t getDeviceVersion() = 0; diff --git a/services/camera/libcameraservice/common/CameraModule.cpp b/services/camera/libcameraservice/common/CameraModule.cpp index 6a4dfe0..16b8aba 100644 --- a/services/camera/libcameraservice/common/CameraModule.cpp +++ b/services/camera/libcameraservice/common/CameraModule.cpp @@ -15,14 +15,18 @@ */ #define LOG_TAG "CameraModule" +#define ATRACE_TAG ATRACE_TAG_CAMERA //#define LOG_NDEBUG 0 +#include <utils/Trace.h> + #include "CameraModule.h" namespace android { void CameraModule::deriveCameraCharacteristicsKeys( uint32_t deviceVersion, CameraMetadata &chars) { + ATRACE_CALL(); // HAL1 devices should not reach here if (deviceVersion < CAMERA_DEVICE_API_VERSION_2_0) { ALOGV("%s: Cannot derive keys for HAL version < 2.0"); @@ -150,9 +154,7 @@ CameraModule::CameraModule(camera_module_t *module) { ALOGE("%s: camera hardware module must not be null", __FUNCTION__); assert(0); } - mModule = module; - mCameraInfoMap.setCapacity(getNumberOfCameras()); } CameraModule::~CameraModule() @@ -168,14 +170,20 @@ CameraModule::~CameraModule() } int CameraModule::init() { + ATRACE_CALL(); + int res = OK; if (getModuleApiVersion() >= CAMERA_MODULE_API_VERSION_2_4 && mModule->init != NULL) { - return mModule->init(); + ATRACE_BEGIN("camera_module->init"); + res = mModule->init(); + ATRACE_END(); } - return OK; + mCameraInfoMap.setCapacity(getNumberOfCameras()); + return res; } int CameraModule::getCameraInfo(int cameraId, struct camera_info *info) { + ATRACE_CALL(); Mutex::Autolock lock(mCameraInfoLock); if (cameraId < 0) { ALOGE("%s: Invalid camera ID %d", __FUNCTION__, cameraId); @@ -185,14 +193,20 @@ int CameraModule::getCameraInfo(int cameraId, struct camera_info *info) { // Only override static_camera_characteristics for API2 devices int apiVersion = mModule->common.module_api_version; if (apiVersion < CAMERA_MODULE_API_VERSION_2_0) { - return mModule->get_camera_info(cameraId, info); + int ret; + ATRACE_BEGIN("camera_module->get_camera_info"); + ret = mModule->get_camera_info(cameraId, info); + ATRACE_END(); + return ret; } ssize_t index = mCameraInfoMap.indexOfKey(cameraId); if (index == NAME_NOT_FOUND) { // Get camera info from raw module and cache it camera_info rawInfo, cameraInfo; + ATRACE_BEGIN("camera_module->get_camera_info"); int ret = mModule->get_camera_info(cameraId, &rawInfo); + ATRACE_END(); if (ret != 0) { return ret; } @@ -217,20 +231,36 @@ int CameraModule::getCameraInfo(int cameraId, struct camera_info *info) { } int CameraModule::open(const char* id, struct hw_device_t** device) { - return filterOpenErrorCode(mModule->common.methods->open(&mModule->common, id, device)); + int res; + ATRACE_BEGIN("camera_module->open"); + res = filterOpenErrorCode(mModule->common.methods->open(&mModule->common, id, device)); + ATRACE_END(); + return res; } int CameraModule::openLegacy( const char* id, uint32_t halVersion, struct hw_device_t** device) { - return mModule->open_legacy(&mModule->common, id, halVersion, device); + int res; + ATRACE_BEGIN("camera_module->open_legacy"); + res = mModule->open_legacy(&mModule->common, id, halVersion, device); + ATRACE_END(); + return res; } int CameraModule::getNumberOfCameras() { - return mModule->get_number_of_cameras(); + int numCameras; + ATRACE_BEGIN("camera_module->get_number_of_cameras"); + numCameras = mModule->get_number_of_cameras(); + ATRACE_END(); + return numCameras; } int CameraModule::setCallbacks(const camera_module_callbacks_t *callbacks) { - return mModule->set_callbacks(callbacks); + int res; + ATRACE_BEGIN("camera_module->set_callbacks"); + res = mModule->set_callbacks(callbacks); + ATRACE_END(); + return res; } bool CameraModule::isVendorTagDefined() { @@ -239,12 +269,18 @@ bool CameraModule::isVendorTagDefined() { void CameraModule::getVendorTagOps(vendor_tag_ops_t* ops) { if (mModule->get_vendor_tag_ops) { + ATRACE_BEGIN("camera_module->get_vendor_tag_ops"); mModule->get_vendor_tag_ops(ops); + ATRACE_END(); } } int CameraModule::setTorchMode(const char* camera_id, bool enable) { - return mModule->set_torch_mode(camera_id, enable); + int res; + ATRACE_BEGIN("camera_module->set_torch_mode"); + res = mModule->set_torch_mode(camera_id, enable); + ATRACE_END(); + return res; } status_t CameraModule::filterOpenErrorCode(status_t err) { |