Loading libs/gui/DisplayEventDispatcher.cpp +17 −1 Original line number Diff line number Diff line Loading @@ -33,10 +33,13 @@ namespace android { // using just a few large reads. static const size_t EVENT_BUFFER_SIZE = 100; static constexpr nsecs_t WAITING_FOR_VSYNC_TIMEOUT = ms2ns(300); DisplayEventDispatcher::DisplayEventDispatcher( const sp<Looper>& looper, ISurfaceComposer::VsyncSource vsyncSource, ISurfaceComposer::EventRegistrationFlags eventRegistration) : mLooper(looper), mReceiver(vsyncSource, eventRegistration), mWaitingForVsync(false) { : mLooper(looper), mReceiver(vsyncSource, eventRegistration), mWaitingForVsync(false), mLastVsyncCount(0), mLastScheduleVsyncTime(0) { ALOGV("dispatcher %p ~ Initializing display event dispatcher.", this); } Loading Loading @@ -86,6 +89,7 @@ status_t DisplayEventDispatcher::scheduleVsync() { } mWaitingForVsync = true; mLastScheduleVsyncTime = systemTime(SYSTEM_TIME_MONOTONIC); } return OK; } Loading Loading @@ -124,9 +128,21 @@ int DisplayEventDispatcher::handleEvent(int, int events, void*) { this, ns2ms(vsyncTimestamp), to_string(vsyncDisplayId).c_str(), vsyncCount, vsyncEventData.id); mWaitingForVsync = false; mLastVsyncCount = vsyncCount; dispatchVsync(vsyncTimestamp, vsyncDisplayId, vsyncCount, vsyncEventData); } if (mWaitingForVsync) { const nsecs_t currentTime = systemTime(SYSTEM_TIME_MONOTONIC); const nsecs_t vsyncScheduleDelay = currentTime - mLastScheduleVsyncTime; if (vsyncScheduleDelay > WAITING_FOR_VSYNC_TIMEOUT) { ALOGW("Vsync time out! vsyncScheduleDelay=%" PRId64 "ms", ns2ms(vsyncScheduleDelay)); mWaitingForVsync = false; dispatchVsync(currentTime, vsyncDisplayId /* displayId is not used */, ++mLastVsyncCount, vsyncEventData /* empty data */); } } return 1; // keep the callback } Loading libs/gui/include/gui/DisplayEventDispatcher.h +2 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,8 @@ private: sp<Looper> mLooper; DisplayEventReceiver mReceiver; bool mWaitingForVsync; uint32_t mLastVsyncCount; nsecs_t mLastScheduleVsyncTime; std::vector<FrameRateOverride> mFrameRateOverrides; Loading Loading
libs/gui/DisplayEventDispatcher.cpp +17 −1 Original line number Diff line number Diff line Loading @@ -33,10 +33,13 @@ namespace android { // using just a few large reads. static const size_t EVENT_BUFFER_SIZE = 100; static constexpr nsecs_t WAITING_FOR_VSYNC_TIMEOUT = ms2ns(300); DisplayEventDispatcher::DisplayEventDispatcher( const sp<Looper>& looper, ISurfaceComposer::VsyncSource vsyncSource, ISurfaceComposer::EventRegistrationFlags eventRegistration) : mLooper(looper), mReceiver(vsyncSource, eventRegistration), mWaitingForVsync(false) { : mLooper(looper), mReceiver(vsyncSource, eventRegistration), mWaitingForVsync(false), mLastVsyncCount(0), mLastScheduleVsyncTime(0) { ALOGV("dispatcher %p ~ Initializing display event dispatcher.", this); } Loading Loading @@ -86,6 +89,7 @@ status_t DisplayEventDispatcher::scheduleVsync() { } mWaitingForVsync = true; mLastScheduleVsyncTime = systemTime(SYSTEM_TIME_MONOTONIC); } return OK; } Loading Loading @@ -124,9 +128,21 @@ int DisplayEventDispatcher::handleEvent(int, int events, void*) { this, ns2ms(vsyncTimestamp), to_string(vsyncDisplayId).c_str(), vsyncCount, vsyncEventData.id); mWaitingForVsync = false; mLastVsyncCount = vsyncCount; dispatchVsync(vsyncTimestamp, vsyncDisplayId, vsyncCount, vsyncEventData); } if (mWaitingForVsync) { const nsecs_t currentTime = systemTime(SYSTEM_TIME_MONOTONIC); const nsecs_t vsyncScheduleDelay = currentTime - mLastScheduleVsyncTime; if (vsyncScheduleDelay > WAITING_FOR_VSYNC_TIMEOUT) { ALOGW("Vsync time out! vsyncScheduleDelay=%" PRId64 "ms", ns2ms(vsyncScheduleDelay)); mWaitingForVsync = false; dispatchVsync(currentTime, vsyncDisplayId /* displayId is not used */, ++mLastVsyncCount, vsyncEventData /* empty data */); } } return 1; // keep the callback } Loading
libs/gui/include/gui/DisplayEventDispatcher.h +2 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,8 @@ private: sp<Looper> mLooper; DisplayEventReceiver mReceiver; bool mWaitingForVsync; uint32_t mLastVsyncCount; nsecs_t mLastScheduleVsyncTime; std::vector<FrameRateOverride> mFrameRateOverrides; Loading