summaryrefslogtreecommitdiff
path: root/libs/input/InputConsumerNoResampling.cpp
diff options
context:
space:
mode:
author Paul Ramirez <peramirez@google.com> 2024-09-13 23:01:12 +0000
committer Paul Ramirez <peramirez@google.com> 2024-09-19 15:32:29 +0000
commitcd7488c13e2cc9b3f7cb7100812d353fe585fc07 (patch)
treef0bf392c1d9dfecc0e051db7567dd5b53ce29a0c /libs/input/InputConsumerNoResampling.cpp
parent322fb3b70d8151b984ed98b1909b9e0bd59e7601 (diff)
Fix batching logic in InputConsumerNoResampling.cpp
Fixed batching logic in InputConsumerNoResampling.cpp because it was violating resampling frameTime preconditions. Bug: 297226446 Flag: EXEMPT bugfix Test: TEST=libinput_tests; m $TEST && $ANDROID_HOST_OUT/nativetest64/$TEST/$TEST --gtest_filter="InputConsumerTest*" Change-Id: I1b658d5b9ac7a56a8a3917a49c2b97b60641c0d5
Diffstat (limited to 'libs/input/InputConsumerNoResampling.cpp')
-rw-r--r--libs/input/InputConsumerNoResampling.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/libs/input/InputConsumerNoResampling.cpp b/libs/input/InputConsumerNoResampling.cpp
index eb419180e7..de55828a39 100644
--- a/libs/input/InputConsumerNoResampling.cpp
+++ b/libs/input/InputConsumerNoResampling.cpp
@@ -37,6 +37,8 @@ namespace android {
namespace {
+using std::chrono::nanoseconds;
+
/**
* Log debug messages relating to the consumer end of the transport channel.
* Enable this via "adb shell setprop log.tag.InputTransportConsumer DEBUG" (requires restart)
@@ -485,7 +487,12 @@ InputConsumerNoResampling::createBatchedMotionEvent(const nsecs_t frameTime,
std::queue<InputMessage>& messages) {
std::unique_ptr<MotionEvent> motionEvent;
std::optional<uint32_t> firstSeqForBatch;
- while (!messages.empty() && !(messages.front().body.motion.eventTime > frameTime)) {
+ const nanoseconds resampleLatency =
+ (mResampler != nullptr) ? mResampler->getResampleLatency() : nanoseconds{0};
+ const nanoseconds adjustedFrameTime = nanoseconds{frameTime} - resampleLatency;
+
+ while (!messages.empty() &&
+ (messages.front().body.motion.eventTime <= adjustedFrameTime.count())) {
if (motionEvent == nullptr) {
motionEvent = createMotionEvent(messages.front());
firstSeqForBatch = messages.front().header.seq;
@@ -504,8 +511,7 @@ InputConsumerNoResampling::createBatchedMotionEvent(const nsecs_t frameTime,
if (!messages.empty()) {
futureSample = &messages.front();
}
- mResampler->resampleMotionEvent(static_cast<std::chrono::nanoseconds>(frameTime),
- *motionEvent, futureSample);
+ mResampler->resampleMotionEvent(nanoseconds{frameTime}, *motionEvent, futureSample);
}
return std::make_pair(std::move(motionEvent), firstSeqForBatch);
}