Change ConsumerBase's FrameAvailableListener to be a weak pointer
This prevents strong reference cycles when the listener implementation also
holds a strong pointer to the ConsumerBase
Bug: 7425644
Change-Id: I1514b13a32b18d421c902dddebec0765a989c55c
diff --git a/include/gui/ConsumerBase.h b/include/gui/ConsumerBase.h
index ee5cb29..5ae5a19 100644
--- a/include/gui/ConsumerBase.h
+++ b/include/gui/ConsumerBase.h
@@ -78,7 +78,7 @@
// setFrameAvailableListener sets the listener object that will be notified
// when a new frame becomes available.
- void setFrameAvailableListener(const sp<FrameAvailableListener>& listener);
+ void setFrameAvailableListener(const wp<FrameAvailableListener>& listener);
private:
ConsumerBase(const ConsumerBase&);
@@ -199,7 +199,7 @@
// mFrameAvailableListener is the listener object that will be called when a
// new frame becomes available. If it is not NULL it will be called from
// queueBuffer.
- sp<FrameAvailableListener> mFrameAvailableListener;
+ wp<FrameAvailableListener> mFrameAvailableListener;
// The ConsumerBase has-a BufferQueue and is responsible for creating this object
// if none is supplied
diff --git a/include/gui/SurfaceTexture.h b/include/gui/SurfaceTexture.h
index 7c519ae..b498a5c 100644
--- a/include/gui/SurfaceTexture.h
+++ b/include/gui/SurfaceTexture.h
@@ -33,6 +33,8 @@
#include <utils/threads.h>
#define ANDROID_GRAPHICS_SURFACETEXTURE_JNI_ID "mSurfaceTexture"
+#define ANDROID_GRAPHICS_FRAMEAVAILABLELISTENER_JNI_ID \
+ "mFrameAvailableListener"
namespace android {
// ----------------------------------------------------------------------------