Loading api/current.xml +789 −39 File changed.Preview size limit exceeded, changes collapsed. Show changes camera/libcameraservice/CameraHardwareStub.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -183,6 +183,10 @@ void CameraHardwareStub::stopPreview() mPreviewThread.clear(); } bool CameraHardwareStub::previewEnabled() { return mPreviewThread != 0; } // --------------------------------------------------------------------------- int CameraHardwareStub::beginAutoFocusThread(void *cookie) Loading camera/libcameraservice/CameraHardwareStub.h +1 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ public: virtual status_t startPreview(preview_callback cb, void* user); virtual void stopPreview(); virtual bool previewEnabled(); virtual status_t autoFocus(autofocus_callback, void *user); virtual status_t takePicture(shutter_callback, raw_callback, Loading camera/libcameraservice/CameraService.cpp +55 −7 Original line number Diff line number Diff line Loading @@ -107,7 +107,7 @@ sp<ICamera> CameraService::connect(const sp<ICameraClient>& cameraClient) } // create a new Client object sp<Client> client = new Client(this, cameraClient); sp<Client> client = new Client(this, cameraClient, IPCThreadState::self()->getCallingPid()); mClient = client; #if DEBUG_CLIENT_REFERENCES // Enable tracking for this object, and track increments and decrements of Loading Loading @@ -151,10 +151,12 @@ void CameraService::removeClient(const sp<ICameraClient>& cameraClient) } CameraService::Client::Client(const sp<CameraService>& cameraService, const sp<ICameraClient>& cameraClient) : mCameraService(cameraService), mCameraClient(cameraClient), mHardware(0) const sp<ICameraClient>& cameraClient, pid_t clientPid) { LOGD("Client E constructor"); mCameraService = cameraService; mCameraClient = cameraClient; mClientPid = clientPid; mHardware = openCameraHardware(); // Callback is disabled by default Loading @@ -162,12 +164,36 @@ CameraService::Client::Client(const sp<CameraService>& cameraService, LOGD("Client X constructor"); } status_t CameraService::Client::checkPid() { // zero means the interface is not locked down if (mClientPid == 0) return NO_ERROR; return (int) mClientPid == IPCThreadState::self()->getCallingPid() ? NO_ERROR : -EBUSY; } status_t CameraService::Client::lock() { // lock camera to this client status_t result = checkPid(); if (result == NO_ERROR) mClientPid = IPCThreadState::self()->getCallingPid(); return result; } status_t CameraService::Client::unlock() { // allow anyone to use camera status_t result = checkPid(); if (result == NO_ERROR) mClientPid = 0; return result; } status_t CameraService::Client::connect(const sp<ICameraClient>& client) { // remvoe old client LOGD("connect (new client)"); // remove old client LOGV("connect new client to existing camera"); Mutex::Autolock _l(mLock); mCameraClient = client; mClientPid = IPCThreadState::self()->getCallingPid(); mFrameCallbackFlag = FRAME_CALLBACK_FLAG_NOOP; return NO_ERROR; } Loading Loading @@ -209,6 +235,7 @@ void CameraService::Client::disconnect() { LOGD("Client E disconnect"); Mutex::Autolock lock(mLock); if (checkPid() != NO_ERROR) return; mCameraService->removeClient(mCameraClient); if (mHardware != 0) { // Before destroying mHardware, we must make sure it's in the Loading @@ -228,6 +255,8 @@ status_t CameraService::Client::setPreviewDisplay(const sp<ISurface>& surface) { LOGD("setPreviewDisplay(%p)", surface.get()); Mutex::Autolock lock(mLock); status_t result = checkPid(); if (result != NO_ERROR) return result; Mutex::Autolock surfaceLock(mSurfaceLock); // asBinder() is safe on NULL (returns NULL) if (surface->asBinder() != mSurface->asBinder()) { Loading @@ -245,6 +274,7 @@ status_t CameraService::Client::setPreviewDisplay(const sp<ISurface>& surface) void CameraService::Client::setFrameCallbackFlag(int frame_callback_flag) { Mutex::Autolock lock(mLock); if (checkPid() != NO_ERROR) return; mFrameCallbackFlag = frame_callback_flag; } Loading @@ -258,6 +288,8 @@ status_t CameraService::Client::startPreview() */ Mutex::Autolock lock(mLock); status_t result = checkPid(); if (result != NO_ERROR) return result; if (mHardware == 0) { LOGE("mHardware is NULL, returning."); Loading @@ -269,14 +301,15 @@ status_t CameraService::Client::startPreview() return INVALID_OPERATION; } // do nothing if preview is already started if (mHardware->previewEnabled()) return NO_ERROR; // XXX: This needs to be improved. remove all hardcoded stuff int w, h; CameraParameters params(mHardware->getParameters()); params.getPreviewSize(&w, &h); mSurface->unregisterBuffers(); #if DEBUG_DUMP_PREVIEW_FRAME_TO_FILE debug_frame_cnt = 0; #endif Loading @@ -284,6 +317,7 @@ status_t CameraService::Client::startPreview() status_t ret = mHardware->startPreview(previewCallback, mCameraService.get()); if (ret == NO_ERROR) { mSurface->unregisterBuffers(); mSurface->registerBuffers(w,h,w,h, PIXEL_FORMAT_YCbCr_420_SP, mHardware->getPreviewHeap()); Loading @@ -300,6 +334,7 @@ void CameraService::Client::stopPreview() LOGD("stopPreview()"); Mutex::Autolock lock(mLock); if (checkPid() != NO_ERROR) return; if (mHardware == 0) { LOGE("mHardware is NULL, returning."); Loading @@ -315,6 +350,13 @@ void CameraService::Client::stopPreview() mPreviewBuffer.clear(); } bool CameraService::Client::previewEnabled() { Mutex::Autolock lock(mLock); if (mHardware == 0) return false; return mHardware->previewEnabled(); } // Safely retrieves a strong pointer to the client during a hardware callback. sp<CameraService::Client> CameraService::Client::getClientFromCookie(void* user) { Loading Loading @@ -424,6 +466,8 @@ status_t CameraService::Client::autoFocus() LOGV("autoFocus"); Mutex::Autolock lock(mLock); status_t result = checkPid(); if (result != NO_ERROR) return result; if (mHardware == 0) { LOGE("mHardware is NULL, returning."); Loading @@ -440,6 +484,8 @@ status_t CameraService::Client::takePicture() LOGD("takePicture"); Mutex::Autolock lock(mLock); status_t result = checkPid(); if (result != NO_ERROR) return result; if (mHardware == 0) { LOGE("mHardware is NULL, returning."); Loading Loading @@ -580,6 +626,8 @@ status_t CameraService::Client::setParameters(const String8& params) LOGD("setParameters(%s)", params.string()); Mutex::Autolock lock(mLock); status_t result = checkPid(); if (result != NO_ERROR) return result; if (mHardware == 0) { LOGE("mHardware is NULL, returning."); Loading camera/libcameraservice/CameraService.h +16 −3 Original line number Diff line number Diff line Loading @@ -73,6 +73,12 @@ private: // connect new client with existing camera remote virtual status_t connect(const sp<ICameraClient>& client); // prevent other processes from using this ICamera interface virtual status_t lock(); // allow other processes to use this ICamera interface virtual status_t unlock(); // pass the buffered ISurface to the camera service virtual status_t setPreviewDisplay(const sp<ISurface>& surface); Loading @@ -86,6 +92,9 @@ private: // stop preview mode virtual void stopPreview(); // get preview state virtual bool previewEnabled(); // auto focus virtual status_t autoFocus(); Loading @@ -104,10 +113,13 @@ private: private: friend class CameraService; Client(const sp<CameraService>& cameraService, const sp<ICameraClient>& cameraClient); const sp<ICameraClient>& cameraClient, pid_t clientPid); Client(); virtual ~Client(); status_t checkPid(); static void previewCallback(const sp<IMemory>& mem, void* user); static void shutterCallback(void *user); static void yuvPictureCallback(const sp<IMemory>& mem, void* user); Loading @@ -132,7 +144,7 @@ private: // by the CameraHardwareInterface callback, and needs to // access mSurface. It cannot hold mLock, however, because // stopPreview() may be holding that lock while attempting // top stop preview, and stopPreview itself will block waiting // to stop preview, and stopPreview itself will block waiting // for a callback from CameraHardwareInterface. If this // happens, it will cause a deadlock. mutable Mutex mSurfaceLock; Loading @@ -146,6 +158,7 @@ private: // they don't need to be protected by a lock sp<ICameraClient> mCameraClient; sp<CameraHardwareInterface> mHardware; pid_t mClientPid; }; // ---------------------------------------------------------------------------- Loading Loading
camera/libcameraservice/CameraHardwareStub.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -183,6 +183,10 @@ void CameraHardwareStub::stopPreview() mPreviewThread.clear(); } bool CameraHardwareStub::previewEnabled() { return mPreviewThread != 0; } // --------------------------------------------------------------------------- int CameraHardwareStub::beginAutoFocusThread(void *cookie) Loading
camera/libcameraservice/CameraHardwareStub.h +1 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ public: virtual status_t startPreview(preview_callback cb, void* user); virtual void stopPreview(); virtual bool previewEnabled(); virtual status_t autoFocus(autofocus_callback, void *user); virtual status_t takePicture(shutter_callback, raw_callback, Loading
camera/libcameraservice/CameraService.cpp +55 −7 Original line number Diff line number Diff line Loading @@ -107,7 +107,7 @@ sp<ICamera> CameraService::connect(const sp<ICameraClient>& cameraClient) } // create a new Client object sp<Client> client = new Client(this, cameraClient); sp<Client> client = new Client(this, cameraClient, IPCThreadState::self()->getCallingPid()); mClient = client; #if DEBUG_CLIENT_REFERENCES // Enable tracking for this object, and track increments and decrements of Loading Loading @@ -151,10 +151,12 @@ void CameraService::removeClient(const sp<ICameraClient>& cameraClient) } CameraService::Client::Client(const sp<CameraService>& cameraService, const sp<ICameraClient>& cameraClient) : mCameraService(cameraService), mCameraClient(cameraClient), mHardware(0) const sp<ICameraClient>& cameraClient, pid_t clientPid) { LOGD("Client E constructor"); mCameraService = cameraService; mCameraClient = cameraClient; mClientPid = clientPid; mHardware = openCameraHardware(); // Callback is disabled by default Loading @@ -162,12 +164,36 @@ CameraService::Client::Client(const sp<CameraService>& cameraService, LOGD("Client X constructor"); } status_t CameraService::Client::checkPid() { // zero means the interface is not locked down if (mClientPid == 0) return NO_ERROR; return (int) mClientPid == IPCThreadState::self()->getCallingPid() ? NO_ERROR : -EBUSY; } status_t CameraService::Client::lock() { // lock camera to this client status_t result = checkPid(); if (result == NO_ERROR) mClientPid = IPCThreadState::self()->getCallingPid(); return result; } status_t CameraService::Client::unlock() { // allow anyone to use camera status_t result = checkPid(); if (result == NO_ERROR) mClientPid = 0; return result; } status_t CameraService::Client::connect(const sp<ICameraClient>& client) { // remvoe old client LOGD("connect (new client)"); // remove old client LOGV("connect new client to existing camera"); Mutex::Autolock _l(mLock); mCameraClient = client; mClientPid = IPCThreadState::self()->getCallingPid(); mFrameCallbackFlag = FRAME_CALLBACK_FLAG_NOOP; return NO_ERROR; } Loading Loading @@ -209,6 +235,7 @@ void CameraService::Client::disconnect() { LOGD("Client E disconnect"); Mutex::Autolock lock(mLock); if (checkPid() != NO_ERROR) return; mCameraService->removeClient(mCameraClient); if (mHardware != 0) { // Before destroying mHardware, we must make sure it's in the Loading @@ -228,6 +255,8 @@ status_t CameraService::Client::setPreviewDisplay(const sp<ISurface>& surface) { LOGD("setPreviewDisplay(%p)", surface.get()); Mutex::Autolock lock(mLock); status_t result = checkPid(); if (result != NO_ERROR) return result; Mutex::Autolock surfaceLock(mSurfaceLock); // asBinder() is safe on NULL (returns NULL) if (surface->asBinder() != mSurface->asBinder()) { Loading @@ -245,6 +274,7 @@ status_t CameraService::Client::setPreviewDisplay(const sp<ISurface>& surface) void CameraService::Client::setFrameCallbackFlag(int frame_callback_flag) { Mutex::Autolock lock(mLock); if (checkPid() != NO_ERROR) return; mFrameCallbackFlag = frame_callback_flag; } Loading @@ -258,6 +288,8 @@ status_t CameraService::Client::startPreview() */ Mutex::Autolock lock(mLock); status_t result = checkPid(); if (result != NO_ERROR) return result; if (mHardware == 0) { LOGE("mHardware is NULL, returning."); Loading @@ -269,14 +301,15 @@ status_t CameraService::Client::startPreview() return INVALID_OPERATION; } // do nothing if preview is already started if (mHardware->previewEnabled()) return NO_ERROR; // XXX: This needs to be improved. remove all hardcoded stuff int w, h; CameraParameters params(mHardware->getParameters()); params.getPreviewSize(&w, &h); mSurface->unregisterBuffers(); #if DEBUG_DUMP_PREVIEW_FRAME_TO_FILE debug_frame_cnt = 0; #endif Loading @@ -284,6 +317,7 @@ status_t CameraService::Client::startPreview() status_t ret = mHardware->startPreview(previewCallback, mCameraService.get()); if (ret == NO_ERROR) { mSurface->unregisterBuffers(); mSurface->registerBuffers(w,h,w,h, PIXEL_FORMAT_YCbCr_420_SP, mHardware->getPreviewHeap()); Loading @@ -300,6 +334,7 @@ void CameraService::Client::stopPreview() LOGD("stopPreview()"); Mutex::Autolock lock(mLock); if (checkPid() != NO_ERROR) return; if (mHardware == 0) { LOGE("mHardware is NULL, returning."); Loading @@ -315,6 +350,13 @@ void CameraService::Client::stopPreview() mPreviewBuffer.clear(); } bool CameraService::Client::previewEnabled() { Mutex::Autolock lock(mLock); if (mHardware == 0) return false; return mHardware->previewEnabled(); } // Safely retrieves a strong pointer to the client during a hardware callback. sp<CameraService::Client> CameraService::Client::getClientFromCookie(void* user) { Loading Loading @@ -424,6 +466,8 @@ status_t CameraService::Client::autoFocus() LOGV("autoFocus"); Mutex::Autolock lock(mLock); status_t result = checkPid(); if (result != NO_ERROR) return result; if (mHardware == 0) { LOGE("mHardware is NULL, returning."); Loading @@ -440,6 +484,8 @@ status_t CameraService::Client::takePicture() LOGD("takePicture"); Mutex::Autolock lock(mLock); status_t result = checkPid(); if (result != NO_ERROR) return result; if (mHardware == 0) { LOGE("mHardware is NULL, returning."); Loading Loading @@ -580,6 +626,8 @@ status_t CameraService::Client::setParameters(const String8& params) LOGD("setParameters(%s)", params.string()); Mutex::Autolock lock(mLock); status_t result = checkPid(); if (result != NO_ERROR) return result; if (mHardware == 0) { LOGE("mHardware is NULL, returning."); Loading
camera/libcameraservice/CameraService.h +16 −3 Original line number Diff line number Diff line Loading @@ -73,6 +73,12 @@ private: // connect new client with existing camera remote virtual status_t connect(const sp<ICameraClient>& client); // prevent other processes from using this ICamera interface virtual status_t lock(); // allow other processes to use this ICamera interface virtual status_t unlock(); // pass the buffered ISurface to the camera service virtual status_t setPreviewDisplay(const sp<ISurface>& surface); Loading @@ -86,6 +92,9 @@ private: // stop preview mode virtual void stopPreview(); // get preview state virtual bool previewEnabled(); // auto focus virtual status_t autoFocus(); Loading @@ -104,10 +113,13 @@ private: private: friend class CameraService; Client(const sp<CameraService>& cameraService, const sp<ICameraClient>& cameraClient); const sp<ICameraClient>& cameraClient, pid_t clientPid); Client(); virtual ~Client(); status_t checkPid(); static void previewCallback(const sp<IMemory>& mem, void* user); static void shutterCallback(void *user); static void yuvPictureCallback(const sp<IMemory>& mem, void* user); Loading @@ -132,7 +144,7 @@ private: // by the CameraHardwareInterface callback, and needs to // access mSurface. It cannot hold mLock, however, because // stopPreview() may be holding that lock while attempting // top stop preview, and stopPreview itself will block waiting // to stop preview, and stopPreview itself will block waiting // for a callback from CameraHardwareInterface. If this // happens, it will cause a deadlock. mutable Mutex mSurfaceLock; Loading @@ -146,6 +158,7 @@ private: // they don't need to be protected by a lock sp<ICameraClient> mCameraClient; sp<CameraHardwareInterface> mHardware; pid_t mClientPid; }; // ---------------------------------------------------------------------------- Loading