diff options
author | 2018-12-13 19:23:36 -0800 | |
---|---|---|
committer | 2019-01-02 13:49:36 -0800 | |
commit | add8929f1d781fabf5526d90c17a853274655e79 (patch) | |
tree | 95544591810a63505f196e07639cb8c0be03301f | |
parent | 12598681b0f189ed8116d7194b3806d7771b39ba (diff) |
Consume video frames
An input device currently reads video frames, and stores them into local
queue. We limit the queue size to 10 frames.
Here, we add the step where an input mapper would consume the video
frames from the video device for a given input device, and then pass
them onto the input listener.
Test: integration tested by checking that frames are processed correctly
in input hal. To check if frames are processed correctly, look at the
active touch area and print a log message when the total area exceeds a
certain threshold.
Bug: 111480215
Change-Id: Ifc519389e12b44540e9a54fd273241f9f7cd057d
-rw-r--r-- | services/inputflinger/EventHub.cpp | 10 | ||||
-rw-r--r-- | services/inputflinger/InputReader.cpp | 6 | ||||
-rw-r--r-- | services/inputflinger/include/EventHub.h | 2 | ||||
-rw-r--r-- | services/inputflinger/tests/InputReader_test.cpp | 4 |
4 files changed, 20 insertions, 2 deletions
diff --git a/services/inputflinger/EventHub.cpp b/services/inputflinger/EventHub.cpp index aa241a00e9..18c3ded880 100644 --- a/services/inputflinger/EventHub.cpp +++ b/services/inputflinger/EventHub.cpp @@ -1028,6 +1028,16 @@ size_t EventHub::getEvents(int timeoutMillis, RawEvent* buffer, size_t bufferSiz return event - buffer; } +std::vector<TouchVideoFrame> EventHub::getVideoFrames(int32_t deviceId) { + AutoMutex _l(mLock); + + Device* device = getDeviceLocked(deviceId); + if (!device || !device->videoDevice) { + return {}; + } + return device->videoDevice->consumeFrames(); +} + void EventHub::wake() { ALOGV("wake() called"); diff --git a/services/inputflinger/InputReader.cpp b/services/inputflinger/InputReader.cpp index 73fcb1124d..3d5f1d92d5 100644 --- a/services/inputflinger/InputReader.cpp +++ b/services/inputflinger/InputReader.cpp @@ -6483,11 +6483,13 @@ void TouchInputMapper::dispatchMotion(nsecs_t when, uint32_t policyFlags, uint32 } } - NotifyMotionArgs args(mContext->getNextSequenceNum(), when, getDeviceId(), + const int32_t deviceId = getDeviceId(); + std::vector<TouchVideoFrame> frames = mDevice->getEventHub()->getVideoFrames(deviceId); + NotifyMotionArgs args(mContext->getNextSequenceNum(), when, deviceId, source, mViewport.displayId, policyFlags, action, actionButton, flags, metaState, buttonState, edgeFlags, deviceTimestamp, pointerCount, pointerProperties, pointerCoords, - xPrecision, yPrecision, downTime, /* videoFrames */ {}); + xPrecision, yPrecision, downTime, std::move(frames)); getListener()->notifyMotion(&args); } diff --git a/services/inputflinger/include/EventHub.h b/services/inputflinger/include/EventHub.h index dd64132f3e..295aca8955 100644 --- a/services/inputflinger/include/EventHub.h +++ b/services/inputflinger/include/EventHub.h @@ -211,6 +211,7 @@ public: * Returns the number of events obtained, or 0 if the timeout expired. */ virtual size_t getEvents(int timeoutMillis, RawEvent* buffer, size_t bufferSize) = 0; + virtual std::vector<TouchVideoFrame> getVideoFrames(int32_t deviceId) = 0; /* * Query current input state. @@ -303,6 +304,7 @@ public: const int32_t* keyCodes, uint8_t* outFlags) const; virtual size_t getEvents(int timeoutMillis, RawEvent* buffer, size_t bufferSize); + virtual std::vector<TouchVideoFrame> getVideoFrames(int32_t deviceId); virtual bool hasScanCode(int32_t deviceId, int32_t scanCode) const; virtual bool hasLed(int32_t deviceId, int32_t led) const; diff --git a/services/inputflinger/tests/InputReader_test.cpp b/services/inputflinger/tests/InputReader_test.cpp index b5d209092a..d39d8dc852 100644 --- a/services/inputflinger/tests/InputReader_test.cpp +++ b/services/inputflinger/tests/InputReader_test.cpp @@ -692,6 +692,10 @@ private: return 1; } + virtual std::vector<TouchVideoFrame> getVideoFrames(int32_t deviceId) { + return {}; + } + virtual int32_t getScanCodeState(int32_t deviceId, int32_t scanCode) const { Device* device = getDevice(deviceId); if (device) { |