Skip to content

Commit

Permalink
Free QualcommCameraHardware instance when closing camera
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Dorregaray committed Mar 5, 2014
1 parent dff3f01 commit 9be300b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
4 changes: 1 addition & 3 deletions QualcommCameraHardware.h
Expand Up @@ -223,8 +223,7 @@ namespace android {
class QualcommCameraHardware : public RefBase{
public:

//virtual sp<IMemoryHeap> getPreviewHeap() const;
//virtual sp<IMemoryHeap> getRawHeap() const;
virtual ~QualcommCameraHardware();

void setCallbacks(camera_notify_callback notify_cb,
camera_data_callback data_cb,
Expand Down Expand Up @@ -283,7 +282,6 @@ class QualcommCameraHardware : public RefBase{

private:
QualcommCameraHardware();
virtual ~QualcommCameraHardware();
status_t startPreviewInternal();
status_t setHistogramOn();
status_t setHistogramOff();
Expand Down
1 change: 1 addition & 0 deletions cameraHAL.cpp
Expand Up @@ -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--;

Expand Down

0 comments on commit 9be300b

Please sign in to comment.