From 928a4535c8e7c09a6168d2e7a1b72233151b3ce3 Mon Sep 17 00:00:00 2001 From: Changyeon Jo Date: Thu, 18 May 2023 21:47:52 +0000 Subject: [PATCH] Increase frame counters in the same critical section Bug: 275049370 Test: atest VtsHalEvsV1_0TargetTest Change-Id: I814aac4edec142027d3802f5ee0d7a444ae2ee86 --- automotive/evs/1.0/vts/functional/FrameHandler.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/automotive/evs/1.0/vts/functional/FrameHandler.cpp b/automotive/evs/1.0/vts/functional/FrameHandler.cpp index 6a01a44dfe..4233430478 100644 --- a/automotive/evs/1.0/vts/functional/FrameHandler.cpp +++ b/automotive/evs/1.0/vts/functional/FrameHandler.cpp @@ -133,6 +133,9 @@ Return FrameHandler::deliverFrame(const BufferDesc& bufferArg) { // Local flag we use to keep track of when the stream is stopping bool timeToStop = false; + // Another local flag telling whether or not current frame is displayed. + bool frameDisplayed = false; + if (bufferArg.memHandle.getNativeHandle() == nullptr) { // Signal that the last frame has been received and the stream is stopped timeToStop = true; @@ -172,9 +175,7 @@ Return FrameHandler::deliverFrame(const BufferDesc& bufferArg) { } else { // Everything looks good! // Keep track so tests or watch dogs can monitor progress - mLock.lock(); - mFramesDisplayed++; - mLock.unlock(); + frameDisplayed = true; } } } @@ -197,12 +198,15 @@ Return FrameHandler::deliverFrame(const BufferDesc& bufferArg) { } - // Update our received frame count and notify anybody who cares that things have changed + // Update frame counters and notify anybody who cares that things have changed. mLock.lock(); if (timeToStop) { mRunning = false; } else { mFramesReceived++; + if (frameDisplayed) { + mFramesDisplayed++; + } } mLock.unlock(); mSignal.notify_all();