Respect max fps if specified in the request.
Sleep for appropriate amount of time before acquiring new image
from Surface in case acquiring image imediatelly would exceed max fps
specified by the request.
Bug: 338251124
Test: atest CtsVirtualDevicesCameraCtsTestCases:android.hardware.camera2.cts.CaptureRequestTest#testNoiseReductionModeControl[1]
Change-Id: I1ac504f05cef044b81a2531074e1bedd77412805
diff --git a/services/camera/virtualcamera/VirtualCameraRenderThread.h b/services/camera/virtualcamera/VirtualCameraRenderThread.h
index e222d5b..dfb6f7b 100644
--- a/services/camera/virtualcamera/VirtualCameraRenderThread.h
+++ b/services/camera/virtualcamera/VirtualCameraRenderThread.h
@@ -17,6 +17,7 @@
#ifndef ANDROID_COMPANION_VIRTUALCAMERA_VIRTUALCAMERARENDERTHREAD_H
#define ANDROID_COMPANION_VIRTUALCAMERA_VIRTUALCAMERARENDERTHREAD_H
+#include <atomic>
#include <cstdint>
#include <deque>
#include <future>
@@ -195,6 +196,9 @@
std::condition_variable mCondVar;
volatile bool mPendingExit GUARDED_BY(mLock);
+ // Acquisition timestamp of last frame.
+ std::atomic<uint64_t> mLastAcquisitionTimestampNanoseconds;
+
// EGL helpers - constructed and accessed only from rendering thread.
std::unique_ptr<EglDisplayContext> mEglDisplayContext;
std::unique_ptr<EglTextureProgram> mEglTextureYuvProgram;