OSDN Git Service

Camera2: Tests: Fix CameraFrameTests to pass instead of failing and hanging.: DO...
authorIgor Murashkin <iam@google.com>
Tue, 18 Dec 2012 21:40:32 +0000 (13:40 -0800)
committerIgor Murashkin <iam@google.com>
Thu, 10 Jan 2013 19:46:11 +0000 (11:46 -0800)
Producer would wait for buffers to be released so it could dequeue into them.
Since the test never acquired/released buffers, it would run out, and then
the HAL would deadlock when trying to shutdown since the producing thread
would never finish.

Change-Id: I123f36d87a2e72a2c42d942c975c02b8bd3f9f1a

tests/camera2/CameraFrameTests.cpp

index fc681c4..13d1b17 100644 (file)
@@ -115,8 +115,18 @@ TEST_P(CameraFrameTest, GetFrame) {
     for (int i = 0; i < GetParam(); ++i) {
         ALOGV("Reading capture request %d", i);
         ASSERT_EQ(OK, mDevice->waitForNextFrame(CAMERA_FRAME_TIMEOUT));
+
         CameraMetadata frameMetadata;
         ASSERT_EQ(OK, mDevice->getNextFrame(&frameMetadata));
+
+        // wait for buffer to be available
+        ASSERT_EQ(OK, mFrameListener->waitForFrame(CAMERA_FRAME_TIMEOUT));
+        ALOGV("We got the frame now");
+
+        // mark buffer consumed so producer can re-dequeue it
+        CpuConsumer::LockedBuffer imgBuffer;
+        ASSERT_EQ(OK, mCpuConsumer->lockNextBuffer(&imgBuffer));
+        ASSERT_EQ(OK, mCpuConsumer->unlockBuffer(imgBuffer));
     }
 
 }