From bbbc7cb77efba3dd46e9d13fc22e81cff17c35d2 Mon Sep 17 00:00:00 2001 From: Dave Sparks Date: Tue, 23 Jun 2009 17:30:11 -0700 Subject: Use a ref-counted callback interface for Camera. This allows the camera service to hang onto the callback interface until all callbacks have been processed. This prevents problems where pending callbacks in binder worker threads are processed after the Java camera object and its associated native resources have been released. Bug 1884362 --- include/ui/Camera.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'include/ui') diff --git a/include/ui/Camera.h b/include/ui/Camera.h index 048bdd560b..bd4855ce6b 100644 --- a/include/ui/Camera.h +++ b/include/ui/Camera.h @@ -86,6 +86,14 @@ class Surface; class Mutex; class String8; +// ref-counted object for callbacks +class CameraListener: virtual public RefBase +{ +public: + virtual void notify(int32_t msgType, int32_t ext1, int32_t ext2) = 0; + virtual void postData(int32_t msgType, const sp& dataPtr) = 0; +}; + typedef void (*shutter_callback)(void *cookie); typedef void (*frame_callback)(const sp& mem, void *cookie); typedef void (*autofocus_callback)(bool focused, void *cookie); @@ -152,6 +160,9 @@ public: void setErrorCallback(error_callback cb, void *cookie); void setAutoFocusCallback(autofocus_callback cb, void *cookie); + void setListener(const sp& listener); + void setPreviewCallbackFlags(int preview_callback_flag); + // ICameraClient interface virtual void notifyCallback(int32_t msgType, int32_t ext, int32_t ext2); virtual void dataCallback(int32_t msgType, const sp& dataPtr); @@ -194,6 +205,8 @@ private: autofocus_callback mAutoFocusCallback; void *mAutoFocusCallbackCookie; + sp mListener; + friend class DeathNotifier; static Mutex mLock; -- cgit v1.2.3-59-g8ed1b