Camera: fix long dequeueBuffer call
Fix the long (>1s) dequeueBuffer call when a stream is managed by
Camera3BufferManager and its consumer end discards free buffers.
Test: CTS, no more long dequeBuffer call in GCA mode switch
Bug: 126054873
Change-Id: I03d6526b076796bb44f15cc2c4a092ff3d04fc1d
diff --git a/services/camera/libcameraservice/device3/Camera3BufferManager.h b/services/camera/libcameraservice/device3/Camera3BufferManager.h
index 025062e..f0de1c1 100644
--- a/services/camera/libcameraservice/device3/Camera3BufferManager.h
+++ b/services/camera/libcameraservice/device3/Camera3BufferManager.h
@@ -112,6 +112,10 @@
*
* After this call, the client takes over the ownership of this buffer if it is not freed.
*
+ * Sometimes free buffers are discarded from consumer side and the dequeueBuffer call returns
+ * TIMED_OUT, in this case calling getBufferForStream again with noFreeBufferAtConsumer set to
+ * true will notify buffer manager to update its states and also tries to allocate a new buffer.
+ *
* Return values:
*
* OK: Getting buffer for this stream was successful.
@@ -122,7 +126,9 @@
* to this buffer manager before.
* NO_MEMORY: Unable to allocate a buffer for this stream at this time.
*/
- status_t getBufferForStream(int streamId, int streamSetId, sp<GraphicBuffer>* gb, int* fenceFd);
+ status_t getBufferForStream(
+ int streamId, int streamSetId, sp<GraphicBuffer>* gb, int* fenceFd,
+ bool noFreeBufferAtConsumer = false);
/**
* This method notifies the manager that a buffer has been released by the consumer.