diff options
author | Zhijun He <zhijunhe@google.com> | 2014-06-30 10:24:11 -0700 |
---|---|---|
committer | Zhijun He <zhijunhe@google.com> | 2014-07-02 15:34:03 -0700 |
commit | f0d962a6737eb8eec002d6804d9ffbe7bee672a0 (patch) | |
tree | ee1678ff2ede6bfc45412ddd4c48bc7bcb2be75c /services/camera/libcameraservice/device3 | |
parent | 954d248e02e19f8ecd165804b7d063d346154f4c (diff) | |
download | frameworks_av-f0d962a6737eb8eec002d6804d9ffbe7bee672a0.zip frameworks_av-f0d962a6737eb8eec002d6804d9ffbe7bee672a0.tar.gz frameworks_av-f0d962a6737eb8eec002d6804d9ffbe7bee672a0.tar.bz2 |
Camera3: fix ZSL processor3 issues
- Return input buffer in capture result. Per hal3.2 spec, we should return the
input buffer in process capture result rather than immediately after process
capture request.
- Make the depths of mZslQueue and mFrameList the same. It doesn't make sense
mFrameList depth is larger than mZslQueue depth.
- Set the depths of mZslQueue and mFrameList based on pipelineMaxDepth.
- Clear result queue while clearing zsl buffer queue.
- Hook up camera3 buffer listener with ZslProcessor3, make sure that adding the
same listener multiple times has no effect.
- Remove flush call in pushToReprocess, it is a guaranteed deadlock once
camera3 buffer listener is hooked up.
Change-Id: I285155ab4241e827145855d628f8e98b881c01d5
Diffstat (limited to 'services/camera/libcameraservice/device3')
5 files changed, 43 insertions, 19 deletions
diff --git a/services/camera/libcameraservice/device3/Camera3Device.cpp b/services/camera/libcameraservice/device3/Camera3Device.cpp index 5973625..8fce191 100644 --- a/services/camera/libcameraservice/device3/Camera3Device.cpp +++ b/services/camera/libcameraservice/device3/Camera3Device.cpp @@ -1720,7 +1720,8 @@ void Camera3Device::processCaptureResult(const camera3_capture_result *result) { status_t res; uint32_t frameNumber = result->frame_number; - if (result->result == NULL && result->num_output_buffers == 0) { + if (result->result == NULL && result->num_output_buffers == 0 && + result->input_buffer == NULL) { SET_ERR("No result data provided by HAL for frame %d", frameNumber); return; @@ -1805,7 +1806,7 @@ void Camera3Device::processCaptureResult(const camera3_capture_result *result) { } request.numBuffersLeft -= result->num_output_buffers; - + request.numBuffersLeft -= (result->input_buffer != NULL) ? 1 : 0; if (request.numBuffersLeft < 0) { SET_ERR("Too many buffers returned for frame %d", frameNumber); @@ -1906,6 +1907,19 @@ void Camera3Device::processCaptureResult(const camera3_capture_result *result) { } } + if (result->input_buffer != NULL) { + Camera3Stream *stream = + Camera3Stream::cast(result->input_buffer->stream); + res = stream->returnInputBuffer(*(result->input_buffer)); + // Note: stream may be deallocated at this point, if this buffer was the + // last reference to it. + if (res != OK) { + ALOGE("%s: RequestThread: Can't return input buffer for frame %d to" + " its stream:%s (%d)", __FUNCTION__, + frameNumber, strerror(-res), res); + } + } + // Finally, signal any waiters for new frames if (gotResult) { @@ -2318,6 +2332,7 @@ bool Camera3Device::RequestThread::threadLoop() { } camera3_stream_buffer_t inputBuffer; + uint32_t totalNumBuffers = 0; // Fill in buffers @@ -2330,6 +2345,7 @@ bool Camera3Device::RequestThread::threadLoop() { cleanUpFailedRequest(request, nextRequest, outputBuffers); return true; } + totalNumBuffers += 1; } else { request.input_buffer = NULL; } @@ -2348,6 +2364,7 @@ bool Camera3Device::RequestThread::threadLoop() { } request.num_output_buffers++; } + totalNumBuffers += request.num_output_buffers; // Log request in the in-flight queue sp<Camera3Device> parent = mParent.promote(); @@ -2358,7 +2375,7 @@ bool Camera3Device::RequestThread::threadLoop() { } res = parent->registerInFlight(request.frame_number, - request.num_output_buffers, nextRequest->mResultExtras); + totalNumBuffers, nextRequest->mResultExtras); ALOGVV("%s: registered in flight requestId = %" PRId32 ", frameNumber = %" PRId64 ", burstId = %" PRId32 ".", __FUNCTION__, @@ -2414,21 +2431,6 @@ bool Camera3Device::RequestThread::threadLoop() { } mPrevTriggers = triggerCount; - // Return input buffer back to framework - if (request.input_buffer != NULL) { - Camera3Stream *stream = - Camera3Stream::cast(request.input_buffer->stream); - res = stream->returnInputBuffer(*(request.input_buffer)); - // Note: stream may be deallocated at this point, if this buffer was the - // last reference to it. - if (res != OK) { - ALOGE("%s: RequestThread: Can't return input buffer for frame %d to" - " its stream:%s (%d)", __FUNCTION__, - request.frame_number, strerror(-res), res); - // TODO: Report error upstream - } - } - return true; } diff --git a/services/camera/libcameraservice/device3/Camera3Device.h b/services/camera/libcameraservice/device3/Camera3Device.h index 61e6572..d7545d0 100644 --- a/services/camera/libcameraservice/device3/Camera3Device.h +++ b/services/camera/libcameraservice/device3/Camera3Device.h @@ -501,7 +501,7 @@ class Camera3Device : // Set by process_capture_result call with valid metadata bool haveResultMetadata; // Decremented by calls to process_capture_result with valid output - // buffers + // and input buffers int numBuffersLeft; CaptureResultExtras resultExtras; diff --git a/services/camera/libcameraservice/device3/Camera3Stream.cpp b/services/camera/libcameraservice/device3/Camera3Stream.cpp index 7645a2a..d7b1871 100644 --- a/services/camera/libcameraservice/device3/Camera3Stream.cpp +++ b/services/camera/libcameraservice/device3/Camera3Stream.cpp @@ -485,6 +485,18 @@ status_t Camera3Stream::returnInputBufferLocked( void Camera3Stream::addBufferListener( wp<Camera3StreamBufferListener> listener) { Mutex::Autolock l(mLock); + + List<wp<Camera3StreamBufferListener> >::iterator it, end; + for (it = mBufferListenerList.begin(), end = mBufferListenerList.end(); + it != end; + ) { + if (*it == listener) { + ALOGE("%s: Try to add the same listener twice, ignoring...", __FUNCTION__); + return; + } + it++; + } + mBufferListenerList.push_back(listener); } diff --git a/services/camera/libcameraservice/device3/Camera3Stream.h b/services/camera/libcameraservice/device3/Camera3Stream.h index 14f5387..a77f27c 100644 --- a/services/camera/libcameraservice/device3/Camera3Stream.h +++ b/services/camera/libcameraservice/device3/Camera3Stream.h @@ -226,8 +226,17 @@ class Camera3Stream : */ virtual void dump(int fd, const Vector<String16> &args) const = 0; + /** + * Add a camera3 buffer listener. Adding the same listener twice has + * no effect. + */ void addBufferListener( wp<Camera3StreamBufferListener> listener); + + /** + * Remove a camera3 buffer listener. Removing the same listener twice + * or the listener that was never added has no effect. + */ void removeBufferListener( const sp<Camera3StreamBufferListener>& listener); diff --git a/services/camera/libcameraservice/device3/Camera3ZslStream.cpp b/services/camera/libcameraservice/device3/Camera3ZslStream.cpp index 05b3d1f..6c298f9 100644 --- a/services/camera/libcameraservice/device3/Camera3ZslStream.cpp +++ b/services/camera/libcameraservice/device3/Camera3ZslStream.cpp @@ -300,6 +300,7 @@ status_t Camera3ZslStream::enqueueInputBufferByTimestamp( nsecs_t actual = pinnedBuffer->getBufferItem().mTimestamp; if (actual != timestamp) { + // TODO: this is problematic, we'll end up with using wrong result for this pinned buffer. ALOGW("%s: ZSL buffer candidate search didn't find an exact match --" " requested timestamp = %" PRId64 ", actual timestamp = %" PRId64, __FUNCTION__, timestamp, actual); |