From 9be300b551a20bccc9a7389108b3d31283e3bebc Mon Sep 17 00:00:00 2001 From: trostanski Date: Wed, 5 Mar 2014 09:36:17 +0100 Subject: [PATCH] Free QualcommCameraHardware instance when closing camera The LINK_mm_camera_destroy is being called in QualcommCameraHardware destructor. If we do not free the QualcommCameraHardware from camera_device_close the camera may not be deinitialized and drain the battery when not using camera. This is especially visible when Skype is installed - which opens the camera during startup to probe the camera and obtains its parameters even when the user is not using camera in skype. --- QualcommCameraHardware.h | 4 +--- cameraHAL.cpp | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/QualcommCameraHardware.h b/QualcommCameraHardware.h index 305c8ee..de6edee 100644 --- a/QualcommCameraHardware.h +++ b/QualcommCameraHardware.h @@ -223,8 +223,7 @@ namespace android { class QualcommCameraHardware : public RefBase{ public: - //virtual sp getPreviewHeap() const; - //virtual sp getRawHeap() const; + virtual ~QualcommCameraHardware(); void setCallbacks(camera_notify_callback notify_cb, camera_data_callback data_cb, @@ -283,7 +282,6 @@ class QualcommCameraHardware : public RefBase{ private: QualcommCameraHardware(); - virtual ~QualcommCameraHardware(); status_t startPreviewInternal(); status_t setHistogramOn(); status_t setHistogramOff(); diff --git a/cameraHAL.cpp b/cameraHAL.cpp index a736a71..8457716 100644 --- a/cameraHAL.cpp +++ b/cameraHAL.cpp @@ -643,6 +643,7 @@ int camera_device_close(hw_device_t* device) gCameraHals[dev->cameraid]->release(); dev->released = true; } + delete(gCameraHals[dev->cameraid]); gCameraHals[dev->cameraid] = NULL; gCamerasOpen--;