Increase frame counters in the same critical section am: 928a4535c8

Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2594993

Change-Id: I8a59e6173179a284bb90960b30e2e5a35de075a1
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Changyeon Jo 2023-06-15 22:39:21 +00:00 committed by Automerger Merge Worker
commit a343d0cf0c

View file

@ -133,6 +133,9 @@ Return<void> 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<void> 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<void> 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();