Camera: Avoid dequeue too many buffers from buffer queue
The PreviewFrameSpacer could defer 1 or 2 buffers to reduce jitter.
And we update the handout buffer count at the time of queuing to
the preview frame spacer, not at the time of queuing to the buffer
queue.
This results in accounting mismatch where the framework could allow
the HAL to dequeue more buffers than supported.
The fix is to track the framework cached buffer count in addition to the
handout buffer count.
Test: Camera CTS, vendor testing, observe logcat with GoogleCamera
Bug: 242674531
Change-Id: I579ae7465b59f5bd9e12dfda332998b401793eb4
diff --git a/services/camera/libcameraservice/device3/Camera3Stream.h b/services/camera/libcameraservice/device3/Camera3Stream.h
index d429e6c..214618a 100644
--- a/services/camera/libcameraservice/device3/Camera3Stream.h
+++ b/services/camera/libcameraservice/device3/Camera3Stream.h
@@ -558,6 +558,10 @@
// Get handout input buffer count.
virtual size_t getHandoutInputBufferCountLocked() = 0;
+ // Get cached output buffer count.
+ virtual size_t getCachedOutputBufferCountLocked() const = 0;
+ virtual size_t getMaxCachedOutputBuffersLocked() const = 0;
+
// Get the usage flags for the other endpoint, or return
// INVALID_OPERATION if they cannot be obtained.
virtual status_t getEndpointUsage(uint64_t *usage) const = 0;
@@ -576,6 +580,8 @@
uint64_t mUsage;
+ Condition mOutputBufferReturnedSignal;
+
private:
// Previously configured stream properties (post HAL override)
uint64_t mOldUsage;
@@ -583,7 +589,6 @@
int mOldFormat;
android_dataspace mOldDataSpace;
- Condition mOutputBufferReturnedSignal;
Condition mInputBufferReturnedSignal;
static const nsecs_t kWaitForBufferDuration = 3000000000LL; // 3000 ms