CameraService: ZslProcessor: Don't call back into BQ from callback
am: 9eef26c39a
Change-Id: I2db501eca0c737aa532b32684ce7ee2732f05d83
diff --git a/services/camera/libcameraservice/api1/client2/ZslProcessor.cpp b/services/camera/libcameraservice/api1/client2/ZslProcessor.cpp
index e03ec66..9bc31b9 100644
--- a/services/camera/libcameraservice/api1/client2/ZslProcessor.cpp
+++ b/services/camera/libcameraservice/api1/client2/ZslProcessor.cpp
@@ -138,7 +138,8 @@
mInputBuffer(nullptr),
mProducer(nullptr),
mInputProducer(nullptr),
- mInputProducerSlot(-1) {
+ mInputProducerSlot(-1),
+ mBuffersToDetach(0) {
// Initialize buffer queue and frame list based on pipeline max depth.
size_t pipelineMaxDepth = kDefaultMaxPipelineDepth;
if (client != 0) {
@@ -430,6 +431,11 @@
void ZslProcessor::notifyInputReleased() {
Mutex::Autolock l(mInputMutex);
+ mBuffersToDetach++;
+ mBuffersToDetachSignal.signal();
+}
+
+void ZslProcessor::doNotifyInputReleasedLocked() {
assert(nullptr != mInputBuffer.get());
assert(nullptr != mInputProducer.get());
@@ -736,9 +742,18 @@
}
bool ZslProcessor::threadLoop() {
- // TODO: remove dependency on thread. For now, shut thread down right
- // away.
- return false;
+ Mutex::Autolock l(mInputMutex);
+
+ if (mBuffersToDetach == 0) {
+ status_t res = mBuffersToDetachSignal.waitRelative(mInputMutex, kWaitDuration);
+ if (res == TIMED_OUT) return true;
+ }
+ while (mBuffersToDetach > 0) {
+ doNotifyInputReleasedLocked();
+ mBuffersToDetach--;
+ }
+
+ return true;
}
void ZslProcessor::dumpZslQueue(int fd) const {
diff --git a/services/camera/libcameraservice/api1/client2/ZslProcessor.h b/services/camera/libcameraservice/api1/client2/ZslProcessor.h
index 6113d58..1db2403 100644
--- a/services/camera/libcameraservice/api1/client2/ZslProcessor.h
+++ b/services/camera/libcameraservice/api1/client2/ZslProcessor.h
@@ -142,6 +142,9 @@
sp<IGraphicBufferProducer> mInputProducer;
int mInputProducerSlot;
+ Condition mBuffersToDetachSignal;
+ int mBuffersToDetach;
+
virtual bool threadLoop();
status_t clearZslQueueLocked();
@@ -156,6 +159,7 @@
nsecs_t* actualTimestamp);
status_t clearInputRingBufferLocked(nsecs_t* latestTimestamp);
void notifyInputReleased();
+ void doNotifyInputReleasedLocked();
bool isFixedFocusMode(uint8_t afMode) const;