summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Mathias Agopian <mathias@google.com> 2012-01-31 16:42:54 -0800
committer Mathias Agopian <mathias@google.com> 2012-01-31 16:42:54 -0800
commit58737fe96d9e5027e36a983161ab1888592b3eb8 (patch)
treec8ead9a6ea9f41519b79b917dea7c14b4f2f647d
parenta403a2e0f0d55a709821a6310de849176dc9b426 (diff)
fix an issue with vsync event delivery
vsync events were sometimes delivered to connected client who didn't request them. this happened if another client requested the delivery and that client was first in the client list. also fix the vsync test which didn't request any events as well as DisplayEventReveiver documentation which was misleading about the necessity to request vsync events. Change-Id: Ie990fda3f337f8f0042745c4b2cde67936c45686
-rw-r--r--include/gui/DisplayEventReceiver.h4
-rw-r--r--services/surfaceflinger/EventThread.cpp10
-rw-r--r--services/surfaceflinger/tests/vsync/vsync.cpp2
3 files changed, 8 insertions, 8 deletions
diff --git a/include/gui/DisplayEventReceiver.h b/include/gui/DisplayEventReceiver.h
index dccc1643c93a..a28137785e9a 100644
--- a/include/gui/DisplayEventReceiver.h
+++ b/include/gui/DisplayEventReceiver.h
@@ -63,7 +63,9 @@ public:
public:
/*
* DisplayEventReceiver creates and registers an event connection with
- * SurfaceFlinger. Events start being delivered immediately.
+ * SurfaceFlinger. VSync events are disabled by default. Call setVSyncRate
+ * or requestNextVsync to receive them.
+ * Other events start being delivered immediately.
*/
DisplayEventReceiver();
diff --git a/services/surfaceflinger/EventThread.cpp b/services/surfaceflinger/EventThread.cpp
index 92d4266a8fd9..af0da0bdb22c 100644
--- a/services/surfaceflinger/EventThread.cpp
+++ b/services/surfaceflinger/EventThread.cpp
@@ -151,9 +151,9 @@ bool EventThread::threadLoop() {
mLastVSyncTimestamp = timestamp;
// now see if we still need to report this VSYNC event
- bool reportVsync = false;
- size_t count = mDisplayEventConnections.size();
+ const size_t count = mDisplayEventConnections.size();
for (size_t i=0 ; i<count ; i++) {
+ bool reportVsync = false;
const ConnectionInfo& info(
mDisplayEventConnections.valueAt(i));
if (info.count >= 1) {
@@ -174,11 +174,7 @@ bool EventThread::threadLoop() {
displayEventConnections.add(mDisplayEventConnections.keyAt(i));
}
}
-
- if (reportVsync) {
- break;
- }
- } while (true);
+ } while (!displayEventConnections.size());
// dispatch vsync events to listeners...
vsync.header.type = DisplayEventReceiver::DISPLAY_EVENT_VSYNC;
diff --git a/services/surfaceflinger/tests/vsync/vsync.cpp b/services/surfaceflinger/tests/vsync/vsync.cpp
index 4f790802535c..b0d54c4e0b17 100644
--- a/services/surfaceflinger/tests/vsync/vsync.cpp
+++ b/services/surfaceflinger/tests/vsync/vsync.cpp
@@ -55,6 +55,8 @@ int main(int argc, char** argv)
loop->addFd(myDisplayEvent.getFd(), 0, ALOOPER_EVENT_INPUT, receiver,
&myDisplayEvent);
+ myDisplayEvent.setVsyncRate(1);
+
do {
//printf("about to poll...\n");
int32_t ret = loop->pollOnce(-1);