diff options
author | Gaurav Batra <gbatra@nvidia.com> | 2014-06-19 16:47:07 -0700 |
---|---|---|
committer | Zhijun He <zhijunhe@google.com> | 2014-06-28 00:55:45 +0000 |
commit | 954d248e02e19f8ecd165804b7d063d346154f4c (patch) | |
tree | 775019ce9782e8d8b131af80b835bfb40922a15f /services/camera/libcameraservice/common | |
parent | 0b5003b7d80f70af20f387b1d0d990972a5570da (diff) | |
download | frameworks_av-954d248e02e19f8ecd165804b7d063d346154f4c.zip frameworks_av-954d248e02e19f8ecd165804b7d063d346154f4c.tar.gz frameworks_av-954d248e02e19f8ecd165804b7d063d346154f4c.tar.bz2 |
Camera API1/2: don't register the same listener multiple times
FrameProcessorBase allows register the same metadata result listener multiple
times with the same range IDs, which causes the same metadata result is
delivered multiple times for the same listener. This is problematic as client
like ZslProcessor's updateStream is called multiple times between captures, and
each updateStream calls registerListener unconditionally. The the ZSL metadata
result queue will be flooded with same metadata result multiple times and the
number of same result will keep growing until the queue is full.
Change-Id: I2ff7808e5dce61068a7111e7fbbce2aba95198cd
Diffstat (limited to 'services/camera/libcameraservice/common')
-rw-r--r-- | services/camera/libcameraservice/common/FrameProcessorBase.cpp | 12 | ||||
-rw-r--r-- | services/camera/libcameraservice/common/FrameProcessorBase.h | 3 |
2 files changed, 14 insertions, 1 deletions
diff --git a/services/camera/libcameraservice/common/FrameProcessorBase.cpp b/services/camera/libcameraservice/common/FrameProcessorBase.cpp index 2c82049..482f687 100644 --- a/services/camera/libcameraservice/common/FrameProcessorBase.cpp +++ b/services/camera/libcameraservice/common/FrameProcessorBase.cpp @@ -39,6 +39,18 @@ FrameProcessorBase::~FrameProcessorBase() { status_t FrameProcessorBase::registerListener(int32_t minId, int32_t maxId, wp<FilteredListener> listener, bool sendPartials) { Mutex::Autolock l(mInputMutex); + List<RangeListener>::iterator item = mRangeListeners.begin(); + while (item != mRangeListeners.end()) { + if (item->minId == minId && + item->maxId == maxId && + item->listener == listener) { + // already registered, just return + ALOGV("%s: Attempt to register the same client twice, ignoring", + __FUNCTION__); + return OK; + } + item++; + } ALOGV("%s: Registering listener for frame id range %d - %d", __FUNCTION__, minId, maxId); RangeListener rListener = { minId, maxId, listener, sendPartials }; diff --git a/services/camera/libcameraservice/common/FrameProcessorBase.h b/services/camera/libcameraservice/common/FrameProcessorBase.h index ee44a8b..3649c45 100644 --- a/services/camera/libcameraservice/common/FrameProcessorBase.h +++ b/services/camera/libcameraservice/common/FrameProcessorBase.h @@ -44,7 +44,8 @@ class FrameProcessorBase: public Thread { }; // Register a listener for a range of IDs [minId, maxId). Multiple listeners - // can be listening to the same range. + // can be listening to the same range. Registering the same listener with + // the same range of IDs has no effect. // sendPartials controls whether partial results will be sent. status_t registerListener(int32_t minId, int32_t maxId, wp<FilteredListener> listener, |