summaryrefslogtreecommitdiffstats
path: root/services/camera/libcameraservice
diff options
context:
space:
mode:
authorEino-Ville Talvala <etalvala@google.com>2012-09-19 17:11:04 -0700
committerEino-Ville Talvala <etalvala@google.com>2012-09-20 10:24:47 -0700
commit5a8fed0251b978388bcebd6f4d0c4e2773c7641e (patch)
tree216db9d7a988e7dcc6bac690dc1ba33d076085a5 /services/camera/libcameraservice
parent52e9ad48ddd3c2e7c90a9002a2a65a5d63125b78 (diff)
downloadframeworks_av-5a8fed0251b978388bcebd6f4d0c4e2773c7641e.zip
frameworks_av-5a8fed0251b978388bcebd6f4d0c4e2773c7641e.tar.gz
frameworks_av-5a8fed0251b978388bcebd6f4d0c4e2773c7641e.tar.bz2
Camera2: Erase ZSL queue after each use.
Since preview stops after a capture is submitted, need to clear out the ZSL queue to avoid using stale buffers when the preview starts up again. Bug: 7189765 Change-Id: I9ae2382d0af132208aca5ccba49b5464d18a263e
Diffstat (limited to 'services/camera/libcameraservice')
-rw-r--r--services/camera/libcameraservice/camera2/CaptureSequencer.cpp5
-rw-r--r--services/camera/libcameraservice/camera2/ZslProcessor.cpp25
-rw-r--r--services/camera/libcameraservice/camera2/ZslProcessor.h3
3 files changed, 32 insertions, 1 deletions
diff --git a/services/camera/libcameraservice/camera2/CaptureSequencer.cpp b/services/camera/libcameraservice/camera2/CaptureSequencer.cpp
index 941ad15..a836321 100644
--- a/services/camera/libcameraservice/camera2/CaptureSequencer.cpp
+++ b/services/camera/libcameraservice/camera2/CaptureSequencer.cpp
@@ -223,6 +223,11 @@ CaptureSequencer::CaptureState CaptureSequencer::manageDone(sp<Camera2Client> &c
res = INVALID_OPERATION;
}
}
+ sp<ZslProcessor> processor = mZslProcessor.promote();
+ if (processor != 0) {
+ processor->clearZslQueue();
+ }
+
if (mCaptureBuffer != 0 && res == OK) {
Camera2Client::SharedCameraClient::Lock l(client->mSharedCameraClient);
ALOGV("%s: Sending still image to client", __FUNCTION__);
diff --git a/services/camera/libcameraservice/camera2/ZslProcessor.cpp b/services/camera/libcameraservice/camera2/ZslProcessor.cpp
index 8906cd7..c7a679e 100644
--- a/services/camera/libcameraservice/camera2/ZslProcessor.cpp
+++ b/services/camera/libcameraservice/camera2/ZslProcessor.cpp
@@ -97,6 +97,10 @@ void ZslProcessor::onBufferReleased(buffer_handle_t *handle) {
__FUNCTION__, handle);
}
+ // Erase entire ZSL queue since we've now completed the capture and preview
+ // is stopped.
+ clearZslQueueLocked();
+
mState = RUNNING;
}
@@ -240,7 +244,6 @@ status_t ZslProcessor::pushToReprocess(int32_t requestId) {
dumpZslQueue(-1);
}
-
if (mZslQueueTail != mZslQueueHead) {
CameraMetadata request;
size_t index = mZslQueueTail;
@@ -312,6 +315,26 @@ status_t ZslProcessor::pushToReprocess(int32_t requestId) {
return OK;
}
+status_t ZslProcessor::clearZslQueue() {
+ Mutex::Autolock l(mInputMutex);
+ // If in middle of capture, can't clear out queue
+ if (mState == LOCKED) return OK;
+
+ return clearZslQueueLocked();
+}
+
+status_t ZslProcessor::clearZslQueueLocked() {
+ for (size_t i = 0; i < mZslQueue.size(); i++) {
+ if (mZslQueue[i].buffer.mTimestamp != 0) {
+ mZslConsumer->releaseBuffer(mZslQueue[i].buffer);
+ }
+ mZslQueue.replaceAt(i);
+ }
+ mZslQueueHead = 0;
+ mZslQueueTail = 0;
+ return OK;
+}
+
void ZslProcessor::dump(int fd, const Vector<String16>& args) const {
Mutex::Autolock l(mInputMutex);
dumpZslQueue(fd);
diff --git a/services/camera/libcameraservice/camera2/ZslProcessor.h b/services/camera/libcameraservice/camera2/ZslProcessor.h
index 268f4f5..96ad5fb 100644
--- a/services/camera/libcameraservice/camera2/ZslProcessor.h
+++ b/services/camera/libcameraservice/camera2/ZslProcessor.h
@@ -62,6 +62,7 @@ class ZslProcessor:
int getReprocessStreamId() const;
status_t pushToReprocess(int32_t requestId);
+ status_t clearZslQueue();
void dump(int fd, const Vector<String16>& args) const;
private:
@@ -111,6 +112,8 @@ class ZslProcessor:
// Match up entries from frame list to buffers in ZSL queue
void findMatchesLocked();
+ status_t clearZslQueueLocked();
+
void dumpZslQueue(int id) const;
};