From 4bc4a3845e456fd464556d79d20650a107e873e5 Mon Sep 17 00:00:00 2001 From: Igor Murashkin Date: Wed, 20 Feb 2013 13:36:17 -0800 Subject: 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 --- include/camera/ProCamera.h | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'include/camera') 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 @@ public: // 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 @@ public: // - 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 remote(); protected: @@ -286,7 +297,7 @@ private: StreamInfo(int streamId) { this->streamID = streamId; cpuStream = false; - frameReady = false; + frameReady = 0; } StreamInfo() { @@ -299,7 +310,7 @@ private: sp cpuConsumer; sp frameAvailableListener; sp stc; - bool frameReady; + int frameReady; }; Condition mWaitCondition; -- cgit v1.1