ProCamera: Fix waitForFrameBuffer not handling multiple outstanding frames
If the CpuConsumer triggered multiple onFrameAvailable callbacks in between
a single waitForFrameBuffer call, the old code would only handle 1 callback.
This meant on two subsequent waitForFrameBuffer calls the second would always
timeout when two buffers were already available to be unlocked.
Bug: 8238112
Change-Id: Ibefca35005ac5c408e5ada97ec4a4344a9e3e497
diff --git a/include/camera/ProCamera.h b/include/camera/ProCamera.h
index f813c1c..cd2772c 100644
--- a/include/camera/ProCamera.h
+++ b/include/camera/ProCamera.h
@@ -196,9 +196,12 @@
// Blocks until a frame is available (CPU streams only)
// - Obtain the frame data by calling CpuConsumer::lockNextBuffer
// - Release the frame data after use with CpuConsumer::unlockBuffer
+ // Return value:
+ // - >0 - number of frames available to be locked
+ // - <0 - error (refer to error codes)
// Error codes:
// -ETIMEDOUT if it took too long to get a frame
- status_t waitForFrameBuffer(int streamId);
+ int waitForFrameBuffer(int streamId);
// Blocks until a metadata result is available
// - Obtain the metadata by calling consumeFrameMetadata()
@@ -211,6 +214,14 @@
// - Use waitForFrameMetadata to sync until new data is available.
CameraMetadata consumeFrameMetadata();
+ // Convenience method to drop frame buffers (CPU streams only)
+ // Return values:
+ // >=0 - number of frames dropped (up to count)
+ // <0 - error code
+ // Error codes:
+ // BAD_VALUE - invalid streamId or count passed
+ int dropFrameBuffer(int streamId, int count);
+
sp<IProCameraUser> remote();
protected:
@@ -286,7 +297,7 @@
StreamInfo(int streamId) {
this->streamID = streamId;
cpuStream = false;
- frameReady = false;
+ frameReady = 0;
}
StreamInfo() {
@@ -299,7 +310,7 @@
sp<CpuConsumer> cpuConsumer;
sp<ProFrameListener> frameAvailableListener;
sp<Surface> stc;
- bool frameReady;
+ int frameReady;
};
Condition mWaitCondition;